Skip to content

Commit ae0caaf

Browse files
codefromthecryptTyler-Hardin
authored andcommitted
fix(providers): Azure OpenAI model listing 404 during configure (aaif-goose#7034)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
1 parent d00ddfd commit ae0caaf

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

crates/goose/src/providers/azure.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,15 @@ impl ProviderDef for AzureProvider {
8282
})?;
8383

8484
let auth_provider = AzureAuthProvider { auth };
85-
let host = format!(
86-
"{}/openai/deployments/{}",
87-
endpoint.trim_end_matches('/'),
88-
deployment_name
89-
);
85+
let host = format!("{}/openai", endpoint.trim_end_matches('/'));
9086
let api_client = ApiClient::new(host, AuthMethod::Custom(Box::new(auth_provider)))?
9187
.with_query(vec![("api-version".to_string(), api_version)]);
9288

9389
Ok(OpenAiCompatibleProvider::new(
9490
AZURE_PROVIDER_NAME.to_string(),
9591
api_client,
9692
model,
93+
format!("deployments/{}/", deployment_name),
9794
))
9895
})
9996
}

crates/goose/src/providers/openai_compatible.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,22 @@ pub struct OpenAiCompatibleProvider {
2525
/// Client targeted at the base URL (e.g. `https://api.x.ai/v1`)
2626
api_client: ApiClient,
2727
model: ModelConfig,
28+
/// Path prefix prepended to `chat/completions` (e.g. `"deployments/{name}/"` for Azure).
29+
completions_prefix: String,
2830
}
2931

3032
impl OpenAiCompatibleProvider {
31-
pub fn new(name: String, api_client: ApiClient, model: ModelConfig) -> Self {
33+
pub fn new(
34+
name: String,
35+
api_client: ApiClient,
36+
model: ModelConfig,
37+
completions_prefix: String,
38+
) -> Self {
3239
Self {
3340
name,
3441
api_client,
3542
model,
43+
completions_prefix,
3644
}
3745
}
3846

@@ -81,11 +89,12 @@ impl Provider for OpenAiCompatibleProvider {
8189
let payload = self.build_request(model_config, system, messages, tools, false)?;
8290
let mut log = RequestLog::start(model_config, &payload)?;
8391

92+
let completions_path = format!("{}chat/completions", self.completions_prefix);
8493
let response = self
8594
.with_retry(|| async {
8695
let resp = self
8796
.api_client
88-
.response_post(session_id, "chat/completions", &payload)
97+
.response_post(session_id, &completions_path, &payload)
8998
.await?;
9099
handle_response_openai_compat(resp).await
91100
})
@@ -147,11 +156,12 @@ impl Provider for OpenAiCompatibleProvider {
147156
let payload = self.build_request(&self.model, system, messages, tools, true)?;
148157
let mut log = RequestLog::start(&self.model, &payload)?;
149158

159+
let completions_path = format!("{}chat/completions", self.completions_prefix);
150160
let response = self
151161
.with_retry(|| async {
152162
let resp = self
153163
.api_client
154-
.response_post(Some(session_id), "chat/completions", &payload)
164+
.response_post(Some(session_id), &completions_path, &payload)
155165
.await?;
156166
handle_status_openai_compat(resp).await
157167
})

crates/goose/src/providers/xai.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ impl ProviderDef for XaiProvider {
6565
XAI_PROVIDER_NAME.to_string(),
6666
api_client,
6767
model,
68+
String::new(),
6869
))
6970
})
7071
}

0 commit comments

Comments
 (0)