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 {
274
274
* @yields {ServerSentEvent} Each streamed event from the prediction
275
275
*/
276
276
async * stream ( ref , options ) {
277
- const { wait, ...data } = options ;
277
+ const { wait, signal , ...data } = options ;
278
278
279
279
const identifier = ModelVersionIdentifier . parse ( ref ) ;
280
280
@@ -296,11 +296,10 @@ class Replicate {
296
296
}
297
297
298
298
if ( prediction . urls && prediction . urls . stream ) {
299
- const { signal } = options ;
300
299
const stream = createReadableStream ( {
301
300
url : prediction . urls . stream ,
302
301
fetch : this . fetch ,
303
- options : { signal } ,
302
+ ... ( signal ? { options : { signal } } : { } ) ,
304
303
} ) ;
305
304
306
305
yield * streamAsyncIterator ( stream ) ;
Original file line number Diff line number Diff line change @@ -5,12 +5,14 @@ export default {
5
5
const replicate = new Replicate ( { auth : env . REPLICATE_API_TOKEN } ) ;
6
6
7
7
try {
8
+ const controller = new AbortController ( ) ;
8
9
const output = replicate . stream (
9
10
"replicate/canary:30e22229542eb3f79d4f945dacb58d32001b02cc313ae6f54eef27904edf3272" ,
10
11
{
11
12
input : {
12
13
text : "Colin CloudFlare" ,
13
14
} ,
15
+ signal : controller . signal ,
14
16
}
15
17
) ;
16
18
const stream = new ReadableStream ( {
You can’t perform that action at this time.
0 commit comments