Dave Aitel
08/25/2024, 5:00 PM@classmethod
def from_lc_tool(cls, tool: langchain_core.tools.BaseTool, **kwargs):
if isinstance(tool, langchain_core.tools.StructuredTool):
fn = tool.func
else:
#fn = lambda *a, **k: None # noqa
# For non-StructuredTool, check for _run method first, then func
fn = getattr(tool, '_run', getattr(tool, 'func', lambda *a, **k: None))
return cls(
name=tool.name,
description=tool.description,
parameters=tool.args_schema.schema(),
fn=fn,
**kwargs,
)