-
Notifications
You must be signed in to change notification settings - Fork 15.8k
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
core: Fixed inspecting schema issue when working with InjectedToolArg annotations #28435
base: master
Are you sure you want to change the base?
Conversation
filter out `InjectedToolArg` when creating schemas from a function
…chema inspection.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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.
can we add some unit tests for the issue thats being fixed?
Hi @baskaryan, I’ve created a test case to address the problem scenario described in issue #27510. This test case verifies if user specific tools produce the correct Json schema for it's arguments(annotated with InjectedToolArg) using .args. However, if the current explanation or test coverage is not clear enough, please let me know. I’d greatly appreciate it if you could provide:
With this additional input, I can refine the solution further and ensure that the fix is comprehensive and robust across all relevant scenarios. |
InjectedToolArg
annotations cannot be properly inspected or converted into JSON schema, causing errors when working with special type annotations.Description:
(This PR has contributions from @Chloekyuu @JANERUBBISHTOEAT @chloepan33
1. Enhanced Argument Filtering with
_check_injected_arg_type
: It is used to correctly identify arguments annotated withInjectedToolArg
within thecreate_schema_from_function
, and ensures that arguments are properly added to thefilter_args
list wheninclude_injected=False
, allowing these arguments to be excluded from the schema as needed.2. Custom JSON Schema for
InjectedToolArg
: ImplementedInjectedToolArgSchema
that wrapsInjectedToolArg
inAnnotated
with a custom schema defined via WithJsonSchema, which allowsInjectedToolArg
to be parsed into a JSON schema format without causing errors, enabling proper inspection and compatibility with Pydantic.Issue:Cannot inspect schema when working with special type annotations #27510