Skip to content

Commit 04879b2

Browse files
committed
Add azure open ai base path for custom domains
1 parent 4488ee0 commit 04879b2

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

.env.example

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,5 @@ AZURE_OPENAI_API_KEY=your-azure-openai-api-key
3232
AZURE_OPENAI_API_INSTANCE_NAME=your-instance-name
3333
AZURE_OPENAI_API_DEPLOYMENT_NAME=your-deployment-name
3434
AZURE_OPENAI_API_VERSION=2024-08-01-preview
35-
3635
# Optional: Azure OpenAI Base Path (if using a different domain)
37-
# AZURE_OPENAI_BASE_PATH=https://your-custom-domain.com/openai/deployments
36+
# AZURE_OPENAI_API_BASE_PATH=https://your-custom-domain.com/openai/deployments

src/agent/utils.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export const initChatModelWithConfig = async (
3434
azureOpenAIApiDeploymentName:
3535
config.azureConfig.azureOpenAIApiDeploymentName,
3636
azureOpenAIApiVersion: config.azureConfig.azureOpenAIApiVersion,
37+
azureOpenAIBasePath: config.azureConfig.azureOpenAIBasePath,
3738
}
3839
: {}),
3940
});
@@ -159,14 +160,14 @@ export const getModelConfig = (
159160
azureOpenAIApiInstanceName: string;
160161
azureOpenAIApiDeploymentName: string;
161162
azureOpenAIApiVersion: string;
163+
azureOpenAIBasePath?: string;
162164
};
163165
} => {
164166
const customModelName = config.configurable?.customModelName as string;
165167
if (!customModelName) {
166168
throw new Error("Model name is missing in config.");
167169
}
168170

169-
// Handle Azure OpenAI models
170171
if (customModelName.startsWith("azure/")) {
171172
const actualModelName = customModelName.replace("azure/", "");
172173
return {
@@ -180,11 +181,11 @@ export const getModelConfig = (
180181
process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME || "",
181182
azureOpenAIApiVersion:
182183
process.env.AZURE_OPENAI_API_VERSION || "2024-08-01-preview",
184+
azureOpenAIBasePath: process.env.AZURE_OPENAI_API_BASE_PATH,
183185
},
184186
};
185187
}
186188

187-
// Handle existing model providers
188189
if (customModelName.includes("gpt-")) {
189190
return {
190191
modelName: customModelName,

0 commit comments

Comments
 (0)