How do I get ai
to interpret the tools response?
#2148
-
For context, I am building an AI agent to assist with supplement search (https://pillser.com/ask). User should be able to ask a question like "Find supplement that contains the most vitamin B" Then This is my code: const stream = await streamText({
messages: coreMessages,
model: openai('gpt-4o'),
system: systemPrompt.content,
tools: {
getSupplements: tool({
description: 'Finds Pillser products that match the keywords.',
execute: async ({ keywords }) => {
console.log('getSupplements', keywords);
return [
{
name: 'B-100 Complex',
url: 'https://pillser.com/supplements/b-100-complex-415',
},
];
},
parameters: z.object({
keywords: z.array(z.string()),
}),
}),
},
}); and this is what I am seeing in the stream:
It looks like whatever is returned from How do I use the pulled data to generate the response? It looks like in case of client-side, I should be using I would expect |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
I feel you! Generally speaking, AI SDK lacks a lot more flexibility on the handling of tool calls. |
Beta Was this translation helpful? Give feedback.
-
I achieved this. But I feel there are still some minor issues. |
Beta Was this translation helpful? Give feedback.
-
check out the docs here which should help. You have to set your maxRoundTrips https://sdk.vercel.ai/docs/ai-sdk-ui/chatbot-with-tool-calling |
Beta Was this translation helpful? Give feedback.
check out the docs here which should help. You have to set your maxRoundTrips
https://sdk.vercel.ai/docs/ai-sdk-ui/chatbot-with-tool-calling