Constantin
Constantin
CDCloudflare Developers
Created by Constantin on 3/15/2024 in #workers-help
Worker - Streaming : it takes quite a long time for the client to get the first data: is it normal ?
I am following the example in the documentation: https://developers.cloudflare.com/workers-ai/models/llama-2-7b-chat-int8/#code-examples The code I past in my browser to log event from the worker. When I run it, I see the first log after ~6 seconds. This seems quite a long period of time, but is it normal ? Thanks !
const source = new EventSource("/"); // Workers AI streaming endpoint
source.onmessage = (event) => {
if (event.data == "[DONE]") {
source.close();
return;
}
const data = JSON.parse(event.data);
console.log(data.response);
}
const source = new EventSource("/"); // Workers AI streaming endpoint
source.onmessage = (event) => {
if (event.data == "[DONE]") {
source.close();
return;
}
const data = JSON.parse(event.data);
console.log(data.response);
}
2 replies