mirror of
https://github.com/0xMassi/webclaw.git
synced 2026-07-24 07:31:01 +02:00
Support Atlas Cloud base URL override
This commit is contained in:
parent
0124ab9df3
commit
a7e77532db
3 changed files with 12 additions and 6 deletions
|
|
@ -2242,6 +2242,7 @@ async fn build_llm_provider(cli: &Cli) -> Result<Box<dyn LlmProvider>, String> {
|
|||
"atlascloud" => {
|
||||
let provider = webclaw_llm::providers::atlascloud::AtlasCloudProvider::new(
|
||||
None,
|
||||
cli.llm_base_url.clone(),
|
||||
cli.llm_model.clone(),
|
||||
)
|
||||
.ok_or("ATLASCLOUD_API_KEY not set")?;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ impl ProviderChain {
|
|||
providers.push(Box::new(openai));
|
||||
}
|
||||
|
||||
if let Some(atlascloud) = AtlasCloudProvider::new(None, None) {
|
||||
if let Some(atlascloud) = AtlasCloudProvider::new(None, None, None) {
|
||||
debug!("atlascloud configured, adding to chain");
|
||||
providers.push(Box::new(atlascloud));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,10 +12,14 @@ pub struct AtlasCloudProvider {
|
|||
|
||||
impl AtlasCloudProvider {
|
||||
/// Returns `None` if no Atlas Cloud API key is available (param or env).
|
||||
pub fn new(key_override: Option<String>, model: Option<String>) -> Option<Self> {
|
||||
pub fn new(
|
||||
key_override: Option<String>,
|
||||
base_url: Option<String>,
|
||||
model: Option<String>,
|
||||
) -> Option<Self> {
|
||||
let key = super::load_api_key(key_override, "ATLASCLOUD_API_KEY")?;
|
||||
let base_url = std::env::var("ATLASCLOUD_BASE_URL")
|
||||
.ok()
|
||||
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 inner = OpenAiProvider::new(Some(key), Some(base_url), Some(model))?;
|
||||
|
|
@ -48,12 +52,12 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn empty_key_returns_none() {
|
||||
assert!(AtlasCloudProvider::new(Some(String::new()), None).is_none());
|
||||
assert!(AtlasCloudProvider::new(Some(String::new()), None, None).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn explicit_key_constructs_with_atlas_defaults() {
|
||||
let provider = AtlasCloudProvider::new(Some("test-key".into()), None)
|
||||
let provider = AtlasCloudProvider::new(Some("test-key".into()), None, None)
|
||||
.expect("should construct");
|
||||
assert_eq!(provider.name(), "atlascloud");
|
||||
assert_eq!(provider.default_model(), "qwen/qwen3.5-flash");
|
||||
|
|
@ -63,6 +67,7 @@ mod tests {
|
|||
fn explicit_model_override() {
|
||||
let provider = AtlasCloudProvider::new(
|
||||
Some("test-key".into()),
|
||||
Some("https://proxy.example.com/v1".into()),
|
||||
Some("deepseek-ai/deepseek-v4-pro".into()),
|
||||
)
|
||||
.expect("should construct");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue