Replies: 1 comment
-
|
This discussion was automatically locked because it has not been updated in over 30 days. If you still have questions about this topic, please ask us at community.vercel.com/ai-sdk |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey guys, I'm using this route.ts code
`import { anthropic, AnthropicProviderOptions } from '@ai-sdk/anthropic';
import { convertToModelMessages, hasToolCall, streamText, tool, UIMessage, smoothStream, stepCountIs } from 'ai';
import { get_company_info } from './tools';
import z from 'zod';
const webSearchTool = anthropic.tools.webSearch_20250305({
maxUses: 5,
});
export async function POST(req: Request) {
try {
const { messages }: { messages: UIMessage[] } = await req.json();
} catch (error) {
console.error('Chat API error:', error);
return new Response(
JSON.stringify({ error: 'An error occurred while processing your request.' }),
{
status: 500,
headers: { 'Content-Type': 'application/json' },
}
);
}
}`
for my AI agent and using useChat to handle the frontend, i don't understand why the tool call to final_answer isn't streamed but only appear when the tool-call is finished.
i've also tried using final_answer as the stopWhen condition with hasToolCall but i get the same behaviour.
Beta Was this translation helpful? Give feedback.
All reactions