mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 22:07:10 +00:00
fix: sydney模式支持proxy
This commit is contained in:
parent
5ceb9c9de3
commit
1edfe81794
1 changed files with 9 additions and 2 deletions
|
|
@ -20,6 +20,14 @@ try {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.warn('【ChatGPT-Plugin】依赖ws未安装,可能影响Sydney模式下Bing对话,建议使用pnpm install ws安装')
|
logger.warn('【ChatGPT-Plugin】依赖ws未安装,可能影响Sydney模式下Bing对话,建议使用pnpm install ws安装')
|
||||||
}
|
}
|
||||||
|
let proxy
|
||||||
|
if (Config.proxy) {
|
||||||
|
try {
|
||||||
|
proxy = (await import('https-proxy-agent')).default
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('未安装https-proxy-agent,请在插件目录下执行pnpm add https-proxy-agent')
|
||||||
|
}
|
||||||
|
}
|
||||||
async function getWebSocket () {
|
async function getWebSocket () {
|
||||||
let WebSocket
|
let WebSocket
|
||||||
try {
|
try {
|
||||||
|
|
@ -92,7 +100,7 @@ export default class SydneyAIClient {
|
||||||
}
|
}
|
||||||
console.log(fetchOptions)
|
console.log(fetchOptions)
|
||||||
if (this.opts.proxy) {
|
if (this.opts.proxy) {
|
||||||
fetchOptions.dispatcher = new ProxyAgent(this.opts.proxy)
|
fetchOptions.agent = proxy(Config.proxy)
|
||||||
}
|
}
|
||||||
const response = await fetch(`${this.opts.host}/turing/conversation/create`, fetchOptions)
|
const response = await fetch(`${this.opts.host}/turing/conversation/create`, fetchOptions)
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
@ -178,7 +186,6 @@ export default class SydneyAIClient {
|
||||||
onProgress,
|
onProgress,
|
||||||
abortController = new AbortController()
|
abortController = new AbortController()
|
||||||
} = opts
|
} = opts
|
||||||
|
|
||||||
if (typeof onProgress !== 'function') {
|
if (typeof onProgress !== 'function') {
|
||||||
onProgress = () => {}
|
onProgress = () => {}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue