|
5 | 5 | import { CUSTOM_PROVIDERS } from '@tm/core'; |
6 | 6 | import chalk from 'chalk'; |
7 | 7 | import inquirer from 'inquirer'; |
| 8 | +import { getAzureBaseURL } from '../../lib/model-management.js'; |
8 | 9 | import { validateOllamaModel, validateOpenRouterModel } from './fetchers.js'; |
9 | 10 | import { CUSTOM_PROVIDER_IDS } from './types.js'; |
10 | 11 | import type { |
@@ -86,18 +87,16 @@ export const customProviderConfigs: Record< |
86 | 87 | }, |
87 | 88 | AZURE: { |
88 | 89 | id: '__CUSTOM_AZURE__', |
89 | | - name: '* Custom Azure model', |
| 90 | + name: '* Custom Azure OpenAI model', |
90 | 91 | provider: CUSTOM_PROVIDERS.AZURE, |
| 92 | + requiresBaseURL: true, |
91 | 93 | promptMessage: (role) => |
92 | | - `Enter the custom Azure OpenAI Model ID for the ${role} role (e.g., gpt-4o):`, |
| 94 | + `Enter the Azure deployment name for the ${role} role (e.g., gpt-4o):`, |
93 | 95 | checkEnvVars: () => { |
94 | | - if ( |
95 | | - !process.env.AZURE_OPENAI_API_KEY || |
96 | | - !process.env.AZURE_OPENAI_ENDPOINT |
97 | | - ) { |
| 96 | + if (!process.env.AZURE_OPENAI_API_KEY) { |
98 | 97 | console.error( |
99 | 98 | chalk.red( |
100 | | - 'Error: AZURE_OPENAI_API_KEY and/or AZURE_OPENAI_ENDPOINT environment variables are missing. Please set them before using custom Azure models.' |
| 99 | + 'Error: AZURE_OPENAI_API_KEY environment variable is missing. Please set it before using Azure models.' |
101 | 100 | ) |
102 | 101 | ); |
103 | 102 | return false; |
@@ -171,7 +170,8 @@ export async function handleCustomProvider( |
171 | 170 | modelId?: string | null; |
172 | 171 | provider?: string | null; |
173 | 172 | baseURL?: string | null; |
174 | | - } | null = null |
| 173 | + } | null = null, |
| 174 | + projectRoot?: string |
175 | 175 | ): Promise<{ |
176 | 176 | modelId: string | null; |
177 | 177 | provider: string | null; |
@@ -203,6 +203,9 @@ export async function handleCustomProvider( |
203 | 203 | if (currentModel?.provider === config.provider && currentModel?.baseURL) { |
204 | 204 | // Already using this provider - preserve existing baseURL |
205 | 205 | defaultBaseURL = currentModel.baseURL; |
| 206 | + } else if (config.provider === CUSTOM_PROVIDERS.AZURE && projectRoot) { |
| 207 | + // For Azure, try to use the global azureBaseURL from config |
| 208 | + defaultBaseURL = getAzureBaseURL(projectRoot) || ''; |
206 | 209 | } else { |
207 | 210 | // Switching providers or no existing baseURL - use fallback default |
208 | 211 | defaultBaseURL = config.defaultBaseURL || ''; |
|
0 commit comments