minimaxir / simpleaichat

Python package for easily interfacing with chat apps, with robust features and minimal code complexity.
MIT License
3.49k stars 229 forks source link

Invalid keyword: 'options' in call to model_dump_json #68

Open LiamK opened 1 year ago

LiamK commented 1 year ago

In simpleaichat.py line 224, in the str() method, I was getting an error:

  File "/Users/liam/.virtualenvs/comedybot/lib/python3.10/site-packages/simpleaichat/simpleaichat.py", line 220, in __str__
    return self.default_session.model_dump_json(
TypeError: BaseModel.model_dump_json() got an unexpected keyword argument 'option'
def __str__(self) -> str: 
        if self.default_session:
            return self.default_session.model_dump_json(
                exclude={"api_key", "api_url"},
                exclude_none=True,
                option=orjson.OPT_INDENT_2,
            )

I couldn't find any version of Pydantic that had a 'option' keyword argument for the model_dump_json method. So, I replaced it with indent=2 and that works.