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:
@@ -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!(
|
||||||
|
|||||||
@@ -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!(
|
||||||
|
|||||||
@@ -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
Reference in New Issue
Block a user