feat: 支持 Microsoft Azure OpenAI, fix #7

This commit is contained in:
WJG 2024-05-26 18:09:38 +08:00
parent 8025ee4fe9
commit 3bd37b2a9d
No known key found for this signature in database
GPG Key ID: 258474EF8590014A
2 changed files with 5 additions and 5 deletions

View File

@ -1,4 +1,4 @@
import OpenAI from "openai";
import OpenAI, { AzureOpenAI } from "openai";
import {
ChatCompletionMessageParam,
ChatCompletionTool,
@ -28,10 +28,9 @@ class OpenAIClient {
private _client?: OpenAI;
private _init() {
if (!this._client) {
this._client = new OpenAI({
httpAgent: kProxyAgent,
apiKey: kEnvs.OPENAI_API_KEY!,
});
this._client = kEnvs.AZURE_OPENAI_API_KEY
? new AzureOpenAI({ httpAgent: kProxyAgent })
: new OpenAI({ httpAgent: kProxyAgent });
}
}

View File

@ -4,4 +4,5 @@ export const kEnvs: Partial<{
MI_DID: string;
OPENAI_MODEL: string;
OPENAI_API_KEY: string;
AZURE_OPENAI_API_KEY: string;
}> = process.env as any;