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[fix] @tool typing #25856

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

Conversation

samjove
Copy link
Contributor

@samjove samjove commented Aug 29, 2024

Description: Fixes '@tool' typing addressing incompatibility in assignment
Issue: #24089

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Aug 29, 2024
Copy link

vercel bot commented Aug 29, 2024

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

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview Dec 19, 2024 3:35pm

@dosubot dosubot bot added langchain Related to the langchain package 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature labels Aug 29, 2024
@ccurme ccurme added Ɑ: core Related to langchain-core and removed langchain Related to the langchain package labels Aug 29, 2024
@samjove samjove force-pushed the 24089_fix_tool_typing branch from 0a52e2d to 0c6914c Compare August 29, 2024 18:27
infer_schema: bool = True,
response_format: Literal["content", "content_and_artifact"] = "content",
parse_docstring: bool = False,
error_on_invalid_docstring: bool = True,
) -> Callable:
) -> StructuredTool:
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should be Union[Tool, Callable] i believe

@tool(return_direct=True)  # this outputs a Callable that creates a StructuredTool
def foo(...)

@tool(infer_schema=False)   # this outputs a Callable that creates a Tool
def foo(...)

@@ -101,6 +101,17 @@ async def _arun(self, arg1: int, arg2: bool, arg3: Optional[dict] = None) -> str
raise NotImplementedError


def test_tool_typing() -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

could we add a test case for each tool overload variant?

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 Ɑ: core Related to langchain-core 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