From 35c01777294f3098f6e2ec6cad41c848b980dfde Mon Sep 17 00:00:00 2001 From: Gianluigi Conti <13535297+glconti@users.noreply.github.com> Date: Mon, 15 Sep 2025 22:44:28 +0200 Subject: [PATCH] fix(openai): update Azure API version and improve error handling --- apps/client/src/constants/llm.ts | 2 +- .../dashboard/settings/_sections/openai.tsx | 12 +++++++----- apps/client/src/services/openai/client.ts | 16 +++++----------- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/apps/client/src/constants/llm.ts b/apps/client/src/constants/llm.ts index e33b3948..cdf23ff4 100644 --- a/apps/client/src/constants/llm.ts +++ b/apps/client/src/constants/llm.ts @@ -1,3 +1,3 @@ export const DEFAULT_MODEL = "gpt-3.5-turbo"; export const DEFAULT_MAX_TOKENS = 1024; -export const DEFAULT_AZURE_API_VERSION = "2025-01-01-preview"; +export const DEFAULT_AZURE_API_VERSION = "2024-10-21"; diff --git a/apps/client/src/pages/dashboard/settings/_sections/openai.tsx b/apps/client/src/pages/dashboard/settings/_sections/openai.tsx index cb866871..230789ad 100644 --- a/apps/client/src/pages/dashboard/settings/_sections/openai.tsx +++ b/apps/client/src/pages/dashboard/settings/_sections/openai.tsx @@ -127,7 +127,7 @@ export const OpenAISettings = () => { You can also integrate with Azure OpenAI by enabling the "Use Azure OpenAI" checkbox and setting the Resource URL to your Azure OpenAI resource (e.g., - `https://your-resource.openai.azure.com`). Set the deployment name in the Model field + https://your-resource.openai.azure.com). Set the deployment name in the Model field and specify the appropriate API version for your Azure deployment.

@@ -135,8 +135,8 @@ export const OpenAISettings = () => {

You can also integrate with Ollama simply by setting the API key to - `sk-1234567890abcdef` and the Base URL to your Ollama URL, i.e. - `http://localhost:11434/v1`. You can also pick and choose models and set the max tokens + sk-1234567890abcdef and the Base URL to your Ollama URL, i.e. + http://localhost:11434/v1. You can also pick and choose models and set the max tokens as per your preference.

@@ -228,8 +228,10 @@ export const OpenAISettings = () => { { + field.onChange(Boolean(value)); + }} />
diff --git a/apps/client/src/services/openai/client.ts b/apps/client/src/services/openai/client.ts index 34310612..5bbb6ef5 100644 --- a/apps/client/src/services/openai/client.ts +++ b/apps/client/src/services/openai/client.ts @@ -14,21 +14,15 @@ export const openai = () => { if (isAzure) { if (!baseURL) { - throw new Error( - t`Azure OpenAI Base URL is required when using Azure OpenAI.`, - ); + throw new Error(t`Azure OpenAI Base URL is required when using Azure OpenAI.`); } if (!model) { - throw new Error( - t`Azure OpenAI deployment name (model) is required when using Azure OpenAI.`, - ); + throw new Error(t`Azure OpenAI deployment name (model) is required when using Azure OpenAI.`); + } - if (!azureApiVersion) { - throw new Error( - t`Azure OpenAI API version is required when using Azure OpenAI.`, - ); - } + if (!azureApiVersion) { + throw new Error(t`Azure OpenAI API version is required when using Azure OpenAI.`); } // Construct Azure OpenAI URL: https://your-resource.openai.azure.com/openai/deployments/your-deployment