Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Assign OpenAI model based on Azure OpenAI deployment ID (#8835)

Marshall Bowersa860530a2ef9
diff --git a/crates/assistant/src/assistant_settings.rs b/crates/assistant/src/assistant_settings.rs
index 4b8f3feb85b..007e994389d 100644
--- a/crates/assistant/src/assistant_settings.rs
+++ b/crates/assistant/src/assistant_settings.rs
@@ -111,9 +111,23 @@ impl AssistantSettings {
AiProviderSettings::OpenAi(settings) => {
Ok(settings.default_model.unwrap_or(OpenAiModel::FourTurbo))
}
- AiProviderSettings::AzureOpenAi(_settings) => {
- // TODO: We need to use an Azure OpenAI model here.
- Ok(OpenAiModel::FourTurbo)
+ AiProviderSettings::AzureOpenAi(settings) => {
+ let deployment_id = settings
+ .deployment_id
+ .as_deref()
+ .ok_or_else(|| anyhow!("no Azure OpenAI deployment ID"))?;
+
+ match deployment_id {
+ // https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models#gpt-4-and-gpt-4-turbo-preview
+ "gpt-4" | "gpt-4-32k" => Ok(OpenAiModel::Four),
+ // https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models#gpt-35
+ "gpt-35-turbo" | "gpt-35-turbo-16k" | "gpt-35-turbo-instruct" => {
+ Ok(OpenAiModel::ThreePointFiveTurbo)
+ }
+ _ => Err(anyhow!(
+ "no matching OpenAI model found for deployment ID: '{deployment_id}'"
+ )),
+ }
}
}
}