mirror of
https://github.com/idootop/mi-gpt.git
synced 2024-09-20 14:56:14 +00:00
feat: 支持 Microsoft Azure OpenAI, fix #7
This commit is contained in:
parent
8025ee4fe9
commit
3bd37b2a9d
|
@ -1,4 +1,4 @@
|
||||||
import OpenAI from "openai";
|
import OpenAI, { AzureOpenAI } from "openai";
|
||||||
import {
|
import {
|
||||||
ChatCompletionMessageParam,
|
ChatCompletionMessageParam,
|
||||||
ChatCompletionTool,
|
ChatCompletionTool,
|
||||||
|
@ -28,10 +28,9 @@ class OpenAIClient {
|
||||||
private _client?: OpenAI;
|
private _client?: OpenAI;
|
||||||
private _init() {
|
private _init() {
|
||||||
if (!this._client) {
|
if (!this._client) {
|
||||||
this._client = new OpenAI({
|
this._client = kEnvs.AZURE_OPENAI_API_KEY
|
||||||
httpAgent: kProxyAgent,
|
? new AzureOpenAI({ httpAgent: kProxyAgent })
|
||||||
apiKey: kEnvs.OPENAI_API_KEY!,
|
: new OpenAI({ httpAgent: kProxyAgent });
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,4 +4,5 @@ export const kEnvs: Partial<{
|
||||||
MI_DID: string;
|
MI_DID: string;
|
||||||
OPENAI_MODEL: string;
|
OPENAI_MODEL: string;
|
||||||
OPENAI_API_KEY: string;
|
OPENAI_API_KEY: string;
|
||||||
|
AZURE_OPENAI_API_KEY: string;
|
||||||
}> = process.env as any;
|
}> = process.env as any;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user