From bbe6bf9caf7e4374e114bff2a6af119369c9cd9e Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Fri, 3 Jan 2025 18:34:15 -0500 Subject: [PATCH] assistant: Remove unused `AssistantSettings::update_file` (#22636) As a follow-up to #21672, this PR removes the `AssistantSettings::update_file` method, as it was no longer used anywhere. Release Notes: - N/A --- crates/assistant/src/assistant_settings.rs | 99 +--------------------- 1 file changed, 2 insertions(+), 97 deletions(-) diff --git a/crates/assistant/src/assistant_settings.rs b/crates/assistant/src/assistant_settings.rs index 87baf041ff8ea8e17fee6375ad27d6bcb0b225c9..89dbbd0fff0ae53c6250015bb9826927c9f1b6ac 100644 --- a/crates/assistant/src/assistant_settings.rs +++ b/crates/assistant/src/assistant_settings.rs @@ -3,18 +3,12 @@ use std::sync::Arc; use ::open_ai::Model as OpenAiModel; use anthropic::Model as AnthropicModel; use feature_flags::FeatureFlagAppExt; -use fs::Fs; use gpui::{AppContext, Pixels}; use language_model::{CloudModel, LanguageModel}; -use language_models::{ - provider::open_ai, AllLanguageModelSettings, AnthropicSettingsContent, - AnthropicSettingsContentV1, OllamaSettingsContent, OpenAiSettingsContent, - OpenAiSettingsContentV1, VersionedAnthropicSettingsContent, VersionedOpenAiSettingsContent, -}; use ollama::Model as OllamaModel; use schemars::{schema::Schema, JsonSchema}; use serde::{Deserialize, Serialize}; -use settings::{update_settings_file, Settings, SettingsSources}; +use settings::{Settings, SettingsSources}; #[derive(Copy, Clone, Default, Debug, Serialize, Deserialize, JsonSchema)] #[serde(rename_all = "snake_case")] @@ -106,96 +100,6 @@ impl AssistantSettingsContent { } } - pub fn update_file(&mut self, fs: Arc, cx: &AppContext) { - if let AssistantSettingsContent::Versioned(settings) = self { - if let VersionedAssistantSettingsContent::V1(settings) = settings { - if let Some(provider) = settings.provider.clone() { - match provider { - AssistantProviderContentV1::Anthropic { api_url, .. } => { - update_settings_file::( - fs, - cx, - move |content, _| { - if content.anthropic.is_none() { - content.anthropic = - Some(AnthropicSettingsContent::Versioned( - VersionedAnthropicSettingsContent::V1( - AnthropicSettingsContentV1 { - api_url, - available_models: None, - }, - ), - )); - } - }, - ) - } - AssistantProviderContentV1::Ollama { api_url, .. } => { - update_settings_file::( - fs, - cx, - move |content, _| { - if content.ollama.is_none() { - content.ollama = Some(OllamaSettingsContent { - api_url, - available_models: None, - }); - } - }, - ) - } - AssistantProviderContentV1::OpenAi { - api_url, - available_models, - .. - } => update_settings_file::( - fs, - cx, - move |content, _| { - if content.openai.is_none() { - let available_models = available_models.map(|models| { - models - .into_iter() - .filter_map(|model| match model { - OpenAiModel::Custom { - name, - display_name, - max_tokens, - max_output_tokens, - max_completion_tokens: None, - } => Some(open_ai::AvailableModel { - name, - display_name, - max_tokens, - max_output_tokens, - max_completion_tokens: None, - }), - _ => None, - }) - .collect::>() - }); - content.openai = Some(OpenAiSettingsContent::Versioned( - VersionedOpenAiSettingsContent::V1( - OpenAiSettingsContentV1 { - api_url, - available_models, - }, - ), - )); - } - }, - ), - _ => {} - } - } - } - } - - *self = AssistantSettingsContent::Versioned(VersionedAssistantSettingsContent::V2( - self.upgrade(), - )); - } - fn upgrade(&self) -> AssistantSettingsContentV2 { match self { AssistantSettingsContent::Versioned(settings) => match settings { @@ -534,6 +438,7 @@ fn merge(target: &mut T, value: Option) { #[cfg(test)] mod tests { + use fs::Fs; use gpui::{ReadGlobal, TestAppContext}; use super::*;