mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-23 03:19:38 +00:00
core[patch]: add InjectedToolArg annotation (#24279)
```python from typing_extensions import Annotated from langchain_core.tools import tool, InjectedToolArg from langchain_anthropic import ChatAnthropic @tool def multiply(x: int, y: int, not_for_model: Annotated[dict, InjectedToolArg]) -> str: """multiply.""" return x * y ChatAnthropic(model='claude-3-sonnet-20240229',).bind_tools([multiply]).invoke('5 times 3').tool_calls ''' -> [{'name': 'multiply', 'args': {'x': 5, 'y': 3}, 'id': 'toolu_01Y1QazYWhu4R8vF4hF4z9no', 'type': 'tool_call'}] ''' ``` --------- Co-authored-by: Bagatur <baskaryan@gmail.com> Co-authored-by: Bagatur <22008038+baskaryan@users.noreply.github.com>
This commit is contained in:
@@ -89,6 +89,10 @@ def convert_to_ollama_tool(tool: Any) -> Dict:
|
||||
if _is_pydantic_class(tool):
|
||||
schema = tool.construct().schema()
|
||||
name = schema["title"]
|
||||
elif isinstance(tool, BaseTool):
|
||||
schema = tool.tool_call_schema.schema()
|
||||
name = tool.get_name()
|
||||
description = tool.description
|
||||
elif _is_pydantic_object(tool):
|
||||
schema = tool.get_input_schema().schema()
|
||||
name = tool.get_name()
|
||||
|
Reference in New Issue
Block a user