Skip to content

Send a fixed string from the /api/chat endpoint #262

Answered by spy16
spy16 asked this question in Help
Discussion options

You must be logged in to vote

I figured out I can do this:

const getStream = (text: string) => {
    const encoder = new TextEncoder();
    const encodedChunk = encoder.encode(text);
    return new ReadableStream({
        start(controller) {
            controller.enqueue(encodedChunk);
            controller.close();
        }
    });
}

Let me know if there are better way to send errors.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by spy16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
1 participant