mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 21:37:11 +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) {
|
||||
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 () {
|
||||
let WebSocket
|
||||
try {
|
||||
|
|
@ -92,7 +100,7 @@ export default class SydneyAIClient {
|
|||
}
|
||||
console.log(fetchOptions)
|
||||
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)
|
||||
return response.json()
|
||||
|
|
@ -178,7 +186,6 @@ export default class SydneyAIClient {
|
|||
onProgress,
|
||||
abortController = new AbortController()
|
||||
} = opts
|
||||
|
||||
if (typeof onProgress !== 'function') {
|
||||
onProgress = () => {}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue