Improve gateway transport and usage runtime

This commit is contained in:
elky
2026-06-25 22:36:27 +08:00
parent d336d1a7fa
commit 6f00e9fc67
112 changed files with 12456 additions and 1387 deletions
@@ -172,6 +172,8 @@ pub fn build_passthrough_path_url(
let normalized_base_url =
if trimmed_base_url.ends_with("/v1beta") && trimmed_path.starts_with("/v1beta") {
trimmed_base_url.trim_end_matches("/v1beta")
} else if trimmed_base_url.ends_with("/v1") && trimmed_path.starts_with("/v1/") {
trimmed_base_url.trim_end_matches("/v1")
} else {
trimmed_base_url
};
@@ -681,6 +683,20 @@ mod tests {
);
}
#[test]
fn passthrough_path_does_not_duplicate_openai_v1_root() {
assert_eq!(
build_passthrough_path_url(
"https://api.openai.example/v1?tenant=demo",
"/v1/chat/completions?variant=chat",
Some("trace=1"),
&[]
)
.as_deref(),
Some("https://api.openai.example/v1/chat/completions?tenant=demo&trace=1&variant=chat")
);
}
#[test]
fn merges_base_url_query_for_gemini_files_passthrough_urls() {
assert_eq!(