replicate
pixeltable.functions.replicate
Pixeltable UDFs
that wrap various endpoints from the Replicate API. In order to use them, you must
first pip install replicate
and configure your Replicate credentials, as described in
the Working with Replicate tutorial.
run
run(input: Json, *, ref: String) -> Json
Run a model on Replicate.
For additional details, see: https://replicate.com/docs/topics/models/run-a-model
Requirements:
pip install replicate
Parameters:
-
input
(Json
) –The input parameters for the model.
-
ref
(String
) –The name of the model to run.
Returns:
-
Json
–The output of the model.
Examples:
Add a computed column that applies the model meta/meta-llama-3-8b-instruct
to an existing Pixeltable column tbl.prompt
of the table tbl
:
>>> input = {'system_prompt': 'You are a helpful assistant.', 'prompt': tbl.prompt}
... tbl['response'] = run(input, ref='meta/meta-llama-3-8b-instruct')
Add a computed column that uses the model black-forest-labs/flux-schnell
to generate images from an existing Pixeltable column tbl.prompt
:
>>> input = {'prompt': tbl.prompt, 'go_fast': True, 'megapixels': '1'}
... tbl['response'] = run(input, ref='black-forest-labs/flux-schnell')
... tbl['image'] = tbl.response.output[0].astype(pxt.Image)