mirror of
https://github.com/hwchase17/langchain.git
synced 2026-02-21 22:56:05 +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']}
```
LangChain Documentation
For more information on contributing to our documentation, see the Documentation Contributing Guide