Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when importing ChatOutputParser: no validator found for <class 're.Pattern'> #8158

Closed
2 of 14 tasks
SpaceDandy13 opened this issue Jul 24, 2023 · 9 comments
Closed
2 of 14 tasks
Labels
Ɑ: agent Related to agents module 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@SpaceDandy13
Copy link

System Info

from langchain.agents.chat.output_parser import ChatOutputParser
Traceback (most recent call last):
File "", line 1, in
File "/home/ubuntu/chatpdf/Backend/backenv/lib/python3.10/site-packages/langchain/init.py", line 6, in
from langchain.agents import MRKLChain, ReActChain, SelfAskWithSearchChain
File "/home/ubuntu/chatpdf/Backend/backenv/lib/python3.10/site-packages/langchain/agents/init.py", line 10, in
from langchain.agents.agent_toolkits import (
File "/home/ubuntu/chatpdf/Backend/backenv/lib/python3.10/site-packages/langchain/agents/agent_toolkits/init.py", line 6, in
from langchain.agents.agent_toolkits.csv.base import create_csv_agent
File "/home/ubuntu/chatpdf/Backend/backenv/lib/python3.10/site-packages/langchain/agents/agent_toolkits/csv/base.py", line 4, in
from langchain.agents.agent_toolkits.pandas.base import create_pandas_dataframe_agent
File "/home/ubuntu/chatpdf/Backend/backenv/lib/python3.10/site-packages/langchain/agents/agent_toolkits/pandas/base.py", line 18, in
from langchain.agents.types import AgentType
File "/home/ubuntu/chatpdf/Backend/backenv/lib/python3.10/site-packages/langchain/agents/types.py", line 5, in
from langchain.agents.chat.base import ChatAgent
File "/home/ubuntu/chatpdf/Backend/backenv/lib/python3.10/site-packages/langchain/agents/chat/base.py", line 6, in
from langchain.agents.chat.output_parser import ChatOutputParser
File "/home/ubuntu/chatpdf/Backend/backenv/lib/python3.10/site-packages/langchain/agents/chat/output_parser.py", line 12, in
class ChatOutputParser(AgentOutputParser):
File "pydantic/main.py", line 229, in pydantic.main.ModelMetaclass.new
File "pydantic/fields.py", line 491, in pydantic.fields.ModelField.infer
File "pydantic/fields.py", line 421, in pydantic.fields.ModelField.init
File "pydantic/fields.py", line 542, in pydantic.fields.ModelField.prepare
File "pydantic/fields.py", line 804, in pydantic.fields.ModelField.populate_validators
File "pydantic/validators.py", line 723, in find_validators
RuntimeError: no validator found for <class 're.Pattern'>, see arbitrary_types_allowed in Config

Who can help?

No response

Information

  • The official example notebooks/scripts
  • My own modified scripts

Related Components

  • LLMs/Chat Models
  • Embedding Models
  • Prompts / Prompt Templates / Prompt Selectors
  • Output Parsers
  • Document Loaders
  • Vector Stores / Retrievers
  • Memory
  • Agents / Agent Executors
  • Tools / Toolkits
  • Chains
  • Callbacks/Tracing
  • Async

Reproduction

from langchain.agents.chat.output_parser import ChatOutputParser

Expected behavior

Import corrrectly.

@jhnyc
Copy link

jhnyc commented Jul 24, 2023

@SpaceDandy13 How did you resolve the problem eventually? I keep getting this error.

@SpaceDandy13
Copy link
Author

@SpaceDandy13 How did you resolve the problem eventually? I keep getting this error.

I just use the old version.

@SpaceDandy13 SpaceDandy13 reopened this Jul 25, 2023
@divya-r-kamat
Copy link

@SpaceDandy13 which version did you use, please can you share the version number, even I am getting similar error. I have tried couple of older versions.

@Ezhvsalate
Copy link

Was getting same issue right now with v. 0.0.142
Was fixed for me by upgrading pydantic to 1.10.8

@gabriellopesdesouza2002
Copy link

Changing the version to pydantic==1.10.8 worked for me using a flask api in pythonanywhere

@azaiman1
Copy link

azaiman1 commented Sep 6, 2023

I am still getting this error even when installing pydantic 1.10.8 I was wondering if there is anything else I should do?

@MLuis-Model
Copy link

I had the exact same issue and was working with Jupyter Notebook.
It seems like Jupyter is causing this problem, as it works in Pycharm.
So I can recommend to switch IDE.

@gilfernandes
Copy link

After downgrading to 1.10.12 this error went away for me.

Using poetry:

[tool.poetry.dependencies]
...
pydantic = "1.10.12"
Package operations: 0 installs, 1 update, 0 removals

  • Downgrading pydantic (2.3.0 -> 1.10.12)

@dosubot dosubot bot added Ɑ: agent Related to agents module 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature labels Oct 2, 2023
Copy link

dosubot bot commented Feb 7, 2024

Hi, @SpaceDandy13,

I'm helping the LangChain team manage their backlog and am marking this issue as stale. From what I understand, the issue involves a runtime error when importing the ChatOutputParser module due to a missing validator for the re.Pattern class. It seems that the problem has been resolved by downgrading or upgrading the pydantic package to version 1.10.8. Additionally, switching IDEs or downgrading to pydantic version 1.10.12 has also resolved the issue for some users.

Could you please confirm if this issue is still relevant to the latest version of the LangChain repository? If it is, please let the LangChain team know by commenting on the issue. Otherwise, feel free to close the issue yourself, or the issue will be automatically closed in 7 days.

Thank you for your understanding and cooperation.

@dosubot dosubot bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Feb 7, 2024
@dosubot dosubot bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 14, 2024
@dosubot dosubot bot removed the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ɑ: agent Related to agents module 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature
Projects
None yet
Development

No branches or pull requests

8 participants