Skip to content

Commit acd06bf

Browse files
authored
add example for Tool.from_langchain (#8311)
1 parent 843806d commit acd06bf

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

dspy/adapters/types/tool.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,21 @@ def from_langchain(cls, tool: "BaseTool") -> "Tool":
204204
205205
Returns:
206206
A Tool object.
207+
208+
Example:
209+
```python
210+
from langchain.tools import tool
211+
import dspy
212+
213+
@tool
214+
def add(x: int, y: int):
215+
"Add two numbers together."
216+
return x + y
217+
218+
tool = dspy.Tool.from_langchain(add)
219+
print(await tool.acall(x=1, y=2))
220+
# 3
221+
```
207222
"""
208223
from dspy.utils.langchain_tool import convert_langchain_tool
209224

0 commit comments

Comments
 (0)