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

chore: remove langchain _run method wrapper #395

Merged
merged 3 commits into from
Jan 29, 2025

Conversation

maciejmajek
Copy link
Member

@maciejmajek maciejmajek commented Jan 29, 2025

Purpose

Removing ._run method wrapper due to lsp typing problem.- wrong type annotations were shown for ._run methods using the wrapper.

Proposed Changes

  • Removes the wrapper,
  • Add test which searches for tools based on BaseTool and checks for mismatch between BaseTool.args_schema annotations and BaseTool._run annotations.
  • Fixes for bad annotations.

Testing

  • New CI test

style: refactor relative imports in non __init__ files due to problematic handling in tests
tests: new test for checking if BaseModel args schema annotations are equal to _run function annotations
Copy link
Member

@boczekbartek boczekbartek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I nitpick, one question - please check before merging. Overall approved!

tests/tools/test_tool_input_args_compatibility.py Outdated Show resolved Hide resolved
tool_input_annotations = (
tool.__annotations__["args_schema"].__args__[0].__annotations__
)
assert tool_run_annotations == tool_input_annotations
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it compare types as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, these are dicts of {'arg_name': 'type'} e.g. {'action_name': 'str'}

@maciejmajek maciejmajek merged commit df4a8ae into development Jan 29, 2025
5 checks passed
@maciejmajek maciejmajek deleted the refactor/remove-input-wrapper branch January 29, 2025 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants