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

support langchain>=0.3 and migrate to use pydantic v2 #1003

Open
michaelchia opened this issue Sep 18, 2024 · 7 comments
Open

support langchain>=0.3 and migrate to use pydantic v2 #1003

michaelchia opened this issue Sep 18, 2024 · 7 comments
Labels
enhancement New feature or request
Milestone

Comments

@michaelchia
Copy link
Collaborator

michaelchia commented Sep 18, 2024

Problem

Langchain 0.3 has been released since 16 Sep. https://python.langchain.com/docs/versions/v0_3/
This one might involve some migration to support. Changes are mainly regarding migrating stuff to pydantic v2.

Proposed Solution

Will need to move all the pydantic stuff away from langchain.pydantic_v1 and to use pydantic v2 from the base package.

@michaelchia michaelchia added the enhancement New feature or request label Sep 18, 2024
@dlqqq
Copy link
Member

dlqqq commented Sep 19, 2024

@michaelchia Hey Michael, thanks for opening an issue to track this. Our team discussed this issue today and would like to share our thoughts.

Right now, Pydantic v1 is still used in ~40% of all environments using Pydantic, and is still a required dependency for many other popular AI/ML packages, such as autogluon. Upgrading to LangChain v0.3 and dropping support for Pydantic v1 will cause Jupyter AI to be incompatible with these developer environments.

Given this, we are under the impression that upgrading to LangChain v0.3 will require a major version bump, i.e. a Jupyter AI v3.0.0 release. We don't have a formal timeline/roadmap for the v3.0.0 release yet, but our current goal is to have a pre-release available by the end of 2024. It would be best to open a PR for this only once development work on Jupyter AI v3.0.0 begins on main and Jupyter AI v2.x is tracked on a separate branch.

We're open to feedback on this, since we know that users are excited to use LangChain v0.3. However, given Pydantic v1 is still frequently installed in user environments, we think this should be done in a major release (which requires time & planning) instead of a minor one to ensure compatibility for existing users.

@michaelchia
Copy link
Collaborator Author

michaelchia commented Sep 20, 2024

That sounds reasonable.

For context on my situation, although I generally want to be able to support the latest versions of dependencies, currently this is not a blocker for me. However, this may be a blocker in the future. Unlikely because of a new feature in langchain itself but more so a critical feature in the langchain partner providers that we depend on. Hopefully this won't occur for awhile and the project will be ready for a prerelease version by then.

For complicated reasons out of my control, my users have to use the same dependencies as the one jupyterlab is running on, so I can't have the users running a different kernel/venv with their own langchain version.

@BwL1289
Copy link

BwL1289 commented Sep 23, 2024

Everything discussed here makes sense. That said, this is currently a blocker for me as we have a hard dependency on Pydantic v2 elsewhere.

@samuelcolvin
Copy link

I'd love to see this package upgrade to pydantic v2. If we can help at all, let us know.

I don't think 40% of downloads means 40% of AI/ML use cases - I suspect among AI use cases, many of which are newer codebases, the use of v1 is much lower.

Also it's more like 30% now.

and is still a required dependency for many other popular AI/ML packages

Apart from autogluon, can you say which packages? I'm genuinely curious.

@dlqqq dlqqq added this to the v3.0.0 milestone Oct 23, 2024
@dlqqq
Copy link
Member

dlqqq commented Oct 23, 2024

@samuelcolvin Thank you very much for offering to help! This will require a major release of Jupyter AI, for which we are tracking progress here: #1052. We'll reach out if we run into any issues in the process. 🤗

Apart from autogluon, can you say which packages? I'm genuinely curious.

That's the only one I can name from memory. Probably why the v1 download share has dropped from 40% to 30%. 😁

@dlqqq
Copy link
Member

dlqqq commented Oct 23, 2024

@BwL1289

That said, this is currently a blocker for me as we have a hard dependency on Pydantic v2 elsewhere.

Jupyter AI should work in your environment if it has a hard dependency on Pydantic v2, but only if langchain<0.3 is acceptable in your environment. Jupyter AI uses the Pydantic v1 API regardless of whether Pydantic v1 or v2 by importing pydantic from langchain.pydantic_v1, which means Jupyter AI can be installed regardless of whether Pydantic v1 or v2 are installed. However, this module is dropped in langchain>=0.3, which motivates the issue described here.

If you're not using langchain>=0.3, you should still be able to install jupyter_ai~=2.0. Have you explored this option? 👀

@BwL1289
Copy link

BwL1289 commented Oct 23, 2024

@dlqqq yep unfortunately that's also a hard dependency. In the meantime, will be tracking #1052.

Anyway - thanks for the suggestion!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants