Skip to content

Allow embedding model fields, fix coupled model fields, add custom OpenAI provider #1264

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

Merged
merged 39 commits into from
Mar 20, 2025

Conversation

srdas
Copy link
Collaborator

@srdas srdas commented Feb 27, 2025

Description

The OpenAI model interface has been widely adopted by many model providers (DeepSeek, vLLM, etc.) and this PR enables accessing these models using the OpenAI provider. Current OpenAI models are also accessible via the same interface.

This PR also updates related documentation on the use of these models that work via the OpenAI provider.

These updates work for selecting chat and embeddings models. Chat models are tested to work with models from OpenAI, DeepSeek, and models hosted by vLLM. Embedding models are tested for OpenAI models. DeepSeek does not have an API for embedding models, and OpenRouter also does not support as yet any embedding models.

Also, this PR corrects the coupled fields problem in the AI Settings page.

Finally, added the embedding fields to the config_scheme.json and made related changes to config_manager.py and test_ config_manager.py

Each of these changes is now described below in some more detail.

Demo of new features

See the new usage of models and the required settings shown below, note the new "OpenAI::general interface":
image

For any OpenAI model:
openai-chat-openai

For DeepSeek models:
openai-chat-deepseek

For models deployed with vLLM:
openai-chat-vllm

Embedding Models

First, tested to make sure that the OpenAI models are working as intended with no changes to the code:
image

Second, modified check that the interface takes any OpenAI embedding model as an input and test that it works with OpenAI models as before:

image

Fixed coupled model field inputs

We can see that the fields are not coupled any more as shown below:
image

Added embeddings_fields to config_schema.json

  • Updated config_manager.py to handle the new fields.
  • Also updated analogous code for continuation models.
  • Updated test_config_manager.py for the additional embedding field in config.

@srdas srdas added the enhancement New feature or request label Feb 27, 2025
@srdas srdas changed the title Create a custom OpenAI provider to use multiple model providers Create a custom OpenAI provider to use multiple models Feb 27, 2025
@srdas srdas marked this pull request as ready for review February 27, 2025 19:57
@dlqqq dlqqq linked an issue Feb 27, 2025 that may be closed by this pull request
@srdas srdas force-pushed the openai_generic_2 branch from 1ba53fd to f59026b Compare March 5, 2025 06:20
@srdas srdas requested a review from dlqqq March 5, 2025 15:38
@srdas srdas changed the title Create a custom OpenAI provider to use multiple models Create a custom OpenAI provider to use multiple models, resolve coupled input fields, add Embedding Fields to config Mar 10, 2025
Copy link
Member

@dlqqq dlqqq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@srdas Thank you for working on this! This is definitely one of the most challenging tasks that you've taken on thus far. Left some feedback for you below.

I think it would be best to hold off on merging this PR until after the v2.30.0 release scheduled for tomorrow. The ConfigManager areas of the code are fragile, and making lots of changes there introduces risk to users. I recommend that we ship this later to give us more time to thoroughly test these changes and mitigate that risk.

@eugenecherepanov
Copy link

do you have any plan for merge this feature?

@srdas
Copy link
Collaborator Author

srdas commented Mar 17, 2025

do you have any plan for merge this feature?

@eugenecherepanov I have a couple of things still not working that need to be cleared before this can be fully tested and reviewed, hoping to get it done very soon.

@srdas srdas requested review from dlqqq and keerthi-swarna March 17, 2025 23:50
Copy link
Member

@dlqqq dlqqq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@srdas The code now looks much cleaner, thank you for contributing this! Verified the changes locally.

Note that there is a bug where if you have unsaved chat model fields, the fields get reset if you change either the embedding or language model. This is an existing bug however, so this can be addressed separately in the future.

I left 2 additional comments below for you to address, but I will approve this now since those comments are minor.

Comment on lines 28 to 32
"*",
# "nomic-embed-text",
# "mxbai-embed-large",
# "all-minilm",
# "snowflake-arctic-embed",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with requiring Ollama embedding model users to set the model IDs manually, since we are doing that for the Ollama chat model anyways.

However, can you remove the comments and add a help attribute to show a help message?

Comment on lines 464 to 465
// .filter(em => em !== '*') // TODO: support registry providers
// .filter(em => emp.embedding_models.includes(em))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also remove this comment?

@dlqqq dlqqq changed the title Create a custom OpenAI provider to use multiple models, resolve coupled input fields, add Embedding Fields to config Add embedding models, fix coupled model inputs, add custom OpenAI provider Mar 19, 2025
@dlqqq dlqqq added the bug Bugs reported by users label Mar 19, 2025
@dlqqq dlqqq changed the title Add embedding models, fix coupled model inputs, add custom OpenAI provider Allow embedding model fields, fix coupled model fields, add custom OpenAI provider Mar 19, 2025
@srdas srdas merged commit d4dcef9 into jupyterlab:main Mar 20, 2025
9 checks passed
@srdas
Copy link
Collaborator Author

srdas commented Mar 20, 2025

@meeseeksdev please backport to 2.x

meeseeksmachine pushed a commit to meeseeksmachine/jupyter-ai that referenced this pull request Mar 20, 2025
srdas added a commit that referenced this pull request Mar 20, 2025
…upled model fields, add custom OpenAI provider) (#1282)

* Backport PR #1264: Allow embedding model fields, fix coupled model fields, add custom OpenAI provider

* Fix CI

---------

Co-authored-by: Sanjiv Das <[email protected]>
keerthi-swarna pushed a commit to keerthi-swarna/jupyter-ai that referenced this pull request Apr 3, 2025
…ds, fix coupled model fields, add custom OpenAI provider) (jupyterlab#1282)

* Backport PR jupyterlab#1264: Allow embedding model fields, fix coupled model fields, add custom OpenAI provider

* Fix CI

---------

Co-authored-by: Sanjiv Das <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs reported by users enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Model field inputs are coupled in Settings UI Add support for embedding models served through an OpenAI API
4 participants