File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -213,9 +213,23 @@ Returns `AsyncGenerator<ServerSentEvent>` which yields the events of running the
213213Example:
214214
215215``` js
216- for await (const event of replicate .stream (" meta/llama-2-70b-chat" )) {
217- process .stdout .write (` ${ event } ` );
216+ const model = " meta/llama-2-70b-chat" ;
217+ const options = {
218+ input: {
219+ prompt: " Write a poem about machine learning in the style of Mary Oliver." ,
220+ },
221+ // webhook: "https://smee.io/dMUlmOMkzeyRGjW" // optional
222+ };
223+ const output = [];
224+
225+ for await (const event of replicate .stream (model, options)) {
226+ console .debug ({ event });
227+ if (event && event === " output" ) {
228+ output .push (event .data );
229+ }
218230}
231+
232+ console .log (output .join (" " ).trim ());
219233```
220234
221235### Server-sent events
You can’t perform that action at this time.
0 commit comments