From 78f3d4ff49679da251a035f783d5b8380730cce5 Mon Sep 17 00:00:00 2001 From: sigoden Date: Mon, 10 Feb 2025 17:46:24 +0800 Subject: feat: drop predefined models for ollama (#1165) --- src/client/common.rs | 29 +++++++++++++++++------------ src/client/mod.rs | 3 +-- 2 files changed, 18 insertions(+), 14 deletions(-) (limited to 'src/client') diff --git a/src/client/common.rs b/src/client/common.rs index cfbb9d6..99b84b9 100644 --- a/src/client/common.rs +++ b/src/client/common.rs @@ -553,24 +553,29 @@ async fn set_client_models_config(client_config: &mut Value, client: &str) -> Re std::env::var(&env_name).ok() }), ) { - if let Ok(fetched_models) = abortable_run_with_spinner( + match abortable_run_with_spinner( fetch_models(api_base, api_key.as_deref()), "Fetching models", create_abort_signal(), ) .await { - model_names = MultiSelect::new("LLM models (required):", fetched_models) - .with_validator(|list: &[ListOption<&String>]| { - if list.is_empty() { - Ok(Validation::Invalid( - "At least one item must be selected".into(), - )) - } else { - Ok(Validation::Valid) - } - }) - .prompt()?; + Ok(fetched_models) => { + model_names = MultiSelect::new("LLM models (required):", fetched_models) + .with_validator(|list: &[ListOption<&String>]| { + if list.is_empty() { + Ok(Validation::Invalid( + "At least one item must be selected".into(), + )) + } else { + Ok(Validation::Valid) + } + }) + .prompt()?; + } + Err(err) => { + eprintln!("✗ Unable to fetch models: {err}"); + } } } if model_names.is_empty() { diff --git a/src/client/mod.rs b/src/client/mod.rs index c6b65bc..af0ace1 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -33,7 +33,7 @@ register_client!( (bedrock, "bedrock", BedrockConfig, BedrockClient), ); -pub const OPENAI_COMPATIBLE_PROVIDERS: [(&str, &str); 25] = [ +pub const OPENAI_COMPATIBLE_PROVIDERS: [(&str, &str); 24] = [ ("ai21", "https://api.ai21.com/studio/v1"), ( "cloudflare", @@ -53,7 +53,6 @@ pub const OPENAI_COMPATIBLE_PROVIDERS: [(&str, &str); 25] = [ ("moonshot", "https://api.moonshot.cn/v1"), ("novita", "https://api.novita.ai/v3/openai"), ("openrouter", "https://openrouter.ai/api/v1"), - ("ollama", "http://{OLLAMA_HOST}:11434/v1"), ("perplexity", "https://api.perplexity.ai"), ( "qianwen", -- cgit v1.2.3