- Notifications
You must be signed in to change notification settings - Fork2k
feat(function_schema): Add support for pydanticField
annotations in tool arguments (for tools decorated with@function_schema
)#1124
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Field
annotations in tool arguments (for tools decorated with@function_schema
)Field
annotations in tool arguments (for tools decorated with@function_schema
)Could you check the lint error?
|
georg-wolflein commentedJul 15, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Done:)@seratch |
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;@rm-openai can you take a look at this?
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.
This is so good, thanks!@georg-wolflein in a follow up would also love some docs for this
14154b7
intoopenai:mainUh oh!
There was an error while loading.Please reload this page.
Summary
This PR allows you to use the pydantic
Field
decorator to constrain tool arguments for tools decorated with@function_tool
(more specifically, for tools usingfunction_schema
to parse tool arguments). Such constrains include, e.g. limiting integers to a certain range, but in principle, this should work forany constrains supported by the API.Specifically, it enables the following syntax:
Previously, one had to create a nested pydantic
BaseModel
to achieve this functionality.Issue#1123 explains this feature request and the previous workaround.
Example:
Output: (compare to#1123)
Test plan
I added unit tests in
tests/test_function_schema.py
.Issue number
Closes#1123.
Checks
make lint
andmake format
Note: I am happy to add documentation for this; please point me to where I should do so:)