fix: fallback to official api

This commit is contained in:
ikechan8370 2023-03-07 19:58:24 +08:00
parent 176f94f534
commit 628f57a8b0
2 changed files with 4 additions and 3 deletions

View file

@ -1,6 +1,7 @@
import fs from 'fs'
import lodash from 'lodash'
export const defaultChatGPTAPI = 'https://pimon.d201.cn/backend-api/conversation'
export const officialChatGPTAPI = 'https://apps.openai.com/api/conversation'
const defaultConfig = {
blockWords: ['屏蔽词1', '屏蔽词b'],
promptBlockWords: ['屏蔽词1', '屏蔽词b'],

View file

@ -1,5 +1,5 @@
import { v4 as uuidv4 } from 'uuid'
import {Config, defaultChatGPTAPI} from '../utils/config.js'
import {Config, defaultChatGPTAPI, officialChatGPTAPI} from '../utils/config.js'
import _ from 'lodash'
import fetch from 'node-fetch'
let proxy
@ -48,10 +48,10 @@ export class OfficialChatGPTClient {
if (timeoutMs) {
abortController = new AbortController()
}
let url = this._apiReverseUrl || defaultChatGPTAPI
let url = this._apiReverseUrl || officialChatGPTAPI
if (this._apiReverseUrl && Config.proxy && !Config.apiForceUseReverse) {
// 如果配了proxy而且有反代但是没开启强制反代
url = defaultChatGPTAPI
url = officialChatGPTAPI
}
const body = {
action,