mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-10 03:09:50 +08:00
Normalize canonical API formats
This commit is contained in:
@@ -151,6 +151,7 @@ pub(crate) fn provider_key_is_oauth_managed(
|
||||
}
|
||||
|
||||
pub(crate) fn provider_key_configured_api_formats(key: &StoredProviderCatalogKey) -> Vec<String> {
|
||||
let mut seen = BTreeSet::new();
|
||||
key.api_formats
|
||||
.as_ref()
|
||||
.and_then(serde_json::Value::as_array)
|
||||
@@ -160,7 +161,8 @@ pub(crate) fn provider_key_configured_api_formats(key: &StoredProviderCatalogKey
|
||||
.filter_map(serde_json::Value::as_str)
|
||||
.map(str::trim)
|
||||
.filter(|value| !value.is_empty())
|
||||
.map(ToOwned::to_owned)
|
||||
.map(crate::ai_pipeline::normalize_api_format_alias)
|
||||
.filter(|value| seen.insert(value.clone()))
|
||||
.collect::<Vec<_>>()
|
||||
})
|
||||
.unwrap_or_default()
|
||||
@@ -172,11 +174,11 @@ pub(crate) fn provider_active_api_formats(
|
||||
let mut formats = Vec::new();
|
||||
let mut seen = BTreeSet::new();
|
||||
for endpoint in endpoints.iter().filter(|endpoint| endpoint.is_active) {
|
||||
let api_format = endpoint.api_format.trim();
|
||||
if api_format.is_empty() || !seen.insert(api_format.to_string()) {
|
||||
let api_format = crate::ai_pipeline::normalize_api_format_alias(&endpoint.api_format);
|
||||
if api_format.is_empty() || !seen.insert(api_format.clone()) {
|
||||
continue;
|
||||
}
|
||||
formats.push(api_format.to_string());
|
||||
formats.push(api_format);
|
||||
}
|
||||
formats
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user