fix: use build_host_url for GCP Vertex AI location fallback (#8185)
Signed-off-by: rdondeti <ravitez.dondeti@gmail.com>
This commit is contained in:
@@ -72,7 +72,7 @@ fn build_vertex_url(
|
|||||||
let host_url = if configured_location == target_location {
|
let host_url = if configured_location == target_location {
|
||||||
host.to_string()
|
host.to_string()
|
||||||
} else {
|
} else {
|
||||||
host.replace(configured_location, target_location)
|
GcpVertexAIProvider::build_host_url(target_location)
|
||||||
};
|
};
|
||||||
|
|
||||||
let base_url =
|
let base_url =
|
||||||
@@ -735,6 +735,60 @@ mod tests {
|
|||||||
assert!(url.as_str().contains("locations/europe-west1"));
|
assert!(url.as_str().contains("locations/europe-west1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_build_vertex_url_global_location_fallback() {
|
||||||
|
// When configured_location is "global", the host is
|
||||||
|
// "https://aiplatform.googleapis.com" which does not contain "global".
|
||||||
|
// Falling back to a regional target_location must rebuild the host
|
||||||
|
// via build_host_url rather than string replacement.
|
||||||
|
let url = build_vertex_url(
|
||||||
|
"https://aiplatform.googleapis.com",
|
||||||
|
"global",
|
||||||
|
"test-project",
|
||||||
|
"claude-haiku-4-5@20251001",
|
||||||
|
ModelProvider::Anthropic,
|
||||||
|
"us-east5",
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
assert!(
|
||||||
|
url.as_str()
|
||||||
|
.starts_with("https://us-east5-aiplatform.googleapis.com"),
|
||||||
|
"Expected regional host for us-east5, got: {}",
|
||||||
|
url
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
url.as_str().contains("locations/us-east5"),
|
||||||
|
"Expected locations/us-east5 in path, got: {}",
|
||||||
|
url
|
||||||
|
);
|
||||||
|
assert!(url.as_str().contains(":streamRawPredict"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_build_vertex_url_global_location_same() {
|
||||||
|
// When both configured and target are "global", the host should stay as-is.
|
||||||
|
let url = build_vertex_url(
|
||||||
|
"https://aiplatform.googleapis.com",
|
||||||
|
"global",
|
||||||
|
"test-project",
|
||||||
|
"claude-haiku-4-5@20251001",
|
||||||
|
ModelProvider::Anthropic,
|
||||||
|
"global",
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
assert!(
|
||||||
|
url.as_str()
|
||||||
|
.starts_with("https://aiplatform.googleapis.com"),
|
||||||
|
"Expected global host, got: {}",
|
||||||
|
url
|
||||||
|
);
|
||||||
|
assert!(url.as_str().contains("locations/global"));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_provider_metadata() {
|
fn test_provider_metadata() {
|
||||||
let metadata = GcpVertexAIProvider::metadata();
|
let metadata = GcpVertexAIProvider::metadata();
|
||||||
|
|||||||
Reference in New Issue
Block a user