카테고리 없음

langchain error 해결 - PydanticUserError: SQLDatabaseToolkit is not fully defined; you should define BaseCache, then call SQLDatabaseToolkit.model_rebuild()

parkjiu 2024. 12. 2. 11:05

 

DB(postgreSQL)에서 데이터를 읽어서 챗봇을 만들고자 했습니다. 아무래도 SQL 에이전트가 가장 빠르고 효율적인 방법같아서 sql agent 쓰려고 했는데 자꾸


PydanticUserError: SQLDatabaseToolkit is not fully defined; you should define BaseCache, then call SQLDatabaseToolkit.model_rebuild() 
이런 오류가 나는 것임니다... 코파일럿과 지피티 클로드 모두 해결하지 못하길래 일주일 반 정도 다른 일하다가 다시 왔더니 그 사이에 누가 문제를 해결해주셨다. 아래 링크 참고.

 

결론 : pydantic 의 버전을 2.9.2로 다운그레이드 해서 해결. 

https://github.com/langchain-ai/langchain/issues/28284

 

PydanticUserError: `SQLDatabaseToolkit` is not fully defined; you should define `BaseCache`, then call `SQLDatabaseToolkit.model

Checked other resources I added a very descriptive title to this issue. I searched the LangChain documentation with the integrated search. I used the GitHub search to find a similar question and di...

github.com

pip uninstall pydantic
pip install pydantic==2.9.2

위 명령어 실행하시면 댑니당 ㅎ

 

pydantic의 새로운 버전이 나왔는데, sql agent에 필요한 SQLDatabaseToolkit이 이 pydantic 모델이며, 새로운 버전과 충돌이 있어서 안되는 뭐 그런 거 가틈... 많은 이들의 빠른 해결을 바라며...