jupyterlab / jupyter-ai

A generative AI extension for JupyterLab
https://jupyter-ai.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
3.14k stars 311 forks source link

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

Open michaelchia opened 5 days ago

michaelchia commented 5 days ago

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.

dlqqq commented 4 days ago

@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 commented 3 days ago

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 commented 8 hours ago

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