mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 21:37:11 +00:00
fix: 整理了代理与反代之间的关系
This commit is contained in:
parent
ad9516d370
commit
3ee5a2f3f6
5 changed files with 49 additions and 12 deletions
|
|
@ -1,6 +1,5 @@
|
|||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { Config } from '../utils/config.js'
|
||||
import HttpsProxyAgent from 'https-proxy-agent'
|
||||
import _ from 'lodash'
|
||||
import fetch from 'node-fetch'
|
||||
let proxy
|
||||
|
|
@ -11,7 +10,7 @@ if (Config.proxy) {
|
|||
console.warn('未安装https-proxy-agent,请在插件目录下执行pnpm add https-proxy-agent')
|
||||
}
|
||||
}
|
||||
|
||||
// API3
|
||||
export class OfficialChatGPTClient {
|
||||
constructor (opts = {}) {
|
||||
const {
|
||||
|
|
@ -28,7 +27,6 @@ export class OfficialChatGPTClient {
|
|||
agent: proxy(Config.proxy)
|
||||
}
|
||||
: {}
|
||||
|
||||
const mergedOptions = {
|
||||
...defaultOptions,
|
||||
...options
|
||||
|
|
@ -50,7 +48,11 @@ export class OfficialChatGPTClient {
|
|||
if (timeoutMs) {
|
||||
abortController = new AbortController()
|
||||
}
|
||||
const url = this._apiReverseUrl || 'https://chat.openai.com/backend-api/conversation'
|
||||
let url = this._apiReverseUrl || 'https://chat.openai.com/backend-api/conversation'
|
||||
if (this._apiReverseUrl && Config.proxy && !Config.apiForceUseReverse) {
|
||||
// 如果配了proxy,而且有反代,但是没开启强制反代
|
||||
url = 'https://chat.openai.com/backend-api/conversation'
|
||||
}
|
||||
const body = {
|
||||
action,
|
||||
messages: [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue