Skip to content

Conversation

@lucataco
Copy link
Contributor

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

Screenshot 2025-10-20 at 2 33 56 PM

@SBrandeis

Copy link
Contributor

@hanouticelina hanouticelina left a 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") {
Copy link
Contributor

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?

Copy link
Contributor

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";
Copy link
Contributor

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

Suggested change
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];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants