mirror of
https://github.com/hwchase17/langchain
synced 2024-11-18 09:25:54 +00:00
pydantic compatibility guide fix (#9418)
This commit is contained in:
parent
ce78877a87
commit
5d60ced7b3
@ -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…
Reference in New Issue
Block a user