mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-03 01:40:21 +08:00
centralize openai responses alias handling
This commit is contained in:
@@ -200,13 +200,5 @@ fn local_same_format_transport_unsupported_reason(
|
||||
}
|
||||
|
||||
fn same_api_format(left: &str, right: &str) -> bool {
|
||||
normalize_api_format_alias(left) == normalize_api_format_alias(right)
|
||||
}
|
||||
|
||||
fn normalize_api_format_alias(value: &str) -> String {
|
||||
match value.trim().to_ascii_lowercase().as_str() {
|
||||
"openai:cli" => "openai:responses".to_string(),
|
||||
"openai:compact" => "openai:responses:compact".to_string(),
|
||||
other => other.to_string(),
|
||||
}
|
||||
aether_ai_formats::legacy_openai_format_alias_matches(left, right)
|
||||
}
|
||||
|
||||
@@ -181,15 +181,11 @@ pub fn fixed_provider_endpoint_template_by_api_format(
|
||||
provider_type: &str,
|
||||
api_format: &str,
|
||||
) -> Option<&'static FixedProviderEndpointTemplate> {
|
||||
let normalized = match api_format.trim().to_ascii_lowercase().as_str() {
|
||||
"openai:cli" => "openai:responses",
|
||||
"openai:compact" => "openai:responses:compact",
|
||||
_ => api_format.trim(),
|
||||
};
|
||||
let normalized = aether_ai_formats::normalize_legacy_openai_format_alias(api_format);
|
||||
fixed_provider_template(provider_type)?
|
||||
.endpoints
|
||||
.iter()
|
||||
.find(|item| item.api_format.eq_ignore_ascii_case(normalized))
|
||||
.find(|item| item.api_format.eq_ignore_ascii_case(&normalized))
|
||||
}
|
||||
|
||||
pub fn provider_type_supports_model_fetch(provider_type: &str) -> bool {
|
||||
|
||||
@@ -60,17 +60,19 @@ pub fn build_transport_request_url(
|
||||
));
|
||||
}
|
||||
|
||||
let url = match provider_api_format.as_str() {
|
||||
let url = match aether_ai_formats::normalize_legacy_openai_format_alias(&provider_api_format)
|
||||
.as_str()
|
||||
{
|
||||
"openai:chat" => Some(build_openai_chat_url(
|
||||
&transport.endpoint.base_url,
|
||||
params.request_query,
|
||||
)),
|
||||
"openai:responses" | "openai:cli" => Some(build_openai_responses_url(
|
||||
"openai:responses" => Some(build_openai_responses_url(
|
||||
&transport.endpoint.base_url,
|
||||
params.request_query,
|
||||
false,
|
||||
)),
|
||||
"openai:responses:compact" | "openai:compact" => Some(build_openai_responses_url(
|
||||
"openai:responses:compact" => Some(build_openai_responses_url(
|
||||
&transport.endpoint.base_url,
|
||||
params.request_query,
|
||||
true,
|
||||
|
||||
Reference in New Issue
Block a user