-
Notifications
You must be signed in to change notification settings - Fork 241
Closed
Description
The replicate.run method provides a nice way of running a prediction and getting its output with a single line of code:
const output = await replicate.run(identifier, options, progress);That's nice if I only want the prediction output. But what if I want the whole prediction object? For example, maybe I want to know the prediction id, or see how long the prediction took to run. In this case, the best option is this:
let prediction = await replicate.predictions.create({ version, input })
prediction = await replicate.wait(prediction);That works, but it's not ideal for a few reasons:
- It's more code. No longer a glamorous one-liner.
- The fact that
replicate.prediction.createis itself an async function makes me think that maybe I'm awaiting its completion too, when in fact I'm actually just awaiting the empty shell of a prediction. - The
waitcall is on thereplicateobject, rather than on thepredictioninstance itself. This is confusing. - I can't make the prediction a
constbecause I have to re-assign it when I callwait. It feels weird to create a thing and then overwrite it entirely, especially in the age of JavaScript constants. - I would probably always have to look at the docs to get this right.
How can we make this better? My off-the-cuff idea is a wait option on the replicate.predictions.create method:
const prediction = await replicate.predictions.create({ version, input, wait: true })What do folks think of that? Open to ideas here.
cc @replicate/product @replicate/hackers
Metadata
Metadata
Assignees
Labels
No labels