@@ -578,7 +578,7 @@ export const wait = {
578578 *
579579 * @param token - The token to wait for.
580580 * @param options - The options for the waitpoint token.
581- * @returns The waitpoint token .
581+ * @returns A promise that resolves to the result of the waitpoint. You can use `.unwrap()` to get the result and an error will throw .
582582 */
583583 forToken : < T > (
584584 /**
@@ -690,30 +690,35 @@ export const wait = {
690690 * ```ts
691691 * //wait for the prediction to complete
692692 const prediction = await wait.forHttpCallback<Prediction>(
693- async (url) => {
694- //pass the provided URL to Replicate's webhook
695- await replicate.predictions.create({
696- version:
697- "19deaef633fd44776c82edf39fd60e95a7250b8ececf11a725229dc75a81f9ca",
698- input: payload,
699- // pass the provided URL to Replicate's webhook, so they can "callback"
700- webhook: url,
701- webhook_events_filter: ["completed"],
702- });
703- },
704- {
705- timeout: "2m",
693+ async (url) => {
694+ //pass the provided URL to Replicate's webhook
695+ await replicate.predictions.create({
696+ version: "27b93a2413e7f36cd83da926f3656280b2931564ff050bf9575f1fdf9bcd7478",
697+ input: {
698+ prompt: "A painting of a cat by Any Warhol",
699+ },
700+ // pass the provided URL to Replicate's webhook, so they can "callback"
701+ webhook: url,
702+ webhook_events_filter: ["completed"],
703+ });
704+ },
705+ {
706+ timeout: "10m",
707+ }
708+ );
709+
710+ if (!prediction.ok) {
711+ throw new Error("Failed to create prediction");
706712 }
707- );
708713
709- //the value of prediction is the body of the webook that Replicate sent
710- const result = prediction.output;
714+ //the value of prediction is the body of the webook that Replicate sent
715+ const result = prediction.output;
711716 * ```
712717 *
713- * @param callback
714- * @param options
715- * @param requestOptions
716- * @returns
718+ * @param callback A function that gives you a URL you can use to send the result to.
719+ * @param options - The options for the waitpoint.
720+ * @param requestOptions - The request options for the waitpoint.
721+ * @returns A promise that resolves to the result of the waitpoint. You can use `.unwrap()` to get the result and an error will throw.
717722 */
718723 forHttpCallback < TResult > (
719724 callback : ( url : string ) => Promise < void > ,
0 commit comments