Skip to content

Commit b9a3c6a

Browse files
fix(rig-1019): fix potentially incorrect provider URLs (#991)
1 parent c80ac48 commit b9a3c6a

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

rig-core/src/providers/azure.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -215,29 +215,32 @@ where
215215
fn post_audio_generation(&self, deployment_id: &str) -> http_client::Builder {
216216
let url = format!(
217217
"{}/openai/deployments/{}/audio/speech?api-version={}",
218-
self.azure_endpoint, deployment_id, self.api_version
219-
)
220-
.replace("//", "/");
218+
self.azure_endpoint,
219+
deployment_id.trim_start_matches('/'),
220+
self.api_version
221+
);
221222

222223
self.post(url)
223224
}
224225

225226
fn post_chat_completion(&self, deployment_id: &str) -> http_client::Builder {
226227
let url = format!(
227228
"{}/openai/deployments/{}/chat/completions?api-version={}",
228-
self.azure_endpoint, deployment_id, self.api_version
229-
)
230-
.replace("//", "/");
229+
self.azure_endpoint,
230+
deployment_id.trim_start_matches('/'),
231+
self.api_version
232+
);
231233

232234
self.post(url)
233235
}
234236

235237
fn post_transcription(&self, deployment_id: &str) -> http_client::Builder {
236238
let url = format!(
237239
"{}/openai/deployments/{}/audio/translations?api-version={}",
238-
self.azure_endpoint, deployment_id, self.api_version
239-
)
240-
.replace("//", "/");
240+
self.azure_endpoint,
241+
deployment_id.trim_start_matches('/'),
242+
self.api_version
243+
);
241244

242245
self.post(url)
243246
}
@@ -246,9 +249,10 @@ where
246249
fn post_image_generation(&self, deployment_id: &str) -> http_client::Builder {
247250
let url = format!(
248251
"{}/openai/deployments/{}/images/generations?api-version={}",
249-
self.azure_endpoint, deployment_id, self.api_version
250-
)
251-
.replace("//", "/");
252+
self.azure_endpoint,
253+
deployment_id.trim_start_matches('/'),
254+
self.api_version
255+
);
252256

253257
self.post(url)
254258
}

rig-core/src/providers/huggingface/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ where
217217
}
218218

219219
pub(crate) fn get(&self, path: &str) -> http_client::Result<http_client::Builder> {
220-
let url = format!("{}/{}", self.base_url, path).replace("//", "/");
220+
let url = format!("{}/{}", self.base_url, path.trim_start_matches('/'));
221221

222222
let mut req = http_client::Request::get(url);
223223

rig-core/src/providers/mistral/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ where
123123
}
124124

125125
pub(crate) fn get(&self, path: &str) -> http_client::Result<http_client::Builder> {
126-
let url = format!("{}/{}", self.base_url, path).replace("//", "/");
126+
let url = format!("{}/{}", self.base_url, path.trim_start_matches('/'));
127127

128128
http_client::with_bearer_auth(http_client::Request::get(url), &self.api_key)
129129
}

rig-core/src/providers/together/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ where
108108
}
109109

110110
pub(crate) fn get(&self, path: &str) -> http_client::Result<http_client::Builder> {
111-
let url = format!("{}/{}", self.base_url, path).replace("//", "/");
111+
let url = format!("{}/{}", self.base_url, path.trim_start_matches('/'));
112112

113113
tracing::debug!("GET {}", url);
114114

0 commit comments

Comments
 (0)