From 04879b23f7122a9cae4ea3499cb62f357ec5dcc4 Mon Sep 17 00:00:00 2001 From: punitda Date: Mon, 4 Nov 2024 16:45:53 +0530 Subject: [PATCH] Add azure open ai base path for custom domains --- .env.example | 3 +-- src/agent/utils.ts | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index cab2f8a0..bf161162 100644 --- a/.env.example +++ b/.env.example @@ -32,6 +32,5 @@ AZURE_OPENAI_API_KEY=your-azure-openai-api-key AZURE_OPENAI_API_INSTANCE_NAME=your-instance-name AZURE_OPENAI_API_DEPLOYMENT_NAME=your-deployment-name AZURE_OPENAI_API_VERSION=2024-08-01-preview - # Optional: Azure OpenAI Base Path (if using a different domain) -# AZURE_OPENAI_BASE_PATH=https://your-custom-domain.com/openai/deployments +# AZURE_OPENAI_API_BASE_PATH=https://your-custom-domain.com/openai/deployments diff --git a/src/agent/utils.ts b/src/agent/utils.ts index 6e9d06b7..0efe1d49 100644 --- a/src/agent/utils.ts +++ b/src/agent/utils.ts @@ -34,6 +34,7 @@ export const initChatModelWithConfig = async ( azureOpenAIApiDeploymentName: config.azureConfig.azureOpenAIApiDeploymentName, azureOpenAIApiVersion: config.azureConfig.azureOpenAIApiVersion, + azureOpenAIBasePath: config.azureConfig.azureOpenAIBasePath, } : {}), }); @@ -159,6 +160,7 @@ export const getModelConfig = ( azureOpenAIApiInstanceName: string; azureOpenAIApiDeploymentName: string; azureOpenAIApiVersion: string; + azureOpenAIBasePath?: string; }; } => { const customModelName = config.configurable?.customModelName as string; @@ -166,7 +168,6 @@ export const getModelConfig = ( throw new Error("Model name is missing in config."); } - // Handle Azure OpenAI models if (customModelName.startsWith("azure/")) { const actualModelName = customModelName.replace("azure/", ""); return { @@ -180,11 +181,11 @@ export const getModelConfig = ( process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME || "", azureOpenAIApiVersion: process.env.AZURE_OPENAI_API_VERSION || "2024-08-01-preview", + azureOpenAIBasePath: process.env.AZURE_OPENAI_API_BASE_PATH, }, }; } - // Handle existing model providers if (customModelName.includes("gpt-")) { return { modelName: customModelName,