Replies: 5 comments 2 replies
-
I found a similar unsolved discussion that might be relevant to your issue: langchain agent to use tool but tool return ValidationError [1]. To resolve the "subclass of BaseModel expected" validation error when building a simple Langgraph with the PythonREPL Tool in LangChain, ensure that the For Pydantic v1: from pydantic.v1 import BaseModel
from langchain_core.tools.base import BaseTool
class PythonInputs(BaseModel):
query: str = Field(description="code snippet to run")
repl = PythonAstREPLTool(
locals={"df": df},
name="python_repl",
description="Runs code and returns the output of the final line",
args_schema=PythonInputs,
) For Pydantic v2: from pydantic import BaseModel
from langchain_core.tools.base import BaseTool
class PythonInputs(BaseModel):
query: str = Field(description="code snippet to run")
repl = PythonAstREPLTool(
locals={"df": df},
name="python_repl",
description="Runs code and returns the output of the final line",
args_schema=PythonInputs,
) In these examples, |
Beta Was this translation helpful? Give feedback.
-
@dosu No luck...seems like I need to define the function and call that as a tool instead of directly calling ' |
Beta Was this translation helpful? Give feedback.
-
how are you importing BaseModel? from |
Beta Was this translation helpful? Give feedback.
-
@hwchase17 I am using langchain_core.pydantic_v1, but I am open to using any base model. My objective is to achieve the same functionality in LangGraph, starting with simple steps such as reading a DataFrame into LangGraph, executing Python REPL functions, and building the graph. I see great potential in using pandas within the graph. Please help and give some sample code to explore. |
Beta Was this translation helpful? Give feedback.
-
@eyurtsev Please take a look
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Description
While I am running above code, I am getting error:
System Info
Name: pydantic
Version: 2.5.3
Name: langchain
Version: 0.2.16
Beta Was this translation helpful? Give feedback.
All reactions