fix(providers): Azure OpenAI model listing 404 during configure (#7034)

Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
Adrian Cole
2026-02-06 18:25:30 +08:00
committed by GitHub
parent 59f5958f0e
commit d039f3f6f3
3 changed files with 16 additions and 8 deletions
+2 -5
View File
@@ -82,11 +82,7 @@ impl ProviderDef for AzureProvider {
})?; })?;
let auth_provider = AzureAuthProvider { auth }; let auth_provider = AzureAuthProvider { auth };
let host = format!( let host = format!("{}/openai", endpoint.trim_end_matches('/'));
"{}/openai/deployments/{}",
endpoint.trim_end_matches('/'),
deployment_name
);
let api_client = ApiClient::new(host, AuthMethod::Custom(Box::new(auth_provider)))? let api_client = ApiClient::new(host, AuthMethod::Custom(Box::new(auth_provider)))?
.with_query(vec![("api-version".to_string(), api_version)]); .with_query(vec![("api-version".to_string(), api_version)]);
@@ -94,6 +90,7 @@ impl ProviderDef for AzureProvider {
AZURE_PROVIDER_NAME.to_string(), AZURE_PROVIDER_NAME.to_string(),
api_client, api_client,
model, model,
format!("deployments/{}/", deployment_name),
)) ))
}) })
} }
@@ -25,14 +25,22 @@ pub struct OpenAiCompatibleProvider {
/// Client targeted at the base URL (e.g. `https://api.x.ai/v1`) /// Client targeted at the base URL (e.g. `https://api.x.ai/v1`)
api_client: ApiClient, api_client: ApiClient,
model: ModelConfig, model: ModelConfig,
/// Path prefix prepended to `chat/completions` (e.g. `"deployments/{name}/"` for Azure).
completions_prefix: String,
} }
impl OpenAiCompatibleProvider { impl OpenAiCompatibleProvider {
pub fn new(name: String, api_client: ApiClient, model: ModelConfig) -> Self { pub fn new(
name: String,
api_client: ApiClient,
model: ModelConfig,
completions_prefix: String,
) -> Self {
Self { Self {
name, name,
api_client, api_client,
model, model,
completions_prefix,
} }
} }
@@ -81,11 +89,12 @@ impl Provider for OpenAiCompatibleProvider {
let payload = self.build_request(model_config, system, messages, tools, false)?; let payload = self.build_request(model_config, system, messages, tools, false)?;
let mut log = RequestLog::start(model_config, &payload)?; let mut log = RequestLog::start(model_config, &payload)?;
let completions_path = format!("{}chat/completions", self.completions_prefix);
let response = self let response = self
.with_retry(|| async { .with_retry(|| async {
let resp = self let resp = self
.api_client .api_client
.response_post(session_id, "chat/completions", &payload) .response_post(session_id, &completions_path, &payload)
.await?; .await?;
handle_response_openai_compat(resp).await handle_response_openai_compat(resp).await
}) })
@@ -147,11 +156,12 @@ impl Provider for OpenAiCompatibleProvider {
let payload = self.build_request(&self.model, system, messages, tools, true)?; let payload = self.build_request(&self.model, system, messages, tools, true)?;
let mut log = RequestLog::start(&self.model, &payload)?; let mut log = RequestLog::start(&self.model, &payload)?;
let completions_path = format!("{}chat/completions", self.completions_prefix);
let response = self let response = self
.with_retry(|| async { .with_retry(|| async {
let resp = self let resp = self
.api_client .api_client
.response_post(Some(session_id), "chat/completions", &payload) .response_post(Some(session_id), &completions_path, &payload)
.await?; .await?;
handle_status_openai_compat(resp).await handle_status_openai_compat(resp).await
}) })
+1
View File
@@ -65,6 +65,7 @@ impl ProviderDef for XaiProvider {
XAI_PROVIDER_NAME.to_string(), XAI_PROVIDER_NAME.to_string(),
api_client, api_client,
model, model,
String::new(),
)) ))
}) })
} }