diff --git a/action/index.cjs b/action/index.cjs index 037ee73..83e5823 100644 --- a/action/index.cjs +++ b/action/index.cjs @@ -150538,10 +150538,19 @@ exports.Chat = void 0; const openai_1 = __importDefault(__nccwpck_require__(60047)); class Chat { openai; + isAzure; + apiVersion; + deployment; constructor(apikey) { + this.isAzure = Boolean(process.env.AZURE_API_VERSION && process.env.AZURE_DEPLOYMENT); + this.apiVersion = process.env.AZURE_API_VERSION || ''; + this.deployment = process.env.AZURE_DEPLOYMENT || ''; + const baseURL = this.isAzure + ? `${process.env.OPENAI_API_ENDPOINT}/openai/deployments/${this.deployment}/chat/completions?api-version=${this.apiVersion}` + : process.env.OPENAI_API_ENDPOINT || 'https://api.openai.com/v1'; this.openai = new openai_1.default({ apiKey: apikey, - baseURL: process.env.OPENAI_API_ENDPOINT || 'https://api.openai.com/v1', + baseURL, }); } generatePrompt = (patch) => { @@ -150567,7 +150576,8 @@ class Chat { content: prompt, } ], - model: process.env.MODEL || 'gpt-4o-mini', + // Use model or deployment name based on the environment + model: (this.isAzure ? this.deployment : process.env.MODEL || 'gpt-4o-mini'), temperature: +(process.env.temperature || 0) || 1, top_p: +(process.env.top_p || 0) || 1, max_tokens: process.env.max_tokens diff --git a/action/src/chat.d.ts b/action/src/chat.d.ts index b292819..627bd8d 100644 --- a/action/src/chat.d.ts +++ b/action/src/chat.d.ts @@ -1,5 +1,8 @@ export declare class Chat { private openai; + private isAzure; + private apiVersion?; + private deployment?; constructor(apikey: string); private generatePrompt; codeReview: (patch: string) => Promise;