-
Notifications
You must be signed in to change notification settings - Fork 538
[Inference] Add async polling support for Replicate provider #1816
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[Inference] Add async polling support for Replicate provider #1816
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @lucataco for the PR! I left some comments
| const prediction = (await pollResponse.json()) as ReplicateAsyncResponse; | ||
| const predictionStatus = prediction.status; | ||
|
|
||
| if (!predictionStatus || predictionStatus === "succeeded") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it intentional to treat "no status" as a successful response?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we have to remove Prefer: wait from the headers (defined in prepareHeaders) now that all the tasks are using async polling
| output?: string | string[]; | ||
| } | ||
|
|
||
| type ReplicatePredictionStatus = "starting" | "processing" | "succeeded" | "failed" | "canceled" | "queued"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i believe this gives tighter typings and better autocomplete support
| type ReplicatePredictionStatus = "starting" | "processing" | "succeeded" | "failed" | "canceled" | "queued"; | |
| const REPLICATE_STATUSES = [ | |
| "starting", | |
| "processing", | |
| "succeeded", | |
| "failed", | |
| "canceled", | |
| "queued", | |
| ] as const; | |
| type ReplicatePredictionStatus = (typeof REPLICATE_STATUSES)[number]; |
This PR adds async polling for Replicate
To help the huggingface team so that they no longer need an allow-list of Replicate models to show Hub users
@SBrandeis