DSPy: The framework for programming—not prompting—language models
Python
add example for Tool.from_langchain (#8311)
TomuHirataacd06bf4d067
diff --git a/dspy/adapters/types/tool.py b/dspy/adapters/types/tool.pyindex 07b980515..34385b26b 100644--- a/dspy/adapters/types/tool.py+++ b/dspy/adapters/types/tool.py@@ -204,6 +204,21 @@ class Tool(BaseType):Returns:A Tool object.++ Example:+ ```python+ from langchain.tools import tool+ import dspy++ @tool+ def add(x: int, y: int):+ "Add two numbers together."+ return x + y++ tool = dspy.Tool.from_langchain(add)+ print(await tool.acall(x=1, y=2))+ # 3+ ```"""from dspy.utils.langchain_tool import convert_langchain_tool