|
|
@ -22,6 +22,7 @@ the case of inheritance and in the case of passing objects to LangChain.
|
|
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
```python
|
|
|
|
from pydantic.v1 import root_validator, validator
|
|
|
|
from pydantic.v1 import root_validator, validator
|
|
|
|
|
|
|
|
from langchain_core.tools import BaseTool
|
|
|
|
|
|
|
|
|
|
|
|
class CustomTool(BaseTool): # BaseTool is v1 code
|
|
|
|
class CustomTool(BaseTool): # BaseTool is v1 code
|
|
|
|
x: int = Field(default=1)
|
|
|
|
x: int = Field(default=1)
|
|
|
@ -48,6 +49,7 @@ Mixing Pydantic v2 primitives with Pydantic v1 primitives can raise cryptic erro
|
|
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
```python
|
|
|
|
from pydantic import Field, field_validator # pydantic v2
|
|
|
|
from pydantic import Field, field_validator # pydantic v2
|
|
|
|
|
|
|
|
from langchain_core.tools import BaseTool
|
|
|
|
|
|
|
|
|
|
|
|
class CustomTool(BaseTool): # BaseTool is v1 code
|
|
|
|
class CustomTool(BaseTool): # BaseTool is v1 code
|
|
|
|
x: int = Field(default=1)
|
|
|
|
x: int = Field(default=1)
|
|
|
@ -102,4 +104,4 @@ Tool.from_function( # <-- tool uses v1 namespace
|
|
|
|
description="useful for when you need to answer questions about math",
|
|
|
|
description="useful for when you need to answer questions about math",
|
|
|
|
args_schema=CalculatorInput
|
|
|
|
args_schema=CalculatorInput
|
|
|
|
)
|
|
|
|
)
|
|
|
|
```
|
|
|
|
```
|
|
|
|