Pydantic compatibility: No Breaking Changes #9337
Replies: 8 comments 6 replies
-
Am I correct in understanding that to stay up to date, all our application code must be upgraded to pydantic 2 within 1.5 weeks? I understand langchain is 0.0.x, but that seems a bit much, yeah? Is there a plan for locking in versioning a bit more after this? |
Beta Was this translation helpful? Give feedback.
-
this is a pretty crazy timetable for migrations to pydantic v2. this is coming from someone who put together the original migration of langchain to v2 a while back here - #8330 theres still several downstream deps that aren't upgraded to v2 and won't allow upgrades to occur. What should be happening here is a step between 1 and 2 where while pydantic is unlocked to allow upgrades to v2 but isn't running v2, downstream dependancies that are blocking the full migration to v2 are identified and patches pushed where necessary. As noted on my PR above, there are still several repos that need these support patches. ChromaDB being the most awful as they had similar downstream upgrades required. Only once this new step completes should the timer to force upgrades to v2 be started. |
Beta Was this translation helpful? Give feedback.
-
Just and additional data point, haystack is not upgrading to pydantic 2 until they do a full major version change deepset-ai/haystack#5304. Guessing that this is gonna be a mess for people. |
Beta Was this translation helpful? Give feedback.
-
Please note the updated discussion text: [UPDATE 08/20/23] As of 0.0.267 LangChain does not pin to pydantic v1 or v2, and users should be able to install and use either. Compatibility with pydantic v1 and v2 will be maintained until at least the end of 2023. We have delayed all immediate plans to migrate to pydantic v2, and will provide further updates if/when we have them. We've heard from a number of users and partners that due to other dependencies they are unable to migrate their own projects to pydantic v2 at the moment. We deeply appreciate the feedback, and will continue to do our best to support projects on both pydantic v1 and v2. |
Beta Was this translation helpful? Give feedback.
-
Hey community,
|
Beta Was this translation helpful? Give feedback.
-
I am migrating my project to use Any help how to overcome this is more than appreciated. |
Beta Was this translation helpful? Give feedback.
-
Will langchain ever be upgraded to use pydantic v2? Given langchain only works with pydantic 1. There is currently no way we can progressively migrate our code which depending on langchain from pydantic v1 to v2. So there won't be too much change no matter how long we wait. If we do want to migrate to pydantic v2, we may need an active timeline. |
Beta Was this translation helpful? Give feedback.
-
FWIW, I'm trying to share models I wrote for FastAPI endpoints in LangChain tools, but FastAPI requires Pydantic v2 and LangChain requires using Pydantic v1 (or pydantic.v1). It's been 10 months since the original planned date for upgrading LangChain to Pydantic v2 internally. Any movement or updates on when this migration, originally planned for 2023-08-25, will happen? From what I can tell, there's two issues here:
|
Beta Was this translation helpful? Give feedback.
-
[UPDATE 08/20/23]
As of
0.0.267
LangChain does not pin to pydantic v1 or v2, and users should be able to install and use either. Compatibility with pydantic v1 and v2 will be maintained until at least the end of 2023. We have delayed all immediate plans to migrate to pydantic v2, and will provide further updates if/when we have them.We've heard from a number of users and partners that due to other dependencies they are unable to migrate their own projects to pydantic v2 at the moment. We deeply appreciate the feedback, and will continue to do our best to support projects on both pydantic v1 and v2.
[ORIGINAL POST]
LangChain Pydantic Migration Plan
Langchain will carry out the migration to pydantic v2 in two steps:
migration using pydantic v2 throughout their code, but avoiding mixing v1 and v2 code for LangChain (see below).
pydantic.v1
namespace interacting with LangChain.pydantic.v1
namespace! (see link below)Migration Plan Suggested for Users
If your code base is large, or you are responsible for bumping many libraries at once, consider migrating in 2 steps:
pydantic>=2
Between 2023-08-17 and 2023-08-25 releases
User can either pin to pydantic v1, and upgrade their code in one go once LangChain has migrated to v2 internally, or they can start a partial migration to v2, but must avoid mixing v1 and v2 code for LangChain.
Below are two examples of showing how to avoid mixing pydantic v1 and v2 code in
the case of inheritance and in the case of passing objects to LangChain.
Example 1: Extending via inheritance
YES
Mixing Pydantic v2 primitives with Pydantic v1 primitives can raise cryptic errors
NO
Example 2: Passing objects to LangChain
YES
NO
After 2023-08-25 release
pydantic.v1
derived objects to LangChain or rely onpydantic.v1
when extending functionalityBeta Was this translation helpful? Give feedback.
All reactions