replicate-javascript icon indicating copy to clipboard operation
replicate-javascript copied to clipboard

Use Bun macros to generate typed interfaces for models at bundle time

Open mattt opened this issue 1 year ago • 0 comments

From https://bun.sh/docs/bundler/macros:

Macros are a mechanism for running JavaScript functions at bundle-time. The value returned from these functions are directly inlined into your bundle.

We could use this to download model schemas and provide typed interfaces for their inputs and outputs.

import 'replicate'
import { load } from 'replicate' with { type: 'macro' }
const sd3 = load("stability-ai/stable-diffusion-3")

const image = replicate.run(sd3, { input: { "prompt": "an astronaut riding a rainbow unicorn" })

mattt avatar Jul 15 '24 09:07 mattt