Replies: 1 comment 3 replies
-
I'm also running into this behavior. Another side effect of this is that the import { openai } from '@ai-sdk/openai';
import { streamText } from 'ai';
// Allow streaming responses up to 30 seconds
export const maxDuration = 30;
export async function POST(req: Request) {
const { messages } = await req.json();
const result = streamText({
model: openai('gpt-4-turbo'),
messages,
async onFinish({ text, toolCalls, toolResults, usage, finishReason, responseMessages }) {
// implement your own storage logic:
// Note: toolCalls and toolResults are always empty even when tools were called
await saveChat({ text, toolCalls, toolResults });
},
});
return result.toDataStreamResponse();
} The [
{
role: 'assistant',
content: [
{ type: 'text', text: '' },
{
type: 'tool-call',
toolCallId: 'call_9bchLFghtVPs1ub4JXgBFjHu',
toolName: 'getWeatherInformation',
args: { city: 'Kapstadt' }
}
]
},
{
role: 'tool',
content: [
{
type: 'tool-result',
toolCallId: 'call_9bchLFghtVPs1ub4JXgBFjHu',
toolName: 'getWeatherInformation',
result: 'windy'
}
]
},
{
role: 'assistant',
content: [
{
type: 'text',
text: 'Das Wetter in Kapstadt ist derzeit windig.'
}
]
}
] The vercel/ai-chatbot currently uses the Would be great to know whether this is a bug in the way messages are structured, or expected behavior and the |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello everyone!
I am building a RAG application which basically works like any other RAG.
I want the LLM to choose between 3 tools:
I am using:
"ai": 3.4.33
"next": "14.1.3"
For some reason, whenever the LLM calls a tool, it appends an empty message to the messages Array, which leads to my UI rendering one or more empty chat bubbles:
This is my Chat component:
This is my route:
Is this expected behaviour and I need to adjust my UI and filter out those emtpy messges or am I doing something wrong?
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions