From 7a0b36501f805d9a5a087df894c5c30dd89c9131 Mon Sep 17 00:00:00 2001 From: Bella Be Date: Tue, 18 Jun 2024 05:49:56 +0400 Subject: [PATCH] docs: Update how to docs for pydantic compatibility (#22983) Add missing imports in docs from langchain_core.tools BaseTool --------- Co-authored-by: Eugene Yurtsev --- docs/docs/how_to/pydantic_compatibility.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/docs/how_to/pydantic_compatibility.md b/docs/docs/how_to/pydantic_compatibility.md index 7a3f3fe220..50d64f4247 100644 --- a/docs/docs/how_to/pydantic_compatibility.md +++ b/docs/docs/how_to/pydantic_compatibility.md @@ -22,6 +22,7 @@ the case of inheritance and in the case of passing objects to LangChain. ```python from pydantic.v1 import root_validator, validator +from langchain_core.tools import BaseTool class CustomTool(BaseTool): # BaseTool is v1 code x: int = Field(default=1) @@ -48,6 +49,7 @@ Mixing Pydantic v2 primitives with Pydantic v1 primitives can raise cryptic erro ```python from pydantic import Field, field_validator # pydantic v2 +from langchain_core.tools import BaseTool class CustomTool(BaseTool): # BaseTool is v1 code 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", args_schema=CalculatorInput ) -``` \ No newline at end of file +```