pydantic compatibility guide fix (#9418)

This commit is contained in:
Bagatur 2023-08-17 12:33:20 -07:00 committed by GitHub
parent ce78877a87
commit 5d60ced7b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -99,6 +99,20 @@ Tool.from_function( # <-- tool uses v1 namespace
**NO** **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 ## After 2023-08-25 release