Skip to content

Commit 12a11df

Browse files
committedNov 8, 2024
build
1 parent 289d6c4 commit 12a11df

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed
 

‎action/index.cjs

+12-2
Original file line numberDiff line numberDiff line change
@@ -150538,10 +150538,19 @@ exports.Chat = void 0;
150538150538
const openai_1 = __importDefault(__nccwpck_require__(60047));
150539150539
class Chat {
150540150540
openai;
150541+
isAzure;
150542+
apiVersion;
150543+
deployment;
150541150544
constructor(apikey) {
150545+
this.isAzure = Boolean(process.env.AZURE_API_VERSION && process.env.AZURE_DEPLOYMENT);
150546+
this.apiVersion = process.env.AZURE_API_VERSION || '';
150547+
this.deployment = process.env.AZURE_DEPLOYMENT || '';
150548+
const baseURL = this.isAzure
150549+
? `${process.env.OPENAI_API_ENDPOINT}/openai/deployments/${this.deployment}/chat/completions?api-version=${this.apiVersion}`
150550+
: process.env.OPENAI_API_ENDPOINT || 'https://api.openai.com/v1';
150542150551
this.openai = new openai_1.default({
150543150552
apiKey: apikey,
150544-
baseURL: process.env.OPENAI_API_ENDPOINT || 'https://api.openai.com/v1',
150553+
baseURL,
150545150554
});
150546150555
}
150547150556
generatePrompt = (patch) => {
@@ -150567,7 +150576,8 @@ class Chat {
150567150576
content: prompt,
150568150577
}
150569150578
],
150570-
model: process.env.MODEL || 'gpt-4o-mini',
150579+
// Use model or deployment name based on the environment
150580+
model: (this.isAzure ? this.deployment : process.env.MODEL || 'gpt-4o-mini'),
150571150581
temperature: +(process.env.temperature || 0) || 1,
150572150582
top_p: +(process.env.top_p || 0) || 1,
150573150583
max_tokens: process.env.max_tokens

‎action/src/chat.d.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
export declare class Chat {
22
private openai;
3+
private isAzure;
4+
private apiVersion?;
5+
private deployment?;
36
constructor(apikey: string);
47
private generatePrompt;
58
codeReview: (patch: string) => Promise<string | null>;

0 commit comments

Comments
 (0)
Failed to load comments.