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

fix: remove callbacks arg from Tool and StructuredTool inferred schema #6483

Merged
merged 8 commits into from Jun 23, 2023

Conversation

aledelunap
Copy link
Contributor

Fixes #5456

This PR removes the callbacks argument from a tool's schema when creating a Tool or StructuredTool with the from_function method and infer_schema is set to True. The callbacks argument is now removed in the create_schema_from_function and _get_filtered_args methods. As suggested by @vowelparrot, this fix provides a straightforward solution that minimally affects the existing implementation.

A test was added to verify that this change enables the expected use of Tool and StructuredTool when using a CallbackManager and inferring the tool's schema.

@vercel
Copy link

vercel bot commented Jun 20, 2023

@aledelunap is attempting to deploy a commit to the LangChain Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Jun 21, 2023

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

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Jun 21, 2023 5:58pm

Copy link
Contributor

@vowelparrot vowelparrot left a comment

Choose a reason for hiding this comment

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

Thank you for making this fix! I had two minor suggestions (in addition to any linting fixes)

langchain/tools/base.py Outdated Show resolved Hide resolved
tests/unit_tests/tools/test_base.py Show resolved Hide resolved
@vowelparrot vowelparrot merged commit 980c865 into langchain-ai:master Jun 23, 2023
14 checks passed
This was referenced Jun 25, 2023
@aledelunap aledelunap deleted the fix/tools-schema branch June 28, 2023 20:04
kacperlukawski pushed a commit to kacperlukawski/langchain that referenced this pull request Jun 29, 2023
langchain-ai#6483)

Fixes langchain-ai#5456 

This PR removes the `callbacks` argument from a tool's schema when
creating a `Tool` or `StructuredTool` with the `from_function` method
and `infer_schema` is set to `True`. The `callbacks` argument is now
removed in the `create_schema_from_function` and `_get_filtered_args`
methods. As suggested by @vowelparrot, this fix provides a
straightforward solution that minimally affects the existing
implementation.

A test was added to verify that this change enables the expected use of
`Tool` and `StructuredTool` when using a `CallbackManager` and inferring
the tool's schema.

  - @hwchase17
aerrober pushed a commit to aerrober/langchain-fork that referenced this pull request Jul 24, 2023
langchain-ai#6483)

Fixes langchain-ai#5456 

This PR removes the `callbacks` argument from a tool's schema when
creating a `Tool` or `StructuredTool` with the `from_function` method
and `infer_schema` is set to `True`. The `callbacks` argument is now
removed in the `create_schema_from_function` and `_get_filtered_args`
methods. As suggested by @vowelparrot, this fix provides a
straightforward solution that minimally affects the existing
implementation.

A test was added to verify that this change enables the expected use of
`Tool` and `StructuredTool` when using a `CallbackManager` and inferring
the tool's schema.

  - @hwchase17
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.

Tools: Inconsistent callbacks/run_manager parameter
2 participants