Skip to content

Add default_completions_model trait #1303

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 2 commits into from
Apr 3, 2025
Merged

Conversation

srdas
Copy link
Collaborator

@srdas srdas commented Apr 2, 2025

Description

Users can specify a pre-specified configuration file titled jupyter_jupyter_ai_config.json in any of the paths shown when running jupyter --paths (see the documentation here). A sample of this file is shown below:

{
  "AiExtension": {
    "default_language_model": "openrouter:microsoft/phi-4",
    "default_embeddings_model": "openai-custom:BAAI/bge-m3",
    "default_completions_model": "ollama:llama3.2",
    "default_api_keys": {
      "OPENROUTER_API_KEY": "sk-XXXX",
      "OPENAI_API_KEY": "sk-YYYY"
    },
    "model_parameters": {
      "openrouter:microsoft/phi-4": {
        "openai_api_base": "https://chat.example.com"
      },
      "openai-custom:BAAI/bge-m3": {
        "openai_api_base": "https://chat.example.com"
      },
      "ollama:llama3.2": {
        "base_url": "http://localhost:11434"
      }
    }
  }
}

Issue: Currently, the default_completions_model is not being updated in config.json as this is not handled. This PR enables completions models config in a manner consistent with that done for language models and embedding models.

For reviewers

To test this:

  1. Create a new file titled jupyter_jupyter_ai_config.json in the path ~/.jupyter/ (or any other path seen from running jupyter --paths). Edit in the content of the file above.
  2. Delete the config.json file at path ~/Library/Jupyter/jupyter-ai/
  3. Start jupyter lab from the CLI
  4. Look at the config.json file to make sure it is also correctly showing the completions_model_provider_id and the completions_fields with the required content from the pre-specified config file.
  5. Open the AI setting pane to see all the fields are automatically populated with the content from the file jupyter_jupyter_ai_config.json

@dlqqq dlqqq changed the title Updating inline completions config fields from prespecified custom configuration file Add default_completions_model trait Apr 2, 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 building this! Changes look good. Verified with local testing. Feel free to merge & backport!

@srdas srdas merged commit a82eecc into jupyterlab:main Apr 3, 2025
11 checks passed
@srdas
Copy link
Collaborator Author

srdas commented Apr 3, 2025

@meeseeksdev please backport to 2.x

Copy link

lumberbot-app bot commented Apr 3, 2025

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout 2.x
git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -x -m1 a82eecc220a032b9bfbef9beb3da900a8bfd4e59
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #1303: Add `default_completions_model` trait'
  1. Push to a named branch:
git push YOURFORK 2.x:auto-backport-of-pr-1303-on-2.x
  1. Create a PR against branch 2.x, I would have named this PR:

"Backport PR #1303 on branch 2.x (Add default_completions_model trait)"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove the Still Needs Manual Backport label once the PR gets merged.

If these instructions are inaccurate, feel free to suggest an improvement.

srdas added a commit to srdas/jupyter-ai that referenced this pull request Apr 3, 2025
* Updating inline completions config fields from prespecified custom config file

* Update extension.py

(cherry picked from commit a82eecc)
srdas added a commit that referenced this pull request Apr 3, 2025
…t) (#1306)

* Update learn.py

* Add `default_completions_model` trait (#1303)

* Updating inline completions config fields from prespecified custom config file

* Update extension.py

(cherry picked from commit a82eecc)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update extension.py

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inline completion model provider should be traitlet-configurable
2 participants