mirror of
https://github.com/hwchase17/langchain.git
synced 2025-05-28 10:39:23 +00:00
Note: this allows the schema to be passed in positionally. ```python from langchain_core.pydantic_v1 import BaseModel, Field from langchain_core.runnables import RunnableLambda class Add(BaseModel): """Add two integers together.""" a: int = Field(..., description="First integer") b: int = Field(..., description="Second integer") def add(input: dict) -> int: return input["a"] + input["b"] runnable = RunnableLambda(add) as_tool = runnable.as_tool(Add) as_tool.args_schema.schema() ``` ``` {'title': 'Add', 'description': 'Add two integers together.', 'type': 'object', 'properties': {'a': {'title': 'A', 'description': 'First integer', 'type': 'integer'}, 'b': {'title': 'B', 'description': 'Second integer', 'type': 'integer'}}, 'required': ['a', 'b']} ``` |
||
---|---|---|
.. | ||
__init__.py | ||
base.py | ||
branch.py | ||
config.py | ||
configurable.py | ||
fallbacks.py | ||
graph_ascii.py | ||
graph_mermaid.py | ||
graph_png.py | ||
graph.py | ||
history.py | ||
learnable.py | ||
passthrough.py | ||
retry.py | ||
router.py | ||
schema.py | ||
utils.py |