diff options
| author | sigoden <sigoden@gmail.com> | 2025-02-10 17:46:24 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-10 17:46:24 +0800 |
| commit | 78f3d4ff49679da251a035f783d5b8380730cce5 (patch) | |
| tree | 28777a63e04b6be8a97bf5e6de39af8ef673bfb4 /src/client | |
| parent | 4fab4c54b2916931bf5705b5aa5e560e57f7f289 (diff) | |
| download | aichat-78f3d4ff49679da251a035f783d5b8380730cce5.tar.gz | |
feat: drop predefined models for ollama (#1165)
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/common.rs | 29 | ||||
| -rw-r--r-- | src/client/mod.rs | 3 |
2 files changed, 18 insertions, 14 deletions
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", |
