Next.js Discord

Discord Forum

How to combine multiple streams into one stream ? AI sdk

Unanswered
Townsend's Solitaire posted this in #help-forum
Open in Discord
Townsend's SolitaireOP
Say I want to call this 7 times each with a different message at once and combine the results into one stream and stream that back to the client

        const response = await llm.chat.completions.create({
            model: "gpt-3.5-turbo-16k-0613",
            temperature: 0,
            stream: true,
            messages,
        });

        const stream = OpenAIStream(response, {
            onCompletion: (completion: string) => {
                console.log(`Completion Complete`);
            },
        });

        return new StreamingTextResponse(stream);

0 Replies