Repository navigation
Add the ability to customize available models for OpenAI-compatible services - #13276
Conversation
rtfeldman
left a comment
There was a problem hiding this comment.
Thanks for the contribution - this is looking good overall! 😃
I have one requested design change, and then some questions about code structure.
|
Thank you. I've updated it. Please let me know if there are any other issues. |
|
Some central documentation for new features would be nice. |
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>
This comment was marked as duplicate.
This comment was marked as duplicate.
|
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!). |
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). |
|
Thank you for sharing @notpeter! I got the following working in Zed for the {
"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
}
]
}
},
} |
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>
…ervices (zed-industries#13276) Closes zed-industries#11984, closes zed-industries#11075. Release Notes: - Added the ability to customize available models for OpenAI-compatible services ([zed-industries#11984](zed-industries#11984)) ([zed-industries#11075](zed-industries#11075)). 

Closes #11984, closes #11075.
Release Notes: