diff --git a/CLAUDE.md b/CLAUDE.md index aab2b15..c34155d 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -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`) diff --git a/crates/webclaw-llm/src/chain.rs b/crates/webclaw-llm/src/chain.rs index e2c6b8b..f564172 100644 --- a/crates/webclaw-llm/src/chain.rs +++ b/crates/webclaw-llm/src/chain.rs @@ -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> = 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 } } diff --git a/crates/webclaw-llm/src/providers/atlascloud.rs b/crates/webclaw-llm/src/providers/atlascloud.rs index a234ec9..8855d87 100644 --- a/crates/webclaw-llm/src/providers/atlascloud.rs +++ b/crates/webclaw-llm/src/providers/atlascloud.rs @@ -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 }) }