fix(provider): update url path handling for azure provider (#1443)

Co-authored-by: Zengyu <sizengyu@spgroup.com.sg>
This commit is contained in:
Si Zengyu
2025-02-28 23:23:39 +08:00
committed by GitHub
parent 96827303c0
commit 7d5d8b400b

View File

@@ -64,10 +64,21 @@ impl AzureProvider {
let mut base_url = url::Url::parse(&self.endpoint)
.map_err(|e| ProviderError::RequestFailed(format!("Invalid base URL: {e}")))?;
base_url.set_path(&format!(
"openai/deployments/{}/chat/completions",
self.deployment_name
));
// Get the existing path without trailing slashes
let existing_path = base_url.path().trim_end_matches('/');
let new_path = if existing_path.is_empty() {
format!(
"/openai/deployments/{}/chat/completions",
self.deployment_name
)
} else {
format!(
"{}/openai/deployments/{}/chat/completions",
existing_path, self.deployment_name
)
};
base_url.set_path(&new_path);
base_url.set_query(Some(&format!("api-version={}", self.api_version)));
let response: reqwest::Response = self