s3rius / FastAPI-template

Feature rich robust FastAPI template.
MIT License
1.79k stars 161 forks source link

How to swap out Pydantic-settings #182

Closed aitoehigie closed 11 months ago

aitoehigie commented 11 months ago

I am trying to use this template to create a FastAPI + Langchain project, however, Langchain only supports Pydantic < v2 while Pydantic-settings which is tightly coupled with Pydantic + FastAPI depends on Pydantic v2.0+.

Any tips on how to swap it out?

s3rius commented 11 months ago

There's no way to swap pydantic version from cli, but this option exists.

Just clone the repo, add this line context.pydanticv1 = True here https://github.com/s3rius/FastAPI-template/blob/master/fastapi_template/__main__.py#L20, right before the actual generation.

I'll make an option later. Actually, you can make a PR that adds this option, I'd really appreciate this.

aitoehigie commented 11 months ago

@s3rius PR opened: https://github.com/s3rius/FastAPI-template/pull/184