xiongzhu 2 лет назад
Родитель
Сommit
3db2920027
4 измененных файлов с 9 добавлено и 2 удалено
  1. 1 1
      .env
  2. 1 0
      src/chat/chatgpt/index.ts
  3. 5 1
      src/chatapi/chatgpt-api.ts
  4. 2 0
      src/chatapi/types.ts

+ 1 - 1
.env

@@ -62,7 +62,7 @@ AZURE_EMBEDDING_DEPLOYMENT=embedding
 AZURE_EMBEDDING_VERSION=2023-03-15-preview
 
 OPENAI_API_KEY=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
-OPENAI_BASE_URL=https://openai.c8c.top/v1
+OPENAI_BASE_URL=https://gateway.ai.cloudflare.com/v1/cc11bed478e65817d30878b0a796422d/openai-gateway/openai
 
 
 WX_APP_ID=wx34f699b80d6f90e7

+ 1 - 0
src/chat/chatgpt/index.ts

@@ -38,6 +38,7 @@ let api: ChatGPTAPI | ChatGPTUnofficialProxyAPI
         const options: ChatGPTAPIOptions = {
             apiKey: process.env.AZURE_OPENAI_KEY,
             apiEndpoint: process.env.AZURE_OPENAI_ENDPOINT,
+            apiInstance: process.env.AZURE_OPENAI_INSTANCE,
             apiDeployment: process.env.AZURE_OPENAI_DEPLOYMENT,
             apiVersion: process.env.AZURE_OPENAI_VERSION,
             completionParams: { model },

+ 5 - 1
src/chatapi/chatgpt-api.ts

@@ -14,6 +14,7 @@ const ASSISTANT_LABEL_DEFAULT = 'ChatGPT'
 
 export class ChatGPTAPI {
     protected _apiKey: string
+    protected _apiInstance: string
     protected _apiEndpoint: string
     protected _apiDeployment: string
     protected _apiVersion: string
@@ -50,6 +51,7 @@ export class ChatGPTAPI {
         const {
             apiKey,
             apiEndpoint,
+            apiInstance,
             apiDeployment,
             apiVersion,
             apiOrg,
@@ -66,6 +68,7 @@ export class ChatGPTAPI {
 
         this._apiKey = apiKey
         this._apiEndpoint = apiEndpoint
+        this._apiInstance = apiInstance
         this._apiDeployment = apiDeployment
         this._apiVersion = apiVersion
         this._apiOrg = apiOrg
@@ -176,7 +179,8 @@ export class ChatGPTAPI {
         }
 
         const responseP = new Promise<types.ChatMessage>(async (resolve, reject) => {
-            const url = `${this._apiEndpoint}/openai/deployments/${this._apiDeployment}/chat/completions?api-version=${this._apiVersion}`
+            // const url = `${this._apiEndpoint}/openai/deployments/${this._apiDeployment}/chat/completions?api-version=${this._apiVersion}`
+            const url = `https://gateway.ai.cloudflare.com/v1/cc11bed478e65817d30878b0a796422d/openai-gateway/azure-openai/${this._apiInstance}/${this._apiDeployment}/chat/completions?api-version=${this._apiVersion}`
             const headers = {
                 'Content-Type': 'application/json',
                 'api-key': `${this._apiKey}`

+ 2 - 0
src/chatapi/types.ts

@@ -9,6 +9,8 @@ export type ChatGPTAPIOptions = {
 
     apiEndpoint: string
 
+    apiInstance: string
+
     apiDeployment: string
 
     apiVersion: string