Skip to content

Commit 36b5f03

Browse files
committed
Fix behavior of run when wait is set
1 parent be0f323 commit 36b5f03

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,15 @@ class Replicate {
165165
throw new Error("Invalid model version identifier");
166166
}
167167

168+
// When `wait` is set, the server may respond
169+
// with the prediction output directly.
170+
// If it hasn't finished, the prediction object is returned
171+
// with an `id` property that can be used to poll for completion.
172+
if (wait && !("id" in prediction)) {
173+
const output = prediction;
174+
return output;
175+
}
176+
168177
// Call progress callback with the initial prediction object
169178
if (progress) {
170179
progress(prediction);

0 commit comments

Comments
 (0)