We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ad2b455 commit a0ef300Copy full SHA for a0ef300
src/controlflow/tools/tools.py
@@ -51,10 +51,17 @@ class Tool(ControlFlowModel):
51
metadata: dict = {}
52
53
fn: Callable = Field(None, exclude=True)
54
+ _lc_tool: Optional[langchain_core.tools.BaseTool] = None
55
56
def to_lc_tool(self) -> dict:
- payload = self.model_dump(include={"name", "description", "parameters"})
57
- return dict(type="function", function=payload)
+ if self._lc_tool is None:
58
+ self._lc_tool = langchain_core.tools.StructuredTool.from_function(
59
+ self.fn,
60
+ name=self.name,
61
+ description=self.description,
62
+ )
63
+
64
+ return self._lc_tool
65
66
@prefect_task(task_run_name="Tool call: {self.name}")
67
def run(self, input: dict):
0 commit comments