fix(provider): update url path handling for azure provider (#1443)
Co-authored-by: Zengyu <sizengyu@spgroup.com.sg>
This commit is contained in:
@@ -64,10 +64,21 @@ impl AzureProvider {
|
|||||||
let mut base_url = url::Url::parse(&self.endpoint)
|
let mut base_url = url::Url::parse(&self.endpoint)
|
||||||
.map_err(|e| ProviderError::RequestFailed(format!("Invalid base URL: {e}")))?;
|
.map_err(|e| ProviderError::RequestFailed(format!("Invalid base URL: {e}")))?;
|
||||||
|
|
||||||
base_url.set_path(&format!(
|
// Get the existing path without trailing slashes
|
||||||
"openai/deployments/{}/chat/completions",
|
let existing_path = base_url.path().trim_end_matches('/');
|
||||||
self.deployment_name
|
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)));
|
base_url.set_query(Some(&format!("api-version={}", self.api_version)));
|
||||||
|
|
||||||
let response: reqwest::Response = self
|
let response: reqwest::Response = self
|
||||||
|
|||||||
Reference in New Issue
Block a user