-
Hello, I'm using If I'm able to Do you know what I'm missing? try {
// .... Logic ....
c.header('X-Vercel-AI-Data-Stream', 'v1')
c.header('Content-Type', 'text/event-stream; charset=utf-8')
return stream(c, (stream) =>
stream
.pipe((answer as StreamTextResult<Record<string, CoreTool>, unknown>).textStream)
.catch(() => { throw new Error('Streaming error') })
)
} catch (e) {
console.log('DOES NOT PRINT')
console.error(e)
return c.html(view())
} try {
// .... Logic ....
c.header("X-Vercel-AI-Data-Stream", "v1");
c.header("Content-Type", "text/event-stream; charset=utf-8");
return stream(
c,
(stream) => stream.pipe(answer.textStream),
async (e, stream) => {
throw new Error("streaming error");
}
)
} catch (e) {
console.log('DOES NOT PRINT')
console.error(e);
return c.html(view());
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
EdamAme-x
Jan 23, 2025
Replies: 1 comment 1 reply
-
Please try to use this app.get('/stream', (c) => {
return stream(
c,
async (stream) => {
// Write a process to be executed when aborted.
stream.onAbort(() => {
console.log('Aborted!')
})
// Write a Uint8Array.
await stream.write(
new Uint8Array([0x48, 0x65, 0x6c, 0x6c, 0x6f])
)
// Pipe a readable stream.
await stream.pipe(anotherReadableStream)
},
(err, stream) => {
// return error page here
stream.writeln('An error occurred!')
console.error(err)
}
)
}) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
charnould
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please try to use this