Skip to content

fix (examples): avoid mixed message types in use-chat-streamdata-multistep #5824

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion content/cookbook/01-next/24-stream-text-multistep.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ export async function POST(req: Request) {
system:
'You are a helpful assistant with a different system prompt. Repeat the extract user goal in your answer.',
// continue the workflow stream with the messages from the previous step:
messages: [...messages, ...(await result1.response).messages],
messages: [
...convertToCoreMessages(messages),
...(await result1.response).messages,
],
});

// forward the 2nd result to the client (incl. the finish event):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { openai } from '@ai-sdk/openai';
import { createDataStreamResponse, streamText, tool } from 'ai';
import {
convertToCoreMessages,
createDataStreamResponse,
streamText,
tool,
} from 'ai';
import { z } from 'zod';

export async function POST(req: Request) {
Expand Down Expand Up @@ -36,7 +41,10 @@ export async function POST(req: Request) {
system:
'You are a helpful assistant with a different system prompt. Repeat the extract user goal in your answer.',
// continue the workflow stream with the messages from the previous step:
messages: [...messages, ...(await result1.response).messages],
messages: [
...convertToCoreMessages(messages),
...(await result1.response).messages,
],
});

// forward the 2nd result to the client (incl. the finish event):
Expand Down
Loading