Settings refactor (#38367)
Co-Authored-By: Ben K <ben@zed.dev> Co-Authored-By: Anthony <anthony@zed.dev> Co-Authored-By: Mikayla <mikayla@zed.dev> Release Notes: - settings: Major internal changes to settings. The primary user-facing effect is that some settings which did not make sense in project settings files are no-longer read from there. (For example the inline blame settings) --------- Co-authored-by: Ben Kunkle <ben@zed.dev> Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com> Co-authored-by: Anthony <anthony@zed.dev>
This commit is contained in:
co-authored by
Ben Kunkle
Mikayla Maki
Anthony
parent
0a9023bce0
commit
fcdab160f9
@@ -18,8 +18,6 @@ use language_model::{
|
||||
LanguageModelToolResultContent, MessageContent, RateLimiter, Role,
|
||||
};
|
||||
use language_model::{LanguageModelCompletionEvent, LanguageModelToolUse, StopReason};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use settings::{Settings, SettingsStore};
|
||||
use std::pin::Pin;
|
||||
use std::str::FromStr;
|
||||
@@ -30,6 +28,8 @@ use ui::{Icon, IconName, List, Tooltip, prelude::*};
|
||||
use util::{ResultExt, truncate_and_trailoff};
|
||||
use zed_env_vars::{EnvVar, env_var};
|
||||
|
||||
pub use settings::AnthropicAvailableModel as AvailableModel;
|
||||
|
||||
const PROVIDER_ID: LanguageModelProviderId = language_model::ANTHROPIC_PROVIDER_ID;
|
||||
const PROVIDER_NAME: LanguageModelProviderName = language_model::ANTHROPIC_PROVIDER_NAME;
|
||||
|
||||
@@ -40,55 +40,6 @@ pub struct AnthropicSettings {
|
||||
pub available_models: Vec<AvailableModel>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
|
||||
pub struct AvailableModel {
|
||||
/// The model's name in the Anthropic API. e.g. claude-3-5-sonnet-latest, claude-3-opus-20240229, etc
|
||||
pub name: String,
|
||||
/// The model's name in Zed's UI, such as in the model selector dropdown menu in the assistant panel.
|
||||
pub display_name: Option<String>,
|
||||
/// The model's context window size.
|
||||
pub max_tokens: u64,
|
||||
/// A model `name` to substitute when calling tools, in case the primary model doesn't support tool calling.
|
||||
pub tool_override: Option<String>,
|
||||
/// Configuration of Anthropic's caching API.
|
||||
pub cache_configuration: Option<LanguageModelCacheConfiguration>,
|
||||
pub max_output_tokens: Option<u64>,
|
||||
pub default_temperature: Option<f32>,
|
||||
#[serde(default)]
|
||||
pub extra_beta_headers: Vec<String>,
|
||||
/// The model's mode (e.g. thinking)
|
||||
pub mode: Option<ModelMode>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, JsonSchema)]
|
||||
#[serde(tag = "type", rename_all = "lowercase")]
|
||||
pub enum ModelMode {
|
||||
#[default]
|
||||
Default,
|
||||
Thinking {
|
||||
/// The maximum number of tokens to use for reasoning. Must be lower than the model's `max_output_tokens`.
|
||||
budget_tokens: Option<u32>,
|
||||
},
|
||||
}
|
||||
|
||||
impl From<ModelMode> for AnthropicModelMode {
|
||||
fn from(value: ModelMode) -> Self {
|
||||
match value {
|
||||
ModelMode::Default => AnthropicModelMode::Default,
|
||||
ModelMode::Thinking { budget_tokens } => AnthropicModelMode::Thinking { budget_tokens },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<AnthropicModelMode> for ModelMode {
|
||||
fn from(value: AnthropicModelMode) -> Self {
|
||||
match value {
|
||||
AnthropicModelMode::Default => ModelMode::Default,
|
||||
AnthropicModelMode::Thinking { budget_tokens } => ModelMode::Thinking { budget_tokens },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AnthropicLanguageModelProvider {
|
||||
http_client: Arc<dyn HttpClient>,
|
||||
state: gpui::Entity<State>,
|
||||
@@ -237,7 +188,7 @@ impl LanguageModelProvider for AnthropicLanguageModelProvider {
|
||||
max_output_tokens: model.max_output_tokens,
|
||||
default_temperature: model.default_temperature,
|
||||
extra_beta_headers: model.extra_beta_headers.clone(),
|
||||
mode: model.mode.clone().unwrap_or_default().into(),
|
||||
mode: model.mode.unwrap_or_default().into(),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ use language_model::{
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
use settings::{Settings, SettingsStore};
|
||||
use settings::{BedrockAvailableModel as AvailableModel, Settings, SettingsStore};
|
||||
use smol::lock::OnceCell;
|
||||
use strum::{EnumIter, IntoEnumIterator, IntoStaticStr};
|
||||
use theme::ThemeSettings;
|
||||
@@ -83,15 +83,14 @@ pub enum BedrockAuthMethod {
|
||||
Automatic,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
|
||||
pub struct AvailableModel {
|
||||
pub name: String,
|
||||
pub display_name: Option<String>,
|
||||
pub max_tokens: u64,
|
||||
pub cache_configuration: Option<LanguageModelCacheConfiguration>,
|
||||
pub max_output_tokens: Option<u64>,
|
||||
pub default_temperature: Option<f32>,
|
||||
pub mode: Option<ModelMode>,
|
||||
impl From<settings::BedrockAuthMethodContent> for BedrockAuthMethod {
|
||||
fn from(value: settings::BedrockAuthMethodContent) -> Self {
|
||||
match value {
|
||||
settings::BedrockAuthMethodContent::SingleSignOn => BedrockAuthMethod::SingleSignOn,
|
||||
settings::BedrockAuthMethodContent::Automatic => BedrockAuthMethod::Automatic,
|
||||
settings::BedrockAuthMethodContent::NamedProfile => BedrockAuthMethod::NamedProfile,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, JsonSchema)]
|
||||
|
||||
@@ -32,6 +32,8 @@ use release_channel::AppVersion;
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize, de::DeserializeOwned};
|
||||
use settings::SettingsStore;
|
||||
pub use settings::ZedDotDevAvailableModel as AvailableModel;
|
||||
pub use settings::ZedDotDevAvailableProvider as AvailableProvider;
|
||||
use smol::io::{AsyncReadExt, BufReader};
|
||||
use std::pin::Pin;
|
||||
use std::str::FromStr as _;
|
||||
@@ -52,42 +54,6 @@ const PROVIDER_NAME: LanguageModelProviderName = language_model::ZED_CLOUD_PROVI
|
||||
pub struct ZedDotDevSettings {
|
||||
pub available_models: Vec<AvailableModel>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum AvailableProvider {
|
||||
Anthropic,
|
||||
OpenAi,
|
||||
Google,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
|
||||
pub struct AvailableModel {
|
||||
/// The provider of the language model.
|
||||
pub provider: AvailableProvider,
|
||||
/// The model's name in the provider's API. e.g. claude-3-5-sonnet-20240620
|
||||
pub name: String,
|
||||
/// The name displayed in the UI, such as in the assistant panel model dropdown menu.
|
||||
pub display_name: Option<String>,
|
||||
/// The size of the context window, indicating the maximum number of tokens the model can process.
|
||||
pub max_tokens: usize,
|
||||
/// The maximum number of output tokens allowed by the model.
|
||||
pub max_output_tokens: Option<u64>,
|
||||
/// The maximum number of completion tokens allowed by the model (o1-* only)
|
||||
pub max_completion_tokens: Option<u64>,
|
||||
/// Override this model with a different Anthropic model for tool calls.
|
||||
pub tool_override: Option<String>,
|
||||
/// Indicates whether this custom model supports caching.
|
||||
pub cache_configuration: Option<LanguageModelCacheConfiguration>,
|
||||
/// The default temperature to use for this model.
|
||||
pub default_temperature: Option<f32>,
|
||||
/// Any extra beta headers to provide when using the model.
|
||||
#[serde(default)]
|
||||
pub extra_beta_headers: Vec<String>,
|
||||
/// The model's mode (e.g. thinking)
|
||||
pub mode: Option<ModelMode>,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
|
||||
#[serde(tag = "type", rename_all = "lowercase")]
|
||||
pub enum ModelMode {
|
||||
|
||||
@@ -16,8 +16,7 @@ use language_model::{
|
||||
LanguageModelToolChoice, LanguageModelToolResultContent, LanguageModelToolUse, MessageContent,
|
||||
RateLimiter, Role, StopReason, TokenUsage,
|
||||
};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
pub use settings::DeepseekAvailableModel as AvailableModel;
|
||||
use settings::{Settings, SettingsStore};
|
||||
use std::pin::Pin;
|
||||
use std::str::FromStr;
|
||||
@@ -47,15 +46,6 @@ pub struct DeepSeekSettings {
|
||||
pub api_url: String,
|
||||
pub available_models: Vec<AvailableModel>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
|
||||
pub struct AvailableModel {
|
||||
pub name: String,
|
||||
pub display_name: Option<String>,
|
||||
pub max_tokens: u64,
|
||||
pub max_output_tokens: Option<u64>,
|
||||
}
|
||||
|
||||
pub struct DeepSeekLanguageModelProvider {
|
||||
http_client: Arc<dyn HttpClient>,
|
||||
state: Entity<State>,
|
||||
|
||||
@@ -24,6 +24,7 @@ use language_model::{
|
||||
};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
pub use settings::GoogleAvailableModel as AvailableModel;
|
||||
use settings::{Settings, SettingsStore};
|
||||
use std::pin::Pin;
|
||||
use std::sync::{
|
||||
@@ -60,32 +61,6 @@ pub enum ModelMode {
|
||||
},
|
||||
}
|
||||
|
||||
impl From<ModelMode> for GoogleModelMode {
|
||||
fn from(value: ModelMode) -> Self {
|
||||
match value {
|
||||
ModelMode::Default => GoogleModelMode::Default,
|
||||
ModelMode::Thinking { budget_tokens } => GoogleModelMode::Thinking { budget_tokens },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<GoogleModelMode> for ModelMode {
|
||||
fn from(value: GoogleModelMode) -> Self {
|
||||
match value {
|
||||
GoogleModelMode::Default => ModelMode::Default,
|
||||
GoogleModelMode::Thinking { budget_tokens } => ModelMode::Thinking { budget_tokens },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
|
||||
pub struct AvailableModel {
|
||||
name: String,
|
||||
display_name: Option<String>,
|
||||
max_tokens: u64,
|
||||
mode: Option<ModelMode>,
|
||||
}
|
||||
|
||||
pub struct GoogleLanguageModelProvider {
|
||||
http_client: Arc<dyn HttpClient>,
|
||||
state: gpui::Entity<State>,
|
||||
@@ -234,7 +209,7 @@ impl LanguageModelProvider for GoogleLanguageModelProvider {
|
||||
name: model.name.clone(),
|
||||
display_name: model.display_name.clone(),
|
||||
max_tokens: model.max_tokens,
|
||||
mode: model.mode.unwrap_or_default().into(),
|
||||
mode: model.mode.unwrap_or_default(),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@ use language_model::{
|
||||
LanguageModelRequest, RateLimiter, Role,
|
||||
};
|
||||
use lmstudio::{ModelType, get_models};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
pub use settings::LmStudioAvailableModel as AvailableModel;
|
||||
use settings::{Settings, SettingsStore};
|
||||
use std::pin::Pin;
|
||||
use std::str::FromStr;
|
||||
@@ -40,15 +39,6 @@ pub struct LmStudioSettings {
|
||||
pub available_models: Vec<AvailableModel>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
|
||||
pub struct AvailableModel {
|
||||
pub name: String,
|
||||
pub display_name: Option<String>,
|
||||
pub max_tokens: u64,
|
||||
pub supports_tool_calls: bool,
|
||||
pub supports_images: bool,
|
||||
}
|
||||
|
||||
pub struct LmStudioLanguageModelProvider {
|
||||
http_client: Arc<dyn HttpClient>,
|
||||
state: gpui::Entity<State>,
|
||||
|
||||
@@ -15,8 +15,7 @@ use language_model::{
|
||||
RateLimiter, Role, StopReason, TokenUsage,
|
||||
};
|
||||
use mistral::{MISTRAL_API_URL, StreamResponse};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
pub use settings::MistralAvailableModel as AvailableModel;
|
||||
use settings::{Settings, SettingsStore};
|
||||
use std::collections::HashMap;
|
||||
use std::pin::Pin;
|
||||
@@ -42,18 +41,6 @@ pub struct MistralSettings {
|
||||
pub available_models: Vec<AvailableModel>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
|
||||
pub struct AvailableModel {
|
||||
pub name: String,
|
||||
pub display_name: Option<String>,
|
||||
pub max_tokens: u64,
|
||||
pub max_output_tokens: Option<u64>,
|
||||
pub max_completion_tokens: Option<u64>,
|
||||
pub supports_tools: Option<bool>,
|
||||
pub supports_images: Option<bool>,
|
||||
pub supports_thinking: Option<bool>,
|
||||
}
|
||||
|
||||
pub struct MistralLanguageModelProvider {
|
||||
http_client: Arc<dyn HttpClient>,
|
||||
state: gpui::Entity<State>,
|
||||
|
||||
@@ -13,12 +13,10 @@ use language_model::{
|
||||
};
|
||||
use menu;
|
||||
use ollama::{
|
||||
ChatMessage, ChatOptions, ChatRequest, ChatResponseDelta, KeepAlive, OLLAMA_API_URL,
|
||||
OllamaFunctionCall, OllamaFunctionTool, OllamaToolCall, get_models, show_model,
|
||||
stream_chat_completion,
|
||||
ChatMessage, ChatOptions, ChatRequest, ChatResponseDelta, OLLAMA_API_URL, OllamaFunctionCall,
|
||||
OllamaFunctionTool, OllamaToolCall, get_models, show_model, stream_chat_completion,
|
||||
};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
pub use settings::OllamaAvailableModel as AvailableModel;
|
||||
use settings::{Settings, SettingsStore, update_settings_file};
|
||||
use std::pin::Pin;
|
||||
use std::sync::LazyLock;
|
||||
@@ -48,24 +46,6 @@ pub struct OllamaSettings {
|
||||
pub available_models: Vec<AvailableModel>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
|
||||
pub struct AvailableModel {
|
||||
/// The model name in the Ollama API (e.g. "llama3.2:latest")
|
||||
pub name: String,
|
||||
/// The model's name in Zed's UI, such as in the model selector dropdown menu in the assistant panel.
|
||||
pub display_name: Option<String>,
|
||||
/// The Context Length parameter to the model (aka num_ctx or n_ctx)
|
||||
pub max_tokens: u64,
|
||||
/// The number of seconds to keep the connection open after the last request
|
||||
pub keep_alive: Option<KeepAlive>,
|
||||
/// Whether the model supports tools
|
||||
pub supports_tools: Option<bool>,
|
||||
/// Whether the model supports vision
|
||||
pub supports_images: Option<bool>,
|
||||
/// Whether to enable think mode
|
||||
pub supports_thinking: Option<bool>,
|
||||
}
|
||||
|
||||
pub struct OllamaLanguageModelProvider {
|
||||
http_client: Arc<dyn HttpClient>,
|
||||
state: gpui::Entity<State>,
|
||||
@@ -703,15 +683,13 @@ impl ConfigurationView {
|
||||
let current_url = OllamaLanguageModelProvider::api_url(cx);
|
||||
if !api_url.is_empty() && &api_url != ¤t_url {
|
||||
let fs = <dyn Fs>::global(cx);
|
||||
update_settings_file::<AllLanguageModelSettings>(fs, cx, move |settings, _| {
|
||||
if let Some(settings) = settings.ollama.as_mut() {
|
||||
settings.api_url = Some(api_url);
|
||||
} else {
|
||||
settings.ollama = Some(crate::settings::OllamaSettingsContent {
|
||||
api_url: Some(api_url),
|
||||
available_models: None,
|
||||
});
|
||||
}
|
||||
update_settings_file(fs, cx, move |settings, _| {
|
||||
settings
|
||||
.language_models
|
||||
.get_or_insert_default()
|
||||
.ollama
|
||||
.get_or_insert_default()
|
||||
.api_url = Some(api_url);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -720,8 +698,12 @@ impl ConfigurationView {
|
||||
self.api_url_editor
|
||||
.update(cx, |input, cx| input.set_text("", window, cx));
|
||||
let fs = <dyn Fs>::global(cx);
|
||||
update_settings_file::<AllLanguageModelSettings>(fs, cx, |settings, _cx| {
|
||||
if let Some(settings) = settings.ollama.as_mut() {
|
||||
update_settings_file(fs, cx, |settings, _cx| {
|
||||
if let Some(settings) = settings
|
||||
.language_models
|
||||
.as_mut()
|
||||
.and_then(|models| models.ollama.as_mut())
|
||||
{
|
||||
settings.api_url = Some(OLLAMA_API_URL.into());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -15,9 +15,7 @@ use menu;
|
||||
use open_ai::{
|
||||
ImageUrl, Model, OPEN_AI_API_URL, ReasoningEffort, ResponseStreamEvent, stream_completion,
|
||||
};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use settings::{Settings, SettingsStore};
|
||||
use settings::{OpenAiAvailableModel as AvailableModel, Settings, SettingsStore};
|
||||
use std::pin::Pin;
|
||||
use std::str::FromStr as _;
|
||||
use std::sync::{Arc, LazyLock};
|
||||
@@ -41,16 +39,6 @@ pub struct OpenAiSettings {
|
||||
pub available_models: Vec<AvailableModel>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
|
||||
pub struct AvailableModel {
|
||||
pub name: String,
|
||||
pub display_name: Option<String>,
|
||||
pub max_tokens: u64,
|
||||
pub max_output_tokens: Option<u64>,
|
||||
pub max_completion_tokens: Option<u64>,
|
||||
pub reasoning_effort: Option<ReasoningEffort>,
|
||||
}
|
||||
|
||||
pub struct OpenAiLanguageModelProvider {
|
||||
http_client: Arc<dyn HttpClient>,
|
||||
state: gpui::Entity<State>,
|
||||
|
||||
@@ -11,8 +11,6 @@ use language_model::{
|
||||
};
|
||||
use menu;
|
||||
use open_ai::{ResponseStreamEvent, stream_completion};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use settings::{Settings, SettingsStore};
|
||||
use std::sync::Arc;
|
||||
use ui::{ElevationIndex, Tooltip, prelude::*};
|
||||
@@ -22,6 +20,8 @@ use zed_env_vars::EnvVar;
|
||||
|
||||
use crate::api_key::ApiKeyState;
|
||||
use crate::provider::open_ai::{OpenAiEventMapper, into_open_ai};
|
||||
pub use settings::OpenAiCompatibleAvailableModel as AvailableModel;
|
||||
pub use settings::OpenAiCompatibleModelCapabilities as ModelCapabilities;
|
||||
|
||||
#[derive(Default, Clone, Debug, PartialEq)]
|
||||
pub struct OpenAiCompatibleSettings {
|
||||
@@ -29,36 +29,6 @@ pub struct OpenAiCompatibleSettings {
|
||||
pub available_models: Vec<AvailableModel>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
|
||||
pub struct AvailableModel {
|
||||
pub name: String,
|
||||
pub display_name: Option<String>,
|
||||
pub max_tokens: u64,
|
||||
pub max_output_tokens: Option<u64>,
|
||||
pub max_completion_tokens: Option<u64>,
|
||||
#[serde(default)]
|
||||
pub capabilities: ModelCapabilities,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
|
||||
pub struct ModelCapabilities {
|
||||
pub tools: bool,
|
||||
pub images: bool,
|
||||
pub parallel_tool_calls: bool,
|
||||
pub prompt_cache_key: bool,
|
||||
}
|
||||
|
||||
impl Default for ModelCapabilities {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
tools: true,
|
||||
images: false,
|
||||
parallel_tool_calls: false,
|
||||
prompt_cache_key: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct OpenAiCompatibleLanguageModelProvider {
|
||||
id: LanguageModelProviderId,
|
||||
name: LanguageModelProviderName,
|
||||
|
||||
@@ -14,12 +14,9 @@ use language_model::{
|
||||
LanguageModelToolUse, MessageContent, RateLimiter, Role, StopReason, TokenUsage,
|
||||
};
|
||||
use open_router::{
|
||||
Model, ModelMode as OpenRouterModelMode, OPEN_ROUTER_API_URL, Provider, ResponseStreamEvent,
|
||||
list_models,
|
||||
Model, ModelMode as OpenRouterModelMode, OPEN_ROUTER_API_URL, ResponseStreamEvent, list_models,
|
||||
};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use settings::{Settings, SettingsStore};
|
||||
use settings::{OpenRouterAvailableModel as AvailableModel, Settings, SettingsStore};
|
||||
use std::pin::Pin;
|
||||
use std::str::FromStr as _;
|
||||
use std::sync::{Arc, LazyLock};
|
||||
@@ -42,51 +39,6 @@ pub struct OpenRouterSettings {
|
||||
pub available_models: Vec<AvailableModel>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
|
||||
pub struct AvailableModel {
|
||||
pub name: String,
|
||||
pub display_name: Option<String>,
|
||||
pub max_tokens: u64,
|
||||
pub max_output_tokens: Option<u64>,
|
||||
pub max_completion_tokens: Option<u64>,
|
||||
pub supports_tools: Option<bool>,
|
||||
pub supports_images: Option<bool>,
|
||||
pub mode: Option<ModelMode>,
|
||||
pub provider: Option<Provider>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, JsonSchema)]
|
||||
#[serde(tag = "type", rename_all = "lowercase")]
|
||||
pub enum ModelMode {
|
||||
#[default]
|
||||
Default,
|
||||
Thinking {
|
||||
budget_tokens: Option<u32>,
|
||||
},
|
||||
}
|
||||
|
||||
impl From<ModelMode> for OpenRouterModelMode {
|
||||
fn from(value: ModelMode) -> Self {
|
||||
match value {
|
||||
ModelMode::Default => OpenRouterModelMode::Default,
|
||||
ModelMode::Thinking { budget_tokens } => {
|
||||
OpenRouterModelMode::Thinking { budget_tokens }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<OpenRouterModelMode> for ModelMode {
|
||||
fn from(value: OpenRouterModelMode) -> Self {
|
||||
match value {
|
||||
OpenRouterModelMode::Default => ModelMode::Default,
|
||||
OpenRouterModelMode::Thinking { budget_tokens } => {
|
||||
ModelMode::Thinking { budget_tokens }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct OpenRouterLanguageModelProvider {
|
||||
http_client: Arc<dyn HttpClient>,
|
||||
state: gpui::Entity<State>,
|
||||
@@ -259,7 +211,7 @@ impl LanguageModelProvider for OpenRouterLanguageModelProvider {
|
||||
max_tokens: model.max_tokens,
|
||||
supports_tools: model.supports_tools,
|
||||
supports_images: model.supports_images,
|
||||
mode: model.mode.clone().unwrap_or_default().into(),
|
||||
mode: model.mode.unwrap_or_default(),
|
||||
provider: model.provider.clone(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,8 +10,7 @@ use language_model::{
|
||||
LanguageModelToolChoice, RateLimiter, Role,
|
||||
};
|
||||
use open_ai::ResponseStreamEvent;
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
pub use settings::VercelAvailableModel as AvailableModel;
|
||||
use settings::{Settings, SettingsStore};
|
||||
use std::sync::{Arc, LazyLock};
|
||||
use strum::IntoEnumIterator;
|
||||
@@ -29,21 +28,12 @@ const PROVIDER_NAME: LanguageModelProviderName = LanguageModelProviderName::new(
|
||||
const API_KEY_ENV_VAR_NAME: &str = "VERCEL_API_KEY";
|
||||
static API_KEY_ENV_VAR: LazyLock<EnvVar> = env_var!(API_KEY_ENV_VAR_NAME);
|
||||
|
||||
#[derive(Default, Clone, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct VercelSettings {
|
||||
pub api_url: String,
|
||||
pub available_models: Vec<AvailableModel>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
|
||||
pub struct AvailableModel {
|
||||
pub name: String,
|
||||
pub display_name: Option<String>,
|
||||
pub max_tokens: u64,
|
||||
pub max_output_tokens: Option<u64>,
|
||||
pub max_completion_tokens: Option<u64>,
|
||||
}
|
||||
|
||||
pub struct VercelLanguageModelProvider {
|
||||
http_client: Arc<dyn HttpClient>,
|
||||
state: gpui::Entity<State>,
|
||||
|
||||
@@ -10,8 +10,7 @@ use language_model::{
|
||||
LanguageModelToolChoice, LanguageModelToolSchemaFormat, RateLimiter, Role,
|
||||
};
|
||||
use open_ai::ResponseStreamEvent;
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
pub use settings::XaiAvailableModel as AvailableModel;
|
||||
use settings::{Settings, SettingsStore};
|
||||
use std::sync::{Arc, LazyLock};
|
||||
use strum::IntoEnumIterator;
|
||||
@@ -35,15 +34,6 @@ pub struct XAiSettings {
|
||||
pub available_models: Vec<AvailableModel>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
|
||||
pub struct AvailableModel {
|
||||
pub name: String,
|
||||
pub display_name: Option<String>,
|
||||
pub max_tokens: u64,
|
||||
pub max_output_tokens: Option<u64>,
|
||||
pub max_completion_tokens: Option<u64>,
|
||||
}
|
||||
|
||||
pub struct XAiLanguageModelProvider {
|
||||
http_client: Arc<dyn HttpClient>,
|
||||
state: gpui::Entity<State>,
|
||||
|
||||
@@ -1,27 +1,16 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::Result;
|
||||
use collections::HashMap;
|
||||
use gpui::App;
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use settings::{Settings, SettingsKey, SettingsSources, SettingsUi};
|
||||
use settings::Settings;
|
||||
use util::MergeFrom;
|
||||
|
||||
use crate::provider::{
|
||||
self,
|
||||
anthropic::AnthropicSettings,
|
||||
bedrock::AmazonBedrockSettings,
|
||||
cloud::{self, ZedDotDevSettings},
|
||||
deepseek::DeepSeekSettings,
|
||||
google::GoogleSettings,
|
||||
lmstudio::LmStudioSettings,
|
||||
mistral::MistralSettings,
|
||||
ollama::OllamaSettings,
|
||||
open_ai::OpenAiSettings,
|
||||
open_ai_compatible::OpenAiCompatibleSettings,
|
||||
open_router::OpenRouterSettings,
|
||||
vercel::VercelSettings,
|
||||
x_ai::XAiSettings,
|
||||
anthropic::AnthropicSettings, bedrock::AmazonBedrockSettings, cloud::ZedDotDevSettings,
|
||||
deepseek::DeepSeekSettings, google::GoogleSettings, lmstudio::LmStudioSettings,
|
||||
mistral::MistralSettings, ollama::OllamaSettings, open_ai::OpenAiSettings,
|
||||
open_ai_compatible::OpenAiCompatibleSettings, open_router::OpenRouterSettings,
|
||||
vercel::VercelSettings, x_ai::XAiSettings,
|
||||
};
|
||||
|
||||
/// Initializes the language model settings.
|
||||
@@ -29,7 +18,6 @@ pub fn init_settings(cx: &mut App) {
|
||||
AllLanguageModelSettings::register(cx);
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct AllLanguageModelSettings {
|
||||
pub anthropic: AnthropicSettings,
|
||||
pub bedrock: AmazonBedrockSettings,
|
||||
@@ -46,281 +34,197 @@ pub struct AllLanguageModelSettings {
|
||||
pub zed_dot_dev: ZedDotDevSettings,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema, SettingsUi, SettingsKey,
|
||||
)]
|
||||
#[settings_key(key = "language_models")]
|
||||
pub struct AllLanguageModelSettingsContent {
|
||||
pub anthropic: Option<AnthropicSettingsContent>,
|
||||
pub bedrock: Option<AmazonBedrockSettingsContent>,
|
||||
pub deepseek: Option<DeepseekSettingsContent>,
|
||||
pub google: Option<GoogleSettingsContent>,
|
||||
pub lmstudio: Option<LmStudioSettingsContent>,
|
||||
pub mistral: Option<MistralSettingsContent>,
|
||||
pub ollama: Option<OllamaSettingsContent>,
|
||||
pub open_router: Option<OpenRouterSettingsContent>,
|
||||
pub openai: Option<OpenAiSettingsContent>,
|
||||
pub openai_compatible: Option<HashMap<Arc<str>, OpenAiCompatibleSettingsContent>>,
|
||||
pub vercel: Option<VercelSettingsContent>,
|
||||
pub x_ai: Option<XAiSettingsContent>,
|
||||
#[serde(rename = "zed.dev")]
|
||||
pub zed_dot_dev: Option<ZedDotDevSettingsContent>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema)]
|
||||
pub struct AnthropicSettingsContent {
|
||||
pub api_url: Option<String>,
|
||||
pub available_models: Option<Vec<provider::anthropic::AvailableModel>>,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema)]
|
||||
pub struct AmazonBedrockSettingsContent {
|
||||
available_models: Option<Vec<provider::bedrock::AvailableModel>>,
|
||||
endpoint_url: Option<String>,
|
||||
region: Option<String>,
|
||||
profile: Option<String>,
|
||||
authentication_method: Option<provider::bedrock::BedrockAuthMethod>,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema)]
|
||||
pub struct OllamaSettingsContent {
|
||||
pub api_url: Option<String>,
|
||||
pub available_models: Option<Vec<provider::ollama::AvailableModel>>,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema)]
|
||||
pub struct LmStudioSettingsContent {
|
||||
pub api_url: Option<String>,
|
||||
pub available_models: Option<Vec<provider::lmstudio::AvailableModel>>,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema)]
|
||||
pub struct DeepseekSettingsContent {
|
||||
pub api_url: Option<String>,
|
||||
pub available_models: Option<Vec<provider::deepseek::AvailableModel>>,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema)]
|
||||
pub struct MistralSettingsContent {
|
||||
pub api_url: Option<String>,
|
||||
pub available_models: Option<Vec<provider::mistral::AvailableModel>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema)]
|
||||
pub struct OpenAiSettingsContent {
|
||||
pub api_url: Option<String>,
|
||||
pub available_models: Option<Vec<provider::open_ai::AvailableModel>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema)]
|
||||
pub struct OpenAiCompatibleSettingsContent {
|
||||
pub api_url: String,
|
||||
pub available_models: Vec<provider::open_ai_compatible::AvailableModel>,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema)]
|
||||
pub struct VercelSettingsContent {
|
||||
pub api_url: Option<String>,
|
||||
pub available_models: Option<Vec<provider::vercel::AvailableModel>>,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema)]
|
||||
pub struct GoogleSettingsContent {
|
||||
pub api_url: Option<String>,
|
||||
pub available_models: Option<Vec<provider::google::AvailableModel>>,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema)]
|
||||
pub struct XAiSettingsContent {
|
||||
pub api_url: Option<String>,
|
||||
pub available_models: Option<Vec<provider::x_ai::AvailableModel>>,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema)]
|
||||
pub struct ZedDotDevSettingsContent {
|
||||
available_models: Option<Vec<cloud::AvailableModel>>,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, JsonSchema)]
|
||||
pub struct OpenRouterSettingsContent {
|
||||
pub api_url: Option<String>,
|
||||
pub available_models: Option<Vec<provider::open_router::AvailableModel>>,
|
||||
}
|
||||
|
||||
impl settings::Settings for AllLanguageModelSettings {
|
||||
const PRESERVED_KEYS: Option<&'static [&'static str]> = Some(&["version"]);
|
||||
|
||||
type FileContent = AllLanguageModelSettingsContent;
|
||||
|
||||
fn load(sources: SettingsSources<Self::FileContent>, _: &mut App) -> Result<Self> {
|
||||
fn merge<T>(target: &mut T, value: Option<T>) {
|
||||
if let Some(value) = value {
|
||||
*target = value;
|
||||
}
|
||||
}
|
||||
|
||||
let mut settings = AllLanguageModelSettings::default();
|
||||
|
||||
for value in sources.defaults_and_customizations() {
|
||||
// Anthropic
|
||||
let anthropic = value.anthropic.clone();
|
||||
merge(
|
||||
&mut settings.anthropic.api_url,
|
||||
anthropic.as_ref().and_then(|s| s.api_url.clone()),
|
||||
);
|
||||
merge(
|
||||
&mut settings.anthropic.available_models,
|
||||
anthropic.as_ref().and_then(|s| s.available_models.clone()),
|
||||
);
|
||||
|
||||
// Bedrock
|
||||
let bedrock = value.bedrock.clone();
|
||||
merge(
|
||||
&mut settings.bedrock.profile_name,
|
||||
bedrock.as_ref().map(|s| s.profile.clone()),
|
||||
);
|
||||
merge(
|
||||
&mut settings.bedrock.authentication_method,
|
||||
bedrock.as_ref().map(|s| s.authentication_method.clone()),
|
||||
);
|
||||
merge(
|
||||
&mut settings.bedrock.region,
|
||||
bedrock.as_ref().map(|s| s.region.clone()),
|
||||
);
|
||||
merge(
|
||||
&mut settings.bedrock.endpoint,
|
||||
bedrock.as_ref().map(|s| s.endpoint_url.clone()),
|
||||
);
|
||||
|
||||
// Ollama
|
||||
let ollama = value.ollama.clone();
|
||||
|
||||
merge(
|
||||
&mut settings.ollama.api_url,
|
||||
value.ollama.as_ref().and_then(|s| s.api_url.clone()),
|
||||
);
|
||||
merge(
|
||||
&mut settings.ollama.available_models,
|
||||
ollama.as_ref().and_then(|s| s.available_models.clone()),
|
||||
);
|
||||
|
||||
// LM Studio
|
||||
let lmstudio = value.lmstudio.clone();
|
||||
|
||||
merge(
|
||||
&mut settings.lmstudio.api_url,
|
||||
value.lmstudio.as_ref().and_then(|s| s.api_url.clone()),
|
||||
);
|
||||
merge(
|
||||
&mut settings.lmstudio.available_models,
|
||||
lmstudio.as_ref().and_then(|s| s.available_models.clone()),
|
||||
);
|
||||
|
||||
// DeepSeek
|
||||
let deepseek = value.deepseek.clone();
|
||||
|
||||
merge(
|
||||
&mut settings.deepseek.api_url,
|
||||
value.deepseek.as_ref().and_then(|s| s.api_url.clone()),
|
||||
);
|
||||
merge(
|
||||
&mut settings.deepseek.available_models,
|
||||
deepseek.as_ref().and_then(|s| s.available_models.clone()),
|
||||
);
|
||||
|
||||
// OpenAI
|
||||
let openai = value.openai.clone();
|
||||
merge(
|
||||
&mut settings.openai.api_url,
|
||||
openai.as_ref().and_then(|s| s.api_url.clone()),
|
||||
);
|
||||
merge(
|
||||
&mut settings.openai.available_models,
|
||||
openai.as_ref().and_then(|s| s.available_models.clone()),
|
||||
);
|
||||
|
||||
// OpenAI Compatible
|
||||
if let Some(openai_compatible) = value.openai_compatible.clone() {
|
||||
for (id, openai_compatible_settings) in openai_compatible {
|
||||
settings.openai_compatible.insert(
|
||||
id,
|
||||
fn from_defaults(content: &settings::SettingsContent, _cx: &mut App) -> Self {
|
||||
let language_models = content.language_models.clone().unwrap();
|
||||
let anthropic = language_models.anthropic.unwrap();
|
||||
let bedrock = language_models.bedrock.unwrap();
|
||||
let deepseek = language_models.deepseek.unwrap();
|
||||
let google = language_models.google.unwrap();
|
||||
let lmstudio = language_models.lmstudio.unwrap();
|
||||
let mistral = language_models.mistral.unwrap();
|
||||
let ollama = language_models.ollama.unwrap();
|
||||
let open_router = language_models.open_router.unwrap();
|
||||
let openai = language_models.openai.unwrap();
|
||||
let openai_compatible = language_models.openai_compatible.unwrap();
|
||||
let vercel = language_models.vercel.unwrap();
|
||||
let x_ai = language_models.x_ai.unwrap();
|
||||
let zed_dot_dev = language_models.zed_dot_dev.unwrap();
|
||||
Self {
|
||||
anthropic: AnthropicSettings {
|
||||
api_url: anthropic.api_url.unwrap(),
|
||||
available_models: anthropic.available_models.unwrap_or_default(),
|
||||
},
|
||||
bedrock: AmazonBedrockSettings {
|
||||
available_models: bedrock.available_models.unwrap_or_default(),
|
||||
region: bedrock.region,
|
||||
endpoint: bedrock.endpoint_url, // todo(should be api_url)
|
||||
profile_name: bedrock.profile,
|
||||
role_arn: None, // todo(was never a setting for this...)
|
||||
authentication_method: bedrock.authentication_method.map(Into::into),
|
||||
},
|
||||
deepseek: DeepSeekSettings {
|
||||
api_url: deepseek.api_url.unwrap(),
|
||||
available_models: deepseek.available_models.unwrap_or_default(),
|
||||
},
|
||||
google: GoogleSettings {
|
||||
api_url: google.api_url.unwrap(),
|
||||
available_models: google.available_models.unwrap_or_default(),
|
||||
},
|
||||
lmstudio: LmStudioSettings {
|
||||
api_url: lmstudio.api_url.unwrap(),
|
||||
available_models: lmstudio.available_models.unwrap_or_default(),
|
||||
},
|
||||
mistral: MistralSettings {
|
||||
api_url: mistral.api_url.unwrap(),
|
||||
available_models: mistral.available_models.unwrap_or_default(),
|
||||
},
|
||||
ollama: OllamaSettings {
|
||||
api_url: ollama.api_url.unwrap(),
|
||||
available_models: ollama.available_models.unwrap_or_default(),
|
||||
},
|
||||
open_router: OpenRouterSettings {
|
||||
api_url: open_router.api_url.unwrap(),
|
||||
available_models: open_router.available_models.unwrap_or_default(),
|
||||
},
|
||||
openai: OpenAiSettings {
|
||||
api_url: openai.api_url.unwrap(),
|
||||
available_models: openai.available_models.unwrap_or_default(),
|
||||
},
|
||||
openai_compatible: openai_compatible
|
||||
.into_iter()
|
||||
.map(|(key, value)| {
|
||||
(
|
||||
key,
|
||||
OpenAiCompatibleSettings {
|
||||
api_url: openai_compatible_settings.api_url,
|
||||
available_models: openai_compatible_settings.available_models,
|
||||
api_url: value.api_url,
|
||||
available_models: value.available_models,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Vercel
|
||||
let vercel = value.vercel.clone();
|
||||
merge(
|
||||
&mut settings.vercel.api_url,
|
||||
vercel.as_ref().and_then(|s| s.api_url.clone()),
|
||||
);
|
||||
merge(
|
||||
&mut settings.vercel.available_models,
|
||||
vercel.as_ref().and_then(|s| s.available_models.clone()),
|
||||
);
|
||||
|
||||
// XAI
|
||||
let x_ai = value.x_ai.clone();
|
||||
merge(
|
||||
&mut settings.x_ai.api_url,
|
||||
x_ai.as_ref().and_then(|s| s.api_url.clone()),
|
||||
);
|
||||
merge(
|
||||
&mut settings.x_ai.available_models,
|
||||
x_ai.as_ref().and_then(|s| s.available_models.clone()),
|
||||
);
|
||||
|
||||
// ZedDotDev
|
||||
merge(
|
||||
&mut settings.zed_dot_dev.available_models,
|
||||
value
|
||||
.zed_dot_dev
|
||||
.as_ref()
|
||||
.and_then(|s| s.available_models.clone()),
|
||||
);
|
||||
merge(
|
||||
&mut settings.google.api_url,
|
||||
value.google.as_ref().and_then(|s| s.api_url.clone()),
|
||||
);
|
||||
merge(
|
||||
&mut settings.google.available_models,
|
||||
value
|
||||
.google
|
||||
.as_ref()
|
||||
.and_then(|s| s.available_models.clone()),
|
||||
);
|
||||
|
||||
// Mistral
|
||||
let mistral = value.mistral.clone();
|
||||
merge(
|
||||
&mut settings.mistral.api_url,
|
||||
mistral.as_ref().and_then(|s| s.api_url.clone()),
|
||||
);
|
||||
merge(
|
||||
&mut settings.mistral.available_models,
|
||||
mistral.as_ref().and_then(|s| s.available_models.clone()),
|
||||
);
|
||||
|
||||
// OpenRouter
|
||||
let open_router = value.open_router.clone();
|
||||
merge(
|
||||
&mut settings.open_router.api_url,
|
||||
open_router.as_ref().and_then(|s| s.api_url.clone()),
|
||||
);
|
||||
merge(
|
||||
&mut settings.open_router.available_models,
|
||||
open_router
|
||||
.as_ref()
|
||||
.and_then(|s| s.available_models.clone()),
|
||||
);
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
vercel: VercelSettings {
|
||||
api_url: vercel.api_url.unwrap(),
|
||||
available_models: vercel.available_models.unwrap_or_default(),
|
||||
},
|
||||
x_ai: XAiSettings {
|
||||
api_url: x_ai.api_url.unwrap(),
|
||||
available_models: x_ai.available_models.unwrap_or_default(),
|
||||
},
|
||||
zed_dot_dev: ZedDotDevSettings {
|
||||
available_models: zed_dot_dev.available_models.unwrap_or_default(),
|
||||
},
|
||||
}
|
||||
|
||||
Ok(settings)
|
||||
}
|
||||
|
||||
fn import_from_vscode(_vscode: &settings::VsCodeSettings, _current: &mut Self::FileContent) {}
|
||||
fn refine(&mut self, content: &settings::SettingsContent, _cx: &mut App) {
|
||||
let Some(models) = content.language_models.as_ref() else {
|
||||
return;
|
||||
};
|
||||
|
||||
if let Some(anthropic) = models.anthropic.as_ref() {
|
||||
self.anthropic
|
||||
.available_models
|
||||
.merge_from(&anthropic.available_models);
|
||||
self.anthropic.api_url.merge_from(&anthropic.api_url);
|
||||
}
|
||||
|
||||
if let Some(bedrock) = models.bedrock.clone() {
|
||||
self.bedrock
|
||||
.available_models
|
||||
.merge_from(&bedrock.available_models);
|
||||
|
||||
if let Some(endpoint_url) = bedrock.endpoint_url {
|
||||
self.bedrock.endpoint = Some(endpoint_url)
|
||||
}
|
||||
|
||||
if let Some(region) = bedrock.region {
|
||||
self.bedrock.region = Some(region)
|
||||
}
|
||||
|
||||
if let Some(profile_name) = bedrock.profile {
|
||||
self.bedrock.profile_name = Some(profile_name);
|
||||
}
|
||||
|
||||
if let Some(auth_method) = bedrock.authentication_method {
|
||||
self.bedrock.authentication_method = Some(auth_method.into());
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(deepseek) = models.deepseek.as_ref() {
|
||||
self.deepseek
|
||||
.available_models
|
||||
.merge_from(&deepseek.available_models);
|
||||
self.deepseek.api_url.merge_from(&deepseek.api_url);
|
||||
}
|
||||
|
||||
if let Some(google) = models.google.as_ref() {
|
||||
self.google
|
||||
.available_models
|
||||
.merge_from(&google.available_models);
|
||||
self.google.api_url.merge_from(&google.api_url);
|
||||
}
|
||||
|
||||
if let Some(lmstudio) = models.lmstudio.as_ref() {
|
||||
self.lmstudio
|
||||
.available_models
|
||||
.merge_from(&lmstudio.available_models);
|
||||
self.lmstudio.api_url.merge_from(&lmstudio.api_url);
|
||||
}
|
||||
|
||||
if let Some(mistral) = models.mistral.as_ref() {
|
||||
self.mistral
|
||||
.available_models
|
||||
.merge_from(&mistral.available_models);
|
||||
self.mistral.api_url.merge_from(&mistral.api_url);
|
||||
}
|
||||
if let Some(ollama) = models.ollama.as_ref() {
|
||||
self.ollama
|
||||
.available_models
|
||||
.merge_from(&ollama.available_models);
|
||||
self.ollama.api_url.merge_from(&ollama.api_url);
|
||||
}
|
||||
if let Some(open_router) = models.open_router.as_ref() {
|
||||
self.open_router
|
||||
.available_models
|
||||
.merge_from(&open_router.available_models);
|
||||
self.open_router.api_url.merge_from(&open_router.api_url);
|
||||
}
|
||||
if let Some(openai) = models.openai.as_ref() {
|
||||
self.openai
|
||||
.available_models
|
||||
.merge_from(&openai.available_models);
|
||||
self.openai.api_url.merge_from(&openai.api_url);
|
||||
}
|
||||
if let Some(openai_compatible) = models.openai_compatible.clone() {
|
||||
for (name, value) in openai_compatible {
|
||||
self.openai_compatible.insert(
|
||||
name,
|
||||
OpenAiCompatibleSettings {
|
||||
api_url: value.api_url,
|
||||
available_models: value.available_models,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
if let Some(vercel) = models.vercel.as_ref() {
|
||||
self.vercel
|
||||
.available_models
|
||||
.merge_from(&vercel.available_models);
|
||||
self.vercel.api_url.merge_from(&vercel.api_url);
|
||||
}
|
||||
if let Some(x_ai) = models.x_ai.as_ref() {
|
||||
self.x_ai
|
||||
.available_models
|
||||
.merge_from(&x_ai.available_models);
|
||||
self.x_ai.api_url.merge_from(&x_ai.api_url);
|
||||
}
|
||||
if let Some(zed_dot_dev) = models.zed_dot_dev.as_ref() {
|
||||
self.zed_dot_dev
|
||||
.available_models
|
||||
.merge_from(&zed_dot_dev.available_models);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user