
I've been bothered by using simple hyphens for bullet lists here for a while; it kinda looked cheap and not well-formatted. So, in this PR, I'm adding a new, custom UI component in the `language_models` crate, called `InstructionListItem`, based off the `ListItem` that's somewhat mimic'ing what a `<li>` would be on the web. It does have a "rigid" structure as in it's always a label followed by a button (which is optional), but that seems okay given it has been the overall shape of the copy we've been using here. Also, never really loved that we were pasting URLs directly, that kinda felt cheap, too. I could see an argument where it's just clearer, but it looks too cluttered, as URLs aren't super pretty, necessarily. | Before | After | |--------|--------| | <img src="https://github.com/user-attachments/assets/ffd1ac27-b1f4-450d-abf5-079285fc9877" width="700px" /> | <img src="https://github.com/user-attachments/assets/28fb9d0d-205d-45d8-9e43-1aaa947adc96" width="700px" /> | Release Notes: - N/A
92 lines
3.1 KiB
Rust
92 lines
3.1 KiB
Rust
use std::sync::Arc;
|
|
|
|
use client::{Client, UserStore};
|
|
use fs::Fs;
|
|
use gpui::{App, Context, Entity};
|
|
use language_model::{LanguageModelProviderId, LanguageModelRegistry, ZED_CLOUD_PROVIDER_ID};
|
|
use provider::deepseek::DeepSeekLanguageModelProvider;
|
|
|
|
pub mod provider;
|
|
mod settings;
|
|
pub mod ui;
|
|
|
|
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;
|
|
use crate::provider::mistral::MistralLanguageModelProvider;
|
|
use crate::provider::ollama::OllamaLanguageModelProvider;
|
|
use crate::provider::open_ai::OpenAiLanguageModelProvider;
|
|
pub use crate::settings::*;
|
|
|
|
pub fn init(user_store: Entity<UserStore>, client: Arc<Client>, fs: Arc<dyn Fs>, cx: &mut App) {
|
|
crate::settings::init(fs, cx);
|
|
let registry = LanguageModelRegistry::global(cx);
|
|
registry.update(cx, |registry, cx| {
|
|
register_language_model_providers(registry, user_store, client, cx);
|
|
});
|
|
}
|
|
|
|
fn register_language_model_providers(
|
|
registry: &mut LanguageModelRegistry,
|
|
user_store: Entity<UserStore>,
|
|
client: Arc<Client>,
|
|
cx: &mut Context<LanguageModelRegistry>,
|
|
) {
|
|
use feature_flags::FeatureFlagAppExt;
|
|
|
|
registry.register_provider(
|
|
AnthropicLanguageModelProvider::new(client.http_client(), cx),
|
|
cx,
|
|
);
|
|
registry.register_provider(
|
|
OpenAiLanguageModelProvider::new(client.http_client(), cx),
|
|
cx,
|
|
);
|
|
registry.register_provider(
|
|
OllamaLanguageModelProvider::new(client.http_client(), cx),
|
|
cx,
|
|
);
|
|
registry.register_provider(
|
|
LmStudioLanguageModelProvider::new(client.http_client(), cx),
|
|
cx,
|
|
);
|
|
registry.register_provider(
|
|
DeepSeekLanguageModelProvider::new(client.http_client(), cx),
|
|
cx,
|
|
);
|
|
registry.register_provider(
|
|
GoogleLanguageModelProvider::new(client.http_client(), cx),
|
|
cx,
|
|
);
|
|
registry.register_provider(
|
|
MistralLanguageModelProvider::new(client.http_client(), cx),
|
|
cx,
|
|
);
|
|
registry.register_provider(
|
|
BedrockLanguageModelProvider::new(client.http_client(), cx),
|
|
cx,
|
|
);
|
|
registry.register_provider(CopilotChatLanguageModelProvider::new(cx), cx);
|
|
|
|
cx.observe_flag::<feature_flags::LanguageModels, _>(move |enabled, cx| {
|
|
let user_store = user_store.clone();
|
|
let client = client.clone();
|
|
LanguageModelRegistry::global(cx).update(cx, move |registry, cx| {
|
|
if enabled {
|
|
registry.register_provider(
|
|
CloudLanguageModelProvider::new(user_store.clone(), client.clone(), cx),
|
|
cx,
|
|
);
|
|
} else {
|
|
registry.unregister_provider(
|
|
LanguageModelProviderId::from(ZED_CLOUD_PROVIDER_ID.to_string()),
|
|
cx,
|
|
);
|
|
}
|
|
});
|
|
})
|
|
.detach();
|
|
}
|