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

core: Fixed inspecting schema issue when working with InjectedToolArg annotations #28435

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

XiaoConan
Copy link

@XiaoConan XiaoConan commented Dec 1, 2024

  • PR message: This PR addresses the issueCannot inspect schema when working with special type annotations #27510 where 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 with InjectedToolArg within the create_schema_from_function, and ensures that arguments are properly added to the filter_args list when include_injected=False, allowing these arguments to be excluded from the schema as needed.
      2. Custom JSON Schema for InjectedToolArg: Implemented InjectedToolArgSchema that wraps InjectedToolArg in Annotated with a custom schema defined via WithJsonSchema, which allows InjectedToolArg 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

Copy link

vercel bot commented Dec 1, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchain ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 17, 2024 1:11am

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. langchain Related to the langchain package 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature labels Dec 1, 2024
Copy link
Collaborator

@baskaryan baskaryan left a 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?

@baskaryan baskaryan added the needs test PR needs to be updated with tests label Dec 9, 2024
@XiaoConan
Copy link
Author

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:

  1. A more detailed explanation of the issue or edge cases you’ve identified.
  2. Specific use cases or test scripts where this problem occurs more prominently.

With this additional input, I can refine the solution further and ensure that the fix is comprehensive and robust across all relevant scenarios.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature langchain Related to the langchain package needs test PR needs to be updated with tests size:M This PR changes 30-99 lines, ignoring generated files.
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

3 participants