Skip to content

Add the ability to customize available models for OpenAI-compatible services - #13276

Merged
rtfeldman merged 6 commits into
zed-industries:mainfrom
amtoaer:improve_openai_compatible
Jun 25, 2024
Merged

rtfeldman merged 6 commits into
zed-industries:mainfrom
amtoaer:improve_openai_compatible

Conversation

@amtoaer

@amtoaer amtoaer commented Jun 19, 2024 •

Copy link
Copy Markdown
Contributor

Closes #11984, closes #11075.

Release Notes:

  • Added the ability to customize available models for OpenAI-compatible services (#11984) (#11075).

image

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jun 19, 2024
@christ-offer

Copy link
Copy Markdown

Very nice! :D

image

@amtoaer amtoaer changed the title Improve OpenAI-compatible services Add the ability to custom available models for OpenAI-compatible services Jun 22, 2024
@amtoaer amtoaer changed the title Add the ability to custom available models for OpenAI-compatible services Add the ability to customize available models for OpenAI-compatible services Jun 22, 2024
Comment thread crates/open_ai/src/open_ai.rs Outdated
Comment thread crates/assistant/src/completion_provider.rs Outdated
Comment thread crates/assistant/src/assistant_settings.rs Outdated

@rtfeldman rtfeldman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the contribution - this is looking good overall! 😃

I have one requested design change, and then some questions about code structure.

@amtoaer

amtoaer commented Jun 25, 2024

Copy link
Copy Markdown
Contributor Author

Thank you. I've updated it. Please let me know if there are any other issues.

@rtfeldman rtfeldman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice, thank you @amtoaer! 🎉

@sa1

sa1 commented Jul 4, 2024

Copy link
Copy Markdown

Some central documentation for new features would be nice.

rtfeldman added a commit that referenced this pull request Jul 19, 2024
We will soon need `semantic_index` to be able to use
`CompletionProvider`. This is currently impossible due to a cyclic crate
dependency, because `CompletionProvider` lives in the `assistant` crate,
which depends on `semantic_index`.

This PR breaks the dependency cycle by extracting two crates out of
`assistant`: `language_model` and `completion`.

Only one piece of logic changed: [this
code](922fcaf#diff-3857b3707687a4d585f1200eec4c34a7a079eae8d303b4ce5b4fce46234ace9fR61-R69).
* As of #13276, whenever we
ask a given completion provider for its available models, OpenAI
providers would go and ask the global assistant settings whether the
user had configured an `available_models` setting, and if so, return
that.
* This PR changes it so that instead of eagerly asking the assistant
settings for this info (the new crate must not depend on `assistant`, or
else the dependency cycle would be back), OpenAI completion providers
now store the user-configured settings as part of their struct, and
whenever the settings change, we update the provider.

In theory, this change should not change user-visible behavior...but
since it's the only change in this large PR that's more than just moving
code around, I'm mentioning it here in case there's an unexpected
regression in practice! (cc @amtoaer in case you'd like to try out this
branch and verify that the feature is still working the way you expect.)

Release Notes:

- N/A

---------

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
@sahadev0079

This comment was marked as duplicate.

@pramjana

pramjana commented Oct 6, 2024 •

Copy link
Copy Markdown

The GIF in this thread changes the displayed image too fast, making it hard to follow. Also, the longer image above is missing some information. Zed Docs mentions "language models" as the key, and so does gliptic in 16576.

It's confusing!

Please can someone provide a simple, correct method to set up OpenRouter models in Zed (one model example is enough, thank you!).

@notpeter

notpeter commented Oct 6, 2024 •

Copy link
Copy Markdown
Contributor

Please can someone provide a simple, correct method to set up OpenRouter models in Zed (one model example is enough, thank you!).

I believe they are using OpenAI API compatibility, so based on the Asssistant Configuration: OpenAI docs:

  "language_models": {
    "openai": {
      "api_url": "https://api.deepseek.com/v1",
      "available_models": [
        {
          "provider": "openai",
          "name": "deepseek_chat",
          "max_tokens": 32000
        },
        {
          "provider": "openai",
          "name": "deepseek_code",
          "max_tokens": 32000
        }
      ]
    }
  }

Untested, but you will need to enter your API key under the OpenAI section (press enter to confirm) of the Assistant configuration ("assistant: show configuration" from the command palette).

@pramjana

pramjana commented Oct 7, 2024

Copy link
Copy Markdown

Thank you for sharing @notpeter! I got the following working in Zed for the openrouter based api.

{
  "assistant": {
    "enabled": true,
    "default_model": {
      "provider": "openai",
      "model": "qwen/qwen-2.5-72b-instruct"
    },
    "version": "2"
  },
  "language_models": {
    "openai": {
      "version": "1",
      "api_url": "https://openrouter.ai/api/v1",
      "available_models": [
        {
          "name": "qwen/qwen-2.5-72b-instruct",
          "display_name": null,
          "max_tokens": 32000,
          "max_output_tokens": 8192,
          "max_completion_tokens": null
        }
      ]
    }
  },
}

jasonsmithio pushed a commit to paddleboarddev/paddleboard that referenced this pull request May 31, 2026
We will soon need `semantic_index` to be able to use
`CompletionProvider`. This is currently impossible due to a cyclic crate
dependency, because `CompletionProvider` lives in the `assistant` crate,
which depends on `semantic_index`.

This PR breaks the dependency cycle by extracting two crates out of
`assistant`: `language_model` and `completion`.

Only one piece of logic changed: [this
code](zed-industries/zed@5c724a3#diff-3857b3707687a4d585f1200eec4c34a7a079eae8d303b4ce5b4fce46234ace9fR61-R69).
* As of zed-industries/zed#13276, whenever we
ask a given completion provider for its available models, OpenAI
providers would go and ask the global assistant settings whether the
user had configured an `available_models` setting, and if so, return
that.
* This PR changes it so that instead of eagerly asking the assistant
settings for this info (the new crate must not depend on `assistant`, or
else the dependency cycle would be back), OpenAI completion providers
now store the user-configured settings as part of their struct, and
whenever the settings change, we update the provider.

In theory, this change should not change user-visible behavior...but
since it's the only change in this large PR that's more than just moving
code around, I'm mentioning it here in case there's an unexpected
regression in practice! (cc @amtoaer in case you'd like to try out this
branch and verify that the feature is still working the way you expect.)

Release Notes:

- N/A

---------

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Assistant] add custom_model parameter Implement Groq or OS models for Assistant Tab (settings.assistant)

7 participants