Next.js Discord

Discord Forum

tools calling for generateObject

Unanswered
Brown bear posted this in #help-forum
Open in Discord
Brown bearOP
hey all :blob_wave: , I working on agent built on to of vercel AI sdk and I just found out that we can't do tool calling with generateObject.

I wanted to know are there fundamental limitations of the current AI models that make this impossible, or is this a planned future?

13 Replies

not all models support tool calling
you need to read the docs of the provider and AI sdk's to see which model supports tool calling and how
Brown bearOP
but right now if I'm not mistaken regardless of the model we can't do tool calling with generateObject
I think you can, not sure
let me read the docs
yea sadly its only in generate and stream text
you could however, do 1 call to generateText with tool calling
and pass the output to generateObject to get desired output
Brown bearOP
yeah that what I found I just want to undertand the thinking behind the AI sdk api design.
@Yi Lon Ma you could however, do 1 call to generateText with tool calling
Brown bearOP
Unfortunately, I don't think that is also possible because you want the LLM to choose which tool to call, and if you cannot pass tools, it means the LLM will not get the tools' definition in the API code.
I meant to first call generateText with tools and then pass the output of that call to generateText to get the output you need
I am following this approach, just without the tools part
Brown bearOP
That would only work if you already know which tool you want the LLM to call. But, say you have five tools and you want the LLM to decide which tool to call, get the result, and decide what is the next tool to call. For the LLM to do that, it needs to get the list of tools that it has available.