diff --git a/src/main/services/KnowledgeService.ts b/src/main/services/KnowledgeService.ts index 89d991b5..07e588cf 100644 --- a/src/main/services/KnowledgeService.ts +++ b/src/main/services/KnowledgeService.ts @@ -13,6 +13,7 @@ import { getAllFiles } from '@main/utils/file' import type { LoaderReturn } from '@shared/config/types' import { FileType, KnowledgeBaseParams, KnowledgeItem } from '@types' import { app } from 'electron' +import { ProxyAgent, setGlobalDispatcher } from 'undici' import { v4 as uuidv4 } from 'uuid' import { proxyManager } from './ProxyManager' @@ -85,6 +86,7 @@ class KnowledgeService { _: Electron.IpcMainInvokeEvent, { base, item, forceReload = false }: { base: KnowledgeBaseParams; item: KnowledgeItem; forceReload: boolean } ): Promise => { + setGlobalDispatcher(new ProxyAgent(proxyManager.getProxyUrl() || '')) const ragApplication = await this.getRagApplication(base) const sendDirectoryProcessingPercent = (totalFiles: number, processedFiles: number) => { diff --git a/src/main/services/ProxyManager.ts b/src/main/services/ProxyManager.ts index 6a4b0fc2..5bd80fb7 100644 --- a/src/main/services/ProxyManager.ts +++ b/src/main/services/ProxyManager.ts @@ -66,6 +66,7 @@ export class ProxyManager { private async setCustomProxy(): Promise { try { if (this.config.url) { + this.proxyUrl = this.config.url this.proxyAgent = new HttpsProxyAgent(this.config.url) this.setEnvironment(this.config.url) await this.setSessionsProxy({ proxyRules: this.config.url })