DSPy: The framework for programming—not prompting—language models
Python
Wrap langchain tool code example by asyncio runner (#8322)
Chen Qianeed2f8cec168
diff --git a/dspy/adapters/types/tool.py b/dspy/adapters/types/tool.pyindex 34385b26b..b17cabd61 100644--- a/dspy/adapters/types/tool.py+++ b/dspy/adapters/types/tool.py@@ -206,17 +206,23 @@ class Tool(BaseType):A Tool object.Example:+```python- from langchain.tools import tool+ import asyncioimport dspy+ from langchain.tools import tool as lc_tool- @tool+ @lc_tooldef 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))+ dspy_tool = dspy.Tool.from_langchain(add)++ async def run_tool():+ return await dspy_tool.acall(x=1, y=2)++ print(asyncio.run(run_tool()))# 3```"""