pydantic compatibility guide fix (#9418)

pull/9419/head
Bagatur 1 year ago committed by GitHub
parent ce78877a87
commit 5d60ced7b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -99,6 +99,20 @@ Tool.from_function( # <-- tool uses v1 namespace
**NO**
```python
from langchain.tools.base import Tool
from pydantic import BaseModel, Field # <-- Uses v2 namespace
class CalculatorInput(BaseModel):
question: str = Field()
Tool.from_function( # <-- tool uses v1 namespace
func=lambda question: 'hello',
name="Calculator",
description="useful for when you need to answer questions about math",
args_schema=CalculatorInput
)
```
## After 2023-08-25 release

Loading…
Cancel
Save