replicate / replicate-swift

Swift client for Replicate
https://replicate.com
Apache License 2.0
157 stars 33 forks source link

Is it possible to get a prediction status change callback while waiting for the result? #55

Closed ynie closed 1 month ago

ynie commented 11 months ago

Sometimes it takes minutes to start a prediction, so it's nice to have this information so we can update the UI to give users some hint on the progress. Thanks!

mattt commented 1 month ago

Hi @ynie. Sorry for not responding sooner. I'm happy to say that this is now possible thanks to https://github.com/replicate/replicate-swift/pull/90, which is in 0.23.0.

let output = try await replicate.run(
    "stability-ai/stable-diffusion-3",
    ["prompt": "a 19th century portrait of a gentleman otter"]
) { prediction in
    // Print the prediction status after each update
    print(prediction.status)
}