mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-13 04:29:50 +08:00
Normalize canonical API formats
This commit is contained in:
@@ -54,21 +54,22 @@ pub(super) fn classify_ai_public_route(
|
||||
"ai_public",
|
||||
"claude",
|
||||
"count_tokens",
|
||||
"claude:chat",
|
||||
"claude:messages",
|
||||
false,
|
||||
))
|
||||
} else if method == http::Method::POST && normalized_path == "/v1/messages" {
|
||||
if is_claude_cli_request(headers) {
|
||||
Some(classified("ai_public", "claude", "cli", "claude:cli", true))
|
||||
let route_kind = if is_claude_cli_request(headers) {
|
||||
"cli"
|
||||
} else {
|
||||
Some(classified(
|
||||
"ai_public",
|
||||
"claude",
|
||||
"chat",
|
||||
"claude:chat",
|
||||
true,
|
||||
))
|
||||
}
|
||||
"messages"
|
||||
};
|
||||
Some(classified(
|
||||
"ai_public",
|
||||
"claude",
|
||||
route_kind,
|
||||
"claude:messages",
|
||||
true,
|
||||
))
|
||||
} else if normalized_path.starts_with("/v1/videos") {
|
||||
Some(classified(
|
||||
"ai_public",
|
||||
@@ -87,13 +88,19 @@ pub(super) fn classify_ai_public_route(
|
||||
true,
|
||||
))
|
||||
} else if is_gemini_cli_request(headers) {
|
||||
Some(classified("ai_public", "gemini", "cli", "gemini:cli", true))
|
||||
Some(classified(
|
||||
"ai_public",
|
||||
"gemini",
|
||||
"cli",
|
||||
"gemini:generate_content",
|
||||
true,
|
||||
))
|
||||
} else {
|
||||
Some(classified(
|
||||
"ai_public",
|
||||
"gemini",
|
||||
"chat",
|
||||
"gemini:chat",
|
||||
"generate_content",
|
||||
"gemini:generate_content",
|
||||
true,
|
||||
))
|
||||
}
|
||||
@@ -112,7 +119,7 @@ pub(super) fn classify_ai_public_route(
|
||||
"ai_public",
|
||||
"gemini",
|
||||
"files",
|
||||
"gemini:chat",
|
||||
"gemini:files",
|
||||
true,
|
||||
))
|
||||
} else {
|
||||
|
||||
@@ -162,7 +162,7 @@ pub(super) fn detect_public_models_auth_signature(uri: &Uri, headers: &http::Hea
|
||||
.is_some();
|
||||
let has_anthropic_version = header_value_str(headers, "anthropic-version").is_some();
|
||||
if has_claude_key && has_anthropic_version {
|
||||
return "claude:chat".to_string();
|
||||
return "claude:messages".to_string();
|
||||
}
|
||||
|
||||
let has_gemini_key = header_value_str(headers, "x-goog-api-key").is_some()
|
||||
@@ -171,11 +171,11 @@ pub(super) fn detect_public_models_auth_signature(uri: &Uri, headers: &http::Hea
|
||||
.any(|(key, value)| key == "key" && !value.trim().is_empty())
|
||||
});
|
||||
if has_gemini_key {
|
||||
return "gemini:chat".to_string();
|
||||
return "gemini:generate_content".to_string();
|
||||
}
|
||||
|
||||
if uri.path().starts_with("/v1beta/models") {
|
||||
return "gemini:chat".to_string();
|
||||
return "gemini:generate_content".to_string();
|
||||
}
|
||||
|
||||
"openai:chat".to_string()
|
||||
|
||||
Reference in New Issue
Block a user