feat(providers/ollama): add variant support, retryable tag fetching with CLI fallback, and configurable provider name for robust model listing and health checks

This commit is contained in:
2025-10-18 05:59:50 +02:00
parent 4ce4ac0b0e
commit 3308b483f7
4 changed files with 682 additions and 88 deletions

View File

@@ -127,12 +127,13 @@ fn provider_from_config() -> Result<Arc<dyn Provider>, RpcError> {
match provider_cfg.provider_type.as_str() { match provider_cfg.provider_type.as_str() {
"ollama" | "ollama_cloud" => { "ollama" | "ollama_cloud" => {
let provider = OllamaProvider::from_config(&provider_cfg, Some(&config.general)) let provider =
.map_err(|e| { OllamaProvider::from_config(&provider_key, &provider_cfg, Some(&config.general))
RpcError::internal_error(format!( .map_err(|e| {
"Failed to init Ollama provider from config: {e}" RpcError::internal_error(format!(
)) "Failed to init Ollama provider from config: {e}"
})?; ))
})?;
Ok(Arc::new(provider) as Arc<dyn Provider>) Ok(Arc::new(provider) as Arc<dyn Provider>)
} }
other => Err(RpcError::internal_error(format!( other => Err(RpcError::internal_error(format!(

View File

@@ -185,7 +185,8 @@ fn build_local_provider(cfg: &Config) -> Result<Arc<dyn Provider>> {
match provider_cfg.provider_type.as_str() { match provider_cfg.provider_type.as_str() {
"ollama" | "ollama_cloud" => { "ollama" | "ollama_cloud" => {
let provider = OllamaProvider::from_config(provider_cfg, Some(&cfg.general))?; let provider =
OllamaProvider::from_config(&provider_name, provider_cfg, Some(&cfg.general))?;
Ok(Arc::new(provider) as Arc<dyn Provider>) Ok(Arc::new(provider) as Arc<dyn Provider>)
} }
other => Err(anyhow!(format!( other => Err(anyhow!(format!(

View File

@@ -161,7 +161,7 @@ async fn status(provider: String) -> Result<()> {
Value::String("cloud".to_string()), Value::String("cloud".to_string()),
); );
let ollama = OllamaProvider::from_config(&runtime_cfg, Some(&config.general)) let ollama = OllamaProvider::from_config(&provider, &runtime_cfg, Some(&config.general))
.with_context(|| "Failed to construct Ollama provider. Run `owlen cloud setup` first.")?; .with_context(|| "Failed to construct Ollama provider. Run `owlen cloud setup` first.")?;
match ollama.health_check().await { match ollama.health_check().await {
@@ -212,7 +212,7 @@ async fn models(provider: String) -> Result<()> {
Value::String("cloud".to_string()), Value::String("cloud".to_string()),
); );
let ollama = OllamaProvider::from_config(&runtime_cfg, Some(&config.general)) let ollama = OllamaProvider::from_config(&provider, &runtime_cfg, Some(&config.general))
.with_context(|| "Failed to construct Ollama provider. Run `owlen cloud setup` first.")?; .with_context(|| "Failed to construct Ollama provider. Run `owlen cloud setup` first.")?;
match ollama.list_models().await { match ollama.list_models().await {

File diff suppressed because it is too large Load Diff