This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is a customized version of the original script: | |
// https://til.simonwillison.net/llms/streaming-llm-apis | |
// Adapted for Replicate Streaming API documentation: | |
// https://replicate.com/docs/topics/predictions/streaming | |
async function* sseStreamIterator(apiUrl, requestBody, extraHeaders) { | |
// POST. | |
let response = await fetch(apiUrl, { | |
method: 'POST', |