Skip to content

[WIP] Migrate from LangChain to LiteLLM (major upgrade) #1426

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

dlqqq
Copy link
Member

@dlqqq dlqqq commented Jul 23, 2025

Description

This PR contains all of the code changes required for the complete migration from LangChain to LiteLLM as the model library used by Jupyter AI, as proposed in #1418. We will iterate on this through smaller PRs targeting the litellm branch. These "sub-PRs" are listed below.

This PR will be merged into the main branch once the "issues remaining" (listed below) are addressed and the litellm branch is stable for general use. Until then, this PR will be marked as a draft.

Issues closed

Issues remaining

Sub-PRs merged

Summary of changes

  • LangChain providers (e.g. ChatOpenAI class) and provider dependencies (e.g. langchain-openai optional dependency) have been removed. The only optional dependency is boto3, which is required for using Bedrock models with LiteLLM.

  • Jupyter AI no longer spends 3000-4000ms loading providers from entry points on server startup. Around 1000 models from several providers are available for use without loading entry points or installing optional dependencies.

  • Model IDs now follow the LiteLLM syntax, <provider-name>/<model-name>.

  • The AI settings page has been rewritten to be more usable and reliable.

* add new /api/ai/models endpoint

* add litellm dependency

* add new model ID input component

* fix custom model ID input

* update ConfigManager to accept litellm model IDs

* update Jupyternaut to use litellm

* remove LangChain partner packages from dependencies

* remove LangChain provider entry points

* pre-commit

* rename /api/ai/models => /api/ai/models/chat

* simplify model settings UI
@dlqqq dlqqq added the enhancement New feature or request label Jul 23, 2025
@dlqqq dlqqq changed the title [WIP, MAJOR] Migrate from LangChain to LiteLLM (#1425) [WIP, MAJOR] Migrate from LangChain to LiteLLM Jul 23, 2025
@dlqqq dlqqq changed the title [WIP, MAJOR] Migrate from LangChain to LiteLLM [WIP] Migrate from LangChain to LiteLLM (major upgrade) Jul 23, 2025
* remove LangChain from jupyter_ai_magics

* remove unused useServerInfo() hook in frontend

* remove LangChain references from jupyter_ai

* remove langchain from test & cookiecutter packages

* move all completions code to jupyter_ai.completions

* remove LangChain provider code from ConfigManager

* minor fixes to allow JAI to start
Jonah Jung and others added 3 commits July 31, 2025 11:54
* add EnvSecretsManager and secrets REST API

* make ListSecrets endpoint more generic

* fix UpdateSecretsRequest type

* fix bug where last secret cannot be deleted

* remove error log used in dev

* add new <SecretsSection /> component

* tweak UI appearance

* make settings page scrollable, fix #1409

* show no static secrets by default

* show something when no secrets are present

* adjust language

* fix success & error alerts on updating secrets

* fix lint

* fix bug when .gitignore and .env do not exist

* bump to 2s poll interval in EnvSecretsManager

* disable model parameters input for now, fix merge conflicts
* Adding `magics` functionality to the `litellm` implementation

* updates for initializing aliases and resolving types, mypy

* Update magics.py

* init alias

* Update test_magics.py

* Update magics.py

* Changed `error` to `fix` in magics

* Update index.md

* Update test_magics.py

* Update magics.py

* streamlining magics

* removed update command

* initial_chat_model

* magics pre-commit

* Update magics.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment