-
Notifications
You must be signed in to change notification settings - Fork 45
[aisdk] Allow passing of provider metadata in tool definitions #579
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
Conversation
loreto
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
See comments.
|
|
||
| strict := true // Default to true | ||
| if tool.ProviderMetadata != nil { | ||
| fmt.Println("provider metadata: ", tool.ProviderMetadata) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove debugging statement
| return nil, nil, fmt.Errorf("failed to convert tool parameters: %w", err) | ||
| } | ||
|
|
||
| strict := true // Default to true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I care too much what the right default is, I think both are sensible, but just FYI, I'm looking at the Vercel code and they seem to now default to false instead: https://github.com/vercel/ai/blob/main/packages/openai/src/responses/openai-responses-language-model.ts#L135
They also seem to have renamed it from StrictSchemas to StrictJSONSchema 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kept default true for now
| strict := true // Default to true | ||
| if tool.ProviderMetadata != nil { | ||
| fmt.Println("provider metadata: ", tool.ProviderMetadata) | ||
| if metadata, ok := tool.ProviderMetadata.Get(ProviderName); ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe there's a GetMetadata helper that you should use here. You should be able to find examples of it being used elsewhere in the codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Summary
We need it so that we can specify whether the tool schema validation should be strict or not.
How was it tested?
Used with testpilot and its custom tools. I'll send a PR on axiom to show its usage too.
Community Contribution License
All community contributions in this pull request are licensed to the project maintainers under the terms of the Apache 2 License.
By creating this pull request I represent that I have the right to license the contributions to the project maintainers under the Apache 2 License as stated in the Community Contribution License.