replicate / replicate-python

Python client for Replicate
https://replicate.com
Apache License 2.0
696 stars 194 forks source link

Support `predictions.create` with `model`, `version`, or `deployment` parameters #290

Closed mattt closed 2 months ago

mattt commented 2 months ago

This PR updates predictions.create to support overloads with model, version, or deployment parameters. With these changes, API consumers can more easily change between official models, model versions, and deployments.

import replicate

prediction = replicate.predictions.create(
    model="meta/meta-llama-3-8b-instruct",
    input={"prompt": "write a haiku about corgis"},
)

prediction = replicate.predictions.create(
    version="39ed52f2a78e934b3ba6e2a89f5b1c712de7dfea535525255b1aa35c5565e08b",
    input={"prompt": "a studio photo of a rainbow colored corgi"},
)

prediction = replicate.predictions.create(
    deployment="my-username/my-embeddings-model",
    input={"text": "hello world"},
)