2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【解決】LangChainのChatOpenAI()関数でPydanticのエラーが出るようになった

Posted at

現象

Google ColaboratoryでLangChainを用いたエージェントの開発をしていたところ、先月後半くらいから下記のエラーが出るようになった。

エラーが出る記述:

model = ChatOpenAI(model="gpt-4o-mini", temperature=0)

エラー内容:

pydantic.errors.PydanticUserError: `ChatOpenAI` is not fully defined; you should define `BaseCache`, then call `ChatOpenAI.model_rebuild()`.

解決方法

Pydantic 2.11のアップデートに起因する不具合を疑い、これを古いバージョンに入れ直したところエラーが出なくなった。

!pip uninstall pydantic
!pip install pydantic==2.10.6
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?