Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for use of Pydantic v1 as well as v2. #147

Merged
merged 7 commits into from
Aug 20, 2023

Conversation

cmungall
Copy link
Contributor

@cmungall cmungall commented Aug 4, 2023

Use v1-style configuration. While this is officially
deprecated (https://docs.pydantic.dev/latest/usage/model_config/),
it is supported by v2. I would assume this support will remain
for a while, this will help ease the transition to v2.

Background: llm may be used in combination with other libraries that may directly or indirectly depend on pydantic v1, this PR is designed to give groups the ability to combine llm with their other libraries and have some breathing space to transition

Use v1-style configuration. While this is officially
deprecated (https://docs.pydantic.dev/latest/usage/model_config/),
it is supported by v2. I would assume this support will remain
for a while, this will help ease the transition to v2
@cmungall
Copy link
Contributor Author

cmungall commented Aug 8, 2023

@simonw any chance you could take a look at this? The rest of the ecosystem has yet to move over to pydantic v2, e.g. chromadb is pinning to <2, which means that currently chromadb and llm can't be used together...

@simonw
Copy link
Owner

simonw commented Aug 12, 2023

I've been bitten by this issue myself - https://github.com/simonw/llm-replicate almost couldn't use the official Replicate client library because it depended on Pydantic v1. I submitted a PR to help with that:

Then the llm-claude plugin had a similar issue:

I think you're right: this needs to be fixed in LLM itself.

I want llm to be a useful dependency for other projects in its Python library form - but lots of other things remain on Pydantic 1.

Having it depend on just pydantic and work with both 1 and 2 would be ideal, at least for the next few months while the world upgrades to v2.

@simonw
Copy link
Owner

simonw commented Aug 12, 2023

One catch: LLM plugins will have to learn to not depend on Pydantic v1 v.s. v2 either. I'll need to document that in the plugin documentation I think.

Also I should set up CI tests that exercise both versions of Pydantic to make sure one of them doesn't accidentally break in the future.

@cmungall
Copy link
Contributor Author

Thanks!

I love pydantic, but version 2 is causing a lot of churn in my ecosystem right now.

@tomviner
Copy link

Does look like supporting both is the best approach right now, during this crossover period. Libraries who've upgraded get asked for v1 compat (this PR), and those still on v1 get asked for v2 compat (anthropics/anthropic-sdk-python#115).

Where's the six of pydantic?

@tomviner
Copy link

Anthropic went cross compatible in anthropics/anthropic-sdk-python#121 So I was able to unvendor them in the latest llm-claude release.

@simonw simonw added this to the 0.8 milestone Aug 20, 2023
@simonw simonw merged commit 740a8e8 into simonw:main Aug 20, 2023
5 checks passed
simonw added a commit that referenced this pull request Aug 20, 2023
simonw added a commit that referenced this pull request Aug 21, 2023
@cmungall cmungall mentioned this pull request Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants