-
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -93,11 +93,21 @@ func encodeFunctionTool(tool api.FunctionTool) (*responses.ToolUnionParam, []api | |
| return nil, nil, fmt.Errorf("failed to convert tool parameters: %w", err) | ||
| } | ||
|
|
||
| strict := true // Default to true | ||
| if tool.ProviderMetadata != nil { | ||
| fmt.Println("provider metadata: ", tool.ProviderMetadata) | ||
|
||
| if metadata, ok := tool.ProviderMetadata.Get(ProviderName); ok { | ||
|
||
| metadata := metadata.(Metadata) | ||
| if metadata.StrictSchemas != nil { | ||
| strict = *metadata.StrictSchemas | ||
| } | ||
| } | ||
| } | ||
|
|
||
| result := responses.ToolParamOfFunction( | ||
| name, | ||
| props, | ||
| // TODO: allow passing the strict flag to the function | ||
| true, // strict mode enabled | ||
| strict, | ||
| ) | ||
|
|
||
| // Add description if provided | ||
|
|
||
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