I am getting RuntimeError: no validator found for <class 'langchain_community.tools.json.tool.JsonSpec'>, see arbitrary_types_allowed in Config
even after to installing
import yaml
from langchain_community.agent_toolkits import JsonToolkit, create_json_agent
from langchain_community.tools.json.tool import JsonSpec
from langchain_openai import OpenAI
The error you're encountering due to incorrect Pydantic configuration.
LangChain uses Pydantic models for validation, and this error can occur when Pydantic does know to handle certain types, such as the JsonSpec
.
Pydantic's Config
class has an option called arbitrary_types_allowed
that needs to be set to True
in such cases.
SOLUTIONS
always work in a virtual environment. (recommended)
check install pydantic
and other modules related to langchain like langchain-community
or langchain-openai
. (recommended)
use the following code to set arbitrary_types_allowed
to True
from pydantic import BaseModel
class Maintain(BaseModel):
class Config:
arbitrary_types_allowed = True