File tree Expand file tree Collapse file tree 2 files changed +4
-3
lines changed
integration/cloudflare-worker Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -274,7 +274,7 @@ class Replicate {
274274 * @yields {ServerSentEvent} Each streamed event from the prediction
275275 */
276276 async * stream ( ref , options ) {
277- const { wait, ...data } = options ;
277+ const { wait, signal , ...data } = options ;
278278
279279 const identifier = ModelVersionIdentifier . parse ( ref ) ;
280280
@@ -296,11 +296,10 @@ class Replicate {
296296 }
297297
298298 if ( prediction . urls && prediction . urls . stream ) {
299- const { signal } = options ;
300299 const stream = createReadableStream ( {
301300 url : prediction . urls . stream ,
302301 fetch : this . fetch ,
303- options : { signal } ,
302+ ... ( signal ? { options : { signal } } : { } ) ,
304303 } ) ;
305304
306305 yield * streamAsyncIterator ( stream ) ;
Original file line number Diff line number Diff line change @@ -5,12 +5,14 @@ export default {
55 const replicate = new Replicate ( { auth : env . REPLICATE_API_TOKEN } ) ;
66
77 try {
8+ const controller = new AbortController ( ) ;
89 const output = replicate . stream (
910 "replicate/canary:30e22229542eb3f79d4f945dacb58d32001b02cc313ae6f54eef27904edf3272" ,
1011 {
1112 input : {
1213 text : "Colin CloudFlare" ,
1314 } ,
15+ signal : controller . signal ,
1416 }
1517 ) ;
1618 const stream = new ReadableStream ( {
You can’t perform that action at this time.
0 commit comments