Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions crates/forge_domain/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ impl ProviderId {
pub const ADAL: ProviderId = ProviderId(Cow::Borrowed("adal"));
pub const XIAOMI_MIMO: ProviderId = ProviderId(Cow::Borrowed("xiaomi_mimo"));
pub const NVIDIA: ProviderId = ProviderId(Cow::Borrowed("nvidia"));
pub const AMBIENT: ProviderId = ProviderId(Cow::Borrowed("ambient"));

/// Returns all built-in provider IDs
///
Expand Down Expand Up @@ -121,6 +122,7 @@ impl ProviderId {
ProviderId::ADAL,
ProviderId::XIAOMI_MIMO,
ProviderId::NVIDIA,
ProviderId::AMBIENT,
]
}

Expand Down Expand Up @@ -155,6 +157,7 @@ impl ProviderId {
"adal" => "AdaL".to_string(),
"xiaomi_mimo" => "XiaomiMimo".to_string(),
"nvidia" => "NVIDIA".to_string(),
"ambient" => "Ambient".to_string(),
_ => {
// For other providers, use UpperCamelCase conversion
use convert_case::{Case, Casing};
Expand Down Expand Up @@ -210,6 +213,7 @@ impl std::str::FromStr for ProviderId {
"adal" => ProviderId::ADAL,
"xiaomi_mimo" => ProviderId::XIAOMI_MIMO,
"nvidia" => ProviderId::NVIDIA,
"ambient" => ProviderId::AMBIENT,
// For custom providers, use Cow::Owned to avoid memory leaks
custom => ProviderId(Cow::Owned(custom.to_string())),
};
Expand Down Expand Up @@ -586,6 +590,7 @@ mod tests {
assert_eq!(ProviderId::OPENCODE_GO.to_string(), "OpenCode Go");
assert_eq!(ProviderId::GOOGLE_AI_STUDIO.to_string(), "GoogleAIStudio");
assert_eq!(ProviderId::NVIDIA.to_string(), "NVIDIA");
assert_eq!(ProviderId::AMBIENT.to_string(), "Ambient");
}

#[test]
Expand Down Expand Up @@ -626,6 +631,7 @@ mod tests {
assert!(built_in.contains(&ProviderId::OPENCODE_GO));
assert!(built_in.contains(&ProviderId::GOOGLE_AI_STUDIO));
assert!(built_in.contains(&ProviderId::NVIDIA));
assert!(built_in.contains(&ProviderId::AMBIENT));
}

#[test]
Expand Down Expand Up @@ -689,6 +695,24 @@ mod tests {
assert!(built_in.contains(&ProviderId::XIAOMI_MIMO));
}

#[test]
fn test_ambient_from_str() {
let actual = ProviderId::from_str("ambient").unwrap();
let expected = ProviderId::AMBIENT;
assert_eq!(actual, expected);
}

#[test]
fn test_ambient_display_name() {
assert_eq!(ProviderId::AMBIENT.to_string(), "Ambient");
}

#[test]
fn test_ambient_in_built_in_providers() {
let built_in = ProviderId::built_in_providers();
assert!(built_in.contains(&ProviderId::AMBIENT));
}

#[test]
fn test_io_intelligence() {
let fixture = "test_key";
Expand Down
9 changes: 9 additions & 0 deletions crates/forge_repo/src/provider/provider.json
Original file line number Diff line number Diff line change
Expand Up @@ -3549,5 +3549,14 @@
"url": "https://integrate.api.nvidia.com/v1/chat/completions",
"models": "https://integrate.api.nvidia.com/v1/models",
"auth_methods": ["api_key"]
},
{
"id": "ambient",
"api_key_vars": "AMBIENT_API_KEY",
"url_param_vars": [],
"response_type": "OpenAI",
"url": "https://api.ambient.xyz/v1/chat/completions",
"models": "https://api.ambient.xyz/v1/models",
"auth_methods": ["api_key"]
}
]
17 changes: 17 additions & 0 deletions crates/forge_repo/src/provider/provider_repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,23 @@ mod tests {
);
}

#[test]
fn test_ambient_config() {
let configs = get_provider_configs();
let config = configs
.iter()
.find(|c| c.id == ProviderId::AMBIENT)
.unwrap();
assert_eq!(config.id, ProviderId::AMBIENT);
assert_eq!(config.api_key_vars, Some("AMBIENT_API_KEY".to_string()));
assert!(config.url_param_vars.is_empty());
assert_eq!(config.response_type, Some(ProviderResponse::OpenAI));
assert_eq!(
config.url.as_str(),
"https://api.ambient.xyz/v1/chat/completions"
);
}

#[test]
fn test_provider_entry_with_static_models_converts_to_hardcoded() {
let model = forge_domain::Model::new("Qwen3.6-35B-A3b-q3-mlx")
Expand Down