Skip to content
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

Tools with Generate Object #1803

Open
arnau01 opened this issue Jun 3, 2024 · 8 comments
Open

Tools with Generate Object #1803

arnau01 opened this issue Jun 3, 2024 · 8 comments
Labels
ai/core enhancement New feature or request

Comments

@arnau01
Copy link

arnau01 commented Jun 3, 2024

Feature Description

Generating structured data is very helpful, would be great if tool calling was supported.

Use Case

Providing a output schema and having access to external tools

Additional context

No response

@lgrammel lgrammel added enhancement New feature or request ai/core labels Jun 3, 2024
@lgrammel
Copy link
Collaborator

lgrammel commented Jun 3, 2024

generateObject uses forced tool calling under the hood for some providers, so this might not be possible.

@arnau01
Copy link
Author

arnau01 commented Jun 3, 2024

Makes sense, my current workaround is a simple chain, first generateText then streamObject which allows for tool usage and also controlling the schema.

@stephenkalnoske
Copy link

Makes sense, my current workaround is a simple chain, first generateText then streamObject which allows for tool usage and also controlling the schema.

Can you give an example of this?

@mi3lix9
Copy link

mi3lix9 commented Aug 8, 2024

You could throw an error with providers which use tool calling and enable it for natively support json mode

@michaeloliverx
Copy link
Contributor

How can I use tool calling along with generateObject?

My structured output requires some lookups to generate its data, how can I work around this for now?

@lgrammel
Copy link
Collaborator

lgrammel commented Sep 3, 2024

@michaeloliverx you can just do the lookups before calling generateObject and add the result to the prompt.

@michaeloliverx
Copy link
Contributor

The queries to lookup need to be inferred by the LLM itself then I would like a chain of thought structured output back. AFAIK structured-outputs and tool calling is supported in "pure" openai SDK usage?

https://platform.openai.com/docs/guides/structured-outputs/examples?lang=node.js

@lgrammel
Copy link
Collaborator

Not quite the same but you can use the "Agents with Structured Answers" approach: https://sdk.vercel.ai/docs/ai-sdk-core/agents#structured-answers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai/core enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants