mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-30 04:20:11 +01:00
0283bfb049
- Edit prediction providers can now be configured through the settings UI - Cleaned up the status bar menu to only show _configured_ providers - Added to the status bar icon button tooltip the name of the active provider - Only display the data collection functionality under "Privacy" for the Zed models - Moved the Codestral edit prediction provider out of the Mistral section in the agent panel into the settings UI - Refined and improved UI and states for configuring GitHub Copilot as both an agent and edit prediction provider #### Todos before merge: - [x] UI: Unify with settings UI style and tidy it all up - [x] Unify Copilot modal `impl`s to use separate window - [x] Remove stop light icons from GitHub modal - [x] Make dismiss events work on GitHub modal - [ ] Investigate workarounds to tell if Copilot authenticated even when LSP not running Release Notes: - settings_ui: Added a section for configuring edit prediction providers under AI > Edit Predictions, including Codestral and GitHub Copilot. Once you've updated you can use the following link to open it: zed://settings/edit_predictions.providers --------- Co-authored-by: Ben Kunkle <ben@zed.dev>
164 lines
5.2 KiB
Rust
164 lines
5.2 KiB
Rust
use std::sync::Arc;
|
|
|
|
use ::settings::{Settings, SettingsStore};
|
|
use client::{Client, UserStore};
|
|
use collections::HashSet;
|
|
use gpui::{App, Context, Entity};
|
|
use language_model::{LanguageModelProviderId, LanguageModelRegistry};
|
|
use provider::deepseek::DeepSeekLanguageModelProvider;
|
|
|
|
pub mod provider;
|
|
mod settings;
|
|
|
|
use crate::provider::anthropic::AnthropicLanguageModelProvider;
|
|
use crate::provider::bedrock::BedrockLanguageModelProvider;
|
|
use crate::provider::cloud::CloudLanguageModelProvider;
|
|
use crate::provider::copilot_chat::CopilotChatLanguageModelProvider;
|
|
use crate::provider::google::GoogleLanguageModelProvider;
|
|
use crate::provider::lmstudio::LmStudioLanguageModelProvider;
|
|
pub use crate::provider::mistral::MistralLanguageModelProvider;
|
|
use crate::provider::ollama::OllamaLanguageModelProvider;
|
|
use crate::provider::open_ai::OpenAiLanguageModelProvider;
|
|
use crate::provider::open_ai_compatible::OpenAiCompatibleLanguageModelProvider;
|
|
use crate::provider::open_router::OpenRouterLanguageModelProvider;
|
|
use crate::provider::vercel::VercelLanguageModelProvider;
|
|
use crate::provider::x_ai::XAiLanguageModelProvider;
|
|
pub use crate::settings::*;
|
|
|
|
pub fn init(user_store: Entity<UserStore>, client: Arc<Client>, cx: &mut App) {
|
|
let registry = LanguageModelRegistry::global(cx);
|
|
registry.update(cx, |registry, cx| {
|
|
register_language_model_providers(registry, user_store, client.clone(), cx);
|
|
});
|
|
|
|
let mut openai_compatible_providers = AllLanguageModelSettings::get_global(cx)
|
|
.openai_compatible
|
|
.keys()
|
|
.cloned()
|
|
.collect::<HashSet<_>>();
|
|
|
|
registry.update(cx, |registry, cx| {
|
|
register_openai_compatible_providers(
|
|
registry,
|
|
&HashSet::default(),
|
|
&openai_compatible_providers,
|
|
client.clone(),
|
|
cx,
|
|
);
|
|
});
|
|
cx.observe_global::<SettingsStore>(move |cx| {
|
|
let openai_compatible_providers_new = AllLanguageModelSettings::get_global(cx)
|
|
.openai_compatible
|
|
.keys()
|
|
.cloned()
|
|
.collect::<HashSet<_>>();
|
|
if openai_compatible_providers_new != openai_compatible_providers {
|
|
registry.update(cx, |registry, cx| {
|
|
register_openai_compatible_providers(
|
|
registry,
|
|
&openai_compatible_providers,
|
|
&openai_compatible_providers_new,
|
|
client.clone(),
|
|
cx,
|
|
);
|
|
});
|
|
openai_compatible_providers = openai_compatible_providers_new;
|
|
}
|
|
})
|
|
.detach();
|
|
}
|
|
|
|
fn register_openai_compatible_providers(
|
|
registry: &mut LanguageModelRegistry,
|
|
old: &HashSet<Arc<str>>,
|
|
new: &HashSet<Arc<str>>,
|
|
client: Arc<Client>,
|
|
cx: &mut Context<LanguageModelRegistry>,
|
|
) {
|
|
for provider_id in old {
|
|
if !new.contains(provider_id) {
|
|
registry.unregister_provider(LanguageModelProviderId::from(provider_id.clone()), cx);
|
|
}
|
|
}
|
|
|
|
for provider_id in new {
|
|
if !old.contains(provider_id) {
|
|
registry.register_provider(
|
|
Arc::new(OpenAiCompatibleLanguageModelProvider::new(
|
|
provider_id.clone(),
|
|
client.http_client(),
|
|
cx,
|
|
)),
|
|
cx,
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
fn register_language_model_providers(
|
|
registry: &mut LanguageModelRegistry,
|
|
user_store: Entity<UserStore>,
|
|
client: Arc<Client>,
|
|
cx: &mut Context<LanguageModelRegistry>,
|
|
) {
|
|
registry.register_provider(
|
|
Arc::new(CloudLanguageModelProvider::new(
|
|
user_store,
|
|
client.clone(),
|
|
cx,
|
|
)),
|
|
cx,
|
|
);
|
|
registry.register_provider(
|
|
Arc::new(AnthropicLanguageModelProvider::new(
|
|
client.http_client(),
|
|
cx,
|
|
)),
|
|
cx,
|
|
);
|
|
registry.register_provider(
|
|
Arc::new(OpenAiLanguageModelProvider::new(client.http_client(), cx)),
|
|
cx,
|
|
);
|
|
registry.register_provider(
|
|
Arc::new(OllamaLanguageModelProvider::new(client.http_client(), cx)),
|
|
cx,
|
|
);
|
|
registry.register_provider(
|
|
Arc::new(LmStudioLanguageModelProvider::new(client.http_client(), cx)),
|
|
cx,
|
|
);
|
|
registry.register_provider(
|
|
Arc::new(DeepSeekLanguageModelProvider::new(client.http_client(), cx)),
|
|
cx,
|
|
);
|
|
registry.register_provider(
|
|
Arc::new(GoogleLanguageModelProvider::new(client.http_client(), cx)),
|
|
cx,
|
|
);
|
|
registry.register_provider(
|
|
MistralLanguageModelProvider::global(client.http_client(), cx),
|
|
cx,
|
|
);
|
|
registry.register_provider(
|
|
Arc::new(BedrockLanguageModelProvider::new(client.http_client(), cx)),
|
|
cx,
|
|
);
|
|
registry.register_provider(
|
|
Arc::new(OpenRouterLanguageModelProvider::new(
|
|
client.http_client(),
|
|
cx,
|
|
)),
|
|
cx,
|
|
);
|
|
registry.register_provider(
|
|
Arc::new(VercelLanguageModelProvider::new(client.http_client(), cx)),
|
|
cx,
|
|
);
|
|
registry.register_provider(
|
|
Arc::new(XAiLanguageModelProvider::new(client.http_client(), cx)),
|
|
cx,
|
|
);
|
|
registry.register_provider(Arc::new(CopilotChatLanguageModelProvider::new(cx)), cx);
|
|
}
|