From 5d60ced7b39733afc43e2aa2b72279082ac996c0 Mon Sep 17 00:00:00 2001 From: Bagatur <22008038+baskaryan@users.noreply.github.com> Date: Thu, 17 Aug 2023 12:33:20 -0700 Subject: [PATCH] pydantic compatibility guide fix (#9418) --- docs/extras/guides/pydantic_compatibility.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/extras/guides/pydantic_compatibility.md b/docs/extras/guides/pydantic_compatibility.md index a54c9fbfa9..15518c5e23 100644 --- a/docs/extras/guides/pydantic_compatibility.md +++ b/docs/extras/guides/pydantic_compatibility.md @@ -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