mirror of
https://github.com/0xMassi/webclaw.git
synced 2026-07-24 07:31:01 +02:00
feat(llm): wire Atlas Cloud as opt-in last-resort provider
Atlas Cloud was merged as a provider type but wasn't reachable from the binaries — nothing constructed it, so ATLASCLOUD_API_KEY had no effect. Add it to ProviderChain::default() after Anthropic, gated on its key, so it's only active when explicitly configured and never preempts an already-configured provider. Also add an ATLASCLOUD_MODEL env fallback so chain users (new(None, None, None)) can override the model, matching the existing GEMINI_MODEL pattern. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c02295b63f
commit
bf7d747021
3 changed files with 16 additions and 7 deletions
|
|
@ -63,7 +63,7 @@ Three binaries: `webclaw` (CLI), `webclaw-mcp` (MCP server), `webclaw-server` (R
|
|||
- `url_security.rs` — SSRF guards + SSRF-safe redirect policy
|
||||
|
||||
### LLM Modules (`webclaw-llm`)
|
||||
- Provider chain (`chain.rs`): Ollama (local-first, always added; availability checked at call time) -> OpenAI -> Gemini -> Anthropic. Gemini sits ahead of Anthropic so Google Cloud credits are preferred; Anthropic is the last-resort fallback. Each provider lives in `providers/` (`ollama.rs`, `openai.rs`, `gemini.rs`, `anthropic.rs`).
|
||||
- Provider chain (`chain.rs`): Ollama (local-first, always added; availability checked at call time) -> OpenAI -> Gemini -> Anthropic -> Atlas Cloud. Gemini sits ahead of Anthropic so Google Cloud credits are preferred; Anthropic is the last-resort fallback. Atlas Cloud is opt-in and added last — only when `ATLASCLOUD_API_KEY` is set — so it never preempts an already-configured provider (`ATLASCLOUD_MODEL` / `ATLASCLOUD_BASE_URL` override its model/endpoint). Each provider lives in `providers/` (`ollama.rs`, `openai.rs`, `gemini.rs`, `anthropic.rs`, `atlascloud.rs`).
|
||||
- JSON schema extraction, prompt-based extraction, summarization
|
||||
|
||||
### PDF Modules (`webclaw-pdf`)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/// Provider chain — tries providers in order until one succeeds.
|
||||
/// Default order: Ollama (local, free) -> OpenAI -> Gemini -> Anthropic.
|
||||
/// Default order: Ollama (local, free) -> OpenAI -> Gemini -> Anthropic -> Atlas Cloud (opt-in).
|
||||
/// Only includes providers that are actually configured/available.
|
||||
use async_trait::async_trait;
|
||||
use tracing::{debug, warn};
|
||||
|
|
@ -7,8 +7,8 @@ use tracing::{debug, warn};
|
|||
use crate::error::LlmError;
|
||||
use crate::provider::{CompletionRequest, LlmProvider};
|
||||
use crate::providers::{
|
||||
anthropic::AnthropicProvider, gemini::GeminiProvider, ollama::OllamaProvider,
|
||||
openai::OpenAiProvider,
|
||||
anthropic::AnthropicProvider, atlascloud::AtlasCloudProvider, gemini::GeminiProvider,
|
||||
ollama::OllamaProvider, openai::OpenAiProvider,
|
||||
};
|
||||
|
||||
pub struct ProviderChain {
|
||||
|
|
@ -16,11 +16,13 @@ pub struct ProviderChain {
|
|||
}
|
||||
|
||||
impl ProviderChain {
|
||||
/// Build the default chain: Ollama -> OpenAI -> Gemini -> Anthropic.
|
||||
/// Build the default chain: Ollama -> OpenAI -> Gemini -> Anthropic -> Atlas Cloud.
|
||||
/// Ollama is always added (availability checked at call time).
|
||||
/// Cloud providers are only added if their API keys are configured.
|
||||
/// Gemini sits ahead of Anthropic so Google Cloud credits are preferred,
|
||||
/// with Anthropic as the last-resort fallback.
|
||||
/// with Anthropic as the last-resort fallback. Atlas Cloud is opt-in and
|
||||
/// added last (only when `ATLASCLOUD_API_KEY` is set), so it never preempts
|
||||
/// an already-configured provider.
|
||||
pub async fn default() -> Self {
|
||||
let mut providers: Vec<Box<dyn LlmProvider>> = Vec::new();
|
||||
|
||||
|
|
@ -47,6 +49,11 @@ impl ProviderChain {
|
|||
providers.push(Box::new(anthropic));
|
||||
}
|
||||
|
||||
if let Some(atlas) = AtlasCloudProvider::new(None, None, None) {
|
||||
debug!("atlascloud configured, adding to chain");
|
||||
providers.push(Box::new(atlas));
|
||||
}
|
||||
|
||||
Self { providers }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,9 @@ impl AtlasCloudProvider {
|
|||
let base_url = base_url
|
||||
.or_else(|| std::env::var("ATLASCLOUD_BASE_URL").ok())
|
||||
.unwrap_or_else(|| "https://api.atlascloud.ai/v1".into());
|
||||
let model = model.unwrap_or_else(|| "qwen/qwen3.5-flash".into());
|
||||
let model = model
|
||||
.or_else(|| std::env::var("ATLASCLOUD_MODEL").ok())
|
||||
.unwrap_or_else(|| "qwen/qwen3.5-flash".into());
|
||||
let inner = OpenAiProvider::new(Some(key), Some(base_url), Some(model))?;
|
||||
Some(Self { inner })
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue