benman1 / generative_ai_with_langchain

Build large language model (LLM) apps with Python, ChatGPT and other models. This is the companion repository for the book on generative AI with LangChain.
https://amzn.to/43PuIkQ
MIT License
552 stars 219 forks source link

Pydantic format error #30

Closed CSalle closed 4 months ago

CSalle commented 4 months ago

Hi,

While trying to run the Openresume CV example, I am getting the following error:

"RuntimeError: no validator found for <class 'main.Resume'>, see arbitrary_types_allowed in Config"

I managed to perform a small hack by enabling arbitrary types as a decorator on top of each class (@pydantic.dataclasses.dataclass(config=Config), where Config is a class that sets arbitrary_types_allowed = True). However this seems to run into parsing errors where the data type is not correct.

Any ideas? Thanks in advance!

benman1 commented 4 months ago

Hi, @CSalle! That's interesting. I've just run the example and, for me, it ran fine. I did a quick search and it seems that this is pydantic's way of saying the input doesn't conform.

Maybe the model doesn't give the expected output? Are you using a different model?

    llm = ChatOpenAI(model_name="gpt-3.5-turbo")

This is the model in the code. Is this what you are using? Have you tried other models?

CSalle commented 4 months ago

Hi Ben,

Thanks for getting back. After some hours of trying stuff, downgrading the version of Pydantic to 1.10 did the trick. I was using Pydantic 2 and it seems this runs into some issues.

After that, I didn't even need the arbitrary_types_allowed trick.

Thanks a lot, I'll close the issue :)

benman1 commented 4 months ago

Good to hear, @CSalle! Thanks for updating. FYI - my version of pydantic is 1.10.13.