Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 38eca6a

Browse files
fix(provider): Ambient as a built-in verified-inference provider (#3389)
Co-authored-by: Amit Singh <[email protected]>
1 parent bdeb1bc commit 38eca6a

3 files changed

Lines changed: 50 additions & 0 deletions

File tree

crates/forge_domain/src/provider.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ impl ProviderId {
8181
pub const ADAL: ProviderId = ProviderId(Cow::Borrowed("adal"));
8282
pub const XIAOMI_MIMO: ProviderId = ProviderId(Cow::Borrowed("xiaomi_mimo"));
8383
pub const NVIDIA: ProviderId = ProviderId(Cow::Borrowed("nvidia"));
84+
pub const AMBIENT: ProviderId = ProviderId(Cow::Borrowed("ambient"));
8485

8586
/// Returns all built-in provider IDs
8687
///
@@ -121,6 +122,7 @@ impl ProviderId {
121122
ProviderId::ADAL,
122123
ProviderId::XIAOMI_MIMO,
123124
ProviderId::NVIDIA,
125+
ProviderId::AMBIENT,
124126
]
125127
}
126128

@@ -155,6 +157,7 @@ impl ProviderId {
155157
"adal" => "AdaL".to_string(),
156158
"xiaomi_mimo" => "XiaomiMimo".to_string(),
157159
"nvidia" => "NVIDIA".to_string(),
160+
"ambient" => "Ambient".to_string(),
158161
_ => {
159162
// For other providers, use UpperCamelCase conversion
160163
use convert_case::{Case, Casing};
@@ -210,6 +213,7 @@ impl std::str::FromStr for ProviderId {
210213
"adal" => ProviderId::ADAL,
211214
"xiaomi_mimo" => ProviderId::XIAOMI_MIMO,
212215
"nvidia" => ProviderId::NVIDIA,
216+
"ambient" => ProviderId::AMBIENT,
213217
// For custom providers, use Cow::Owned to avoid memory leaks
214218
custom => ProviderId(Cow::Owned(custom.to_string())),
215219
};
@@ -586,6 +590,7 @@ mod tests {
586590
assert_eq!(ProviderId::OPENCODE_GO.to_string(), "OpenCode Go");
587591
assert_eq!(ProviderId::GOOGLE_AI_STUDIO.to_string(), "GoogleAIStudio");
588592
assert_eq!(ProviderId::NVIDIA.to_string(), "NVIDIA");
593+
assert_eq!(ProviderId::AMBIENT.to_string(), "Ambient");
589594
}
590595

591596
#[test]
@@ -626,6 +631,7 @@ mod tests {
626631
assert!(built_in.contains(&ProviderId::OPENCODE_GO));
627632
assert!(built_in.contains(&ProviderId::GOOGLE_AI_STUDIO));
628633
assert!(built_in.contains(&ProviderId::NVIDIA));
634+
assert!(built_in.contains(&ProviderId::AMBIENT));
629635
}
630636

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

698+
#[test]
699+
fn test_ambient_from_str() {
700+
let actual = ProviderId::from_str("ambient").unwrap();
701+
let expected = ProviderId::AMBIENT;
702+
assert_eq!(actual, expected);
703+
}
704+
705+
#[test]
706+
fn test_ambient_display_name() {
707+
assert_eq!(ProviderId::AMBIENT.to_string(), "Ambient");
708+
}
709+
710+
#[test]
711+
fn test_ambient_in_built_in_providers() {
712+
let built_in = ProviderId::built_in_providers();
713+
assert!(built_in.contains(&ProviderId::AMBIENT));
714+
}
715+
692716
#[test]
693717
fn test_io_intelligence() {
694718
let fixture = "test_key";

crates/forge_repo/src/provider/provider.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3730,5 +3730,14 @@
37303730
"url": "https://integrate.api.nvidia.com/v1/chat/completions",
37313731
"models": "https://integrate.api.nvidia.com/v1/models",
37323732
"auth_methods": ["api_key"]
3733+
},
3734+
{
3735+
"id": "ambient",
3736+
"api_key_vars": "AMBIENT_API_KEY",
3737+
"url_param_vars": [],
3738+
"response_type": "OpenAI",
3739+
"url": "https://api.ambient.xyz/v1/chat/completions",
3740+
"models": "https://api.ambient.xyz/v1/models",
3741+
"auth_methods": ["api_key"]
37333742
}
37343743
]

crates/forge_repo/src/provider/provider_repo.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,23 @@ mod tests {
885885
);
886886
}
887887

888+
#[test]
889+
fn test_ambient_config() {
890+
let configs = get_provider_configs();
891+
let config = configs
892+
.iter()
893+
.find(|c| c.id == ProviderId::AMBIENT)
894+
.unwrap();
895+
assert_eq!(config.id, ProviderId::AMBIENT);
896+
assert_eq!(config.api_key_vars, Some("AMBIENT_API_KEY".to_string()));
897+
assert!(config.url_param_vars.is_empty());
898+
assert_eq!(config.response_type, Some(ProviderResponse::OpenAI));
899+
assert_eq!(
900+
config.url.as_str(),
901+
"https://api.ambient.xyz/v1/chat/completions"
902+
);
903+
}
904+
888905
#[test]
889906
fn test_provider_entry_with_static_models_converts_to_hardcoded() {
890907
let model = forge_domain::Model::new("Qwen3.6-35B-A3b-q3-mlx")

0 commit comments

Comments
 (0)