Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions WebUI/electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ import { externalResourcesDir, getMediaDir } from './util.ts'
import { packagedResourcesRoot } from './aipgRoot.ts'
import { loadDemoProfile, type DemoProfile } from './demoProfile.ts'
import type { ModelPaths } from '@/assets/js/store/models.ts'
import type { IndexedDocument, EmbedInquiry } from '@/assets/js/store/textInference.ts'
import type {
IndexedDocument,
EmbedInquiry,
WarmupRequest,
PhisonKmIngestConfig,
} from '@/assets/js/store/textInference.ts'
import { BackendServiceName } from '@/assets/js/store/backendServices.ts'
import {
detectGpuHardwareDevices,
Expand Down Expand Up @@ -1275,13 +1280,15 @@ function initEventHandle() {

ipcMain.handle('getPlatform', () => process.platform)

ipcMain.handle('addDocumentToRAGList', (_event, document: IndexedDocument) => {
return handleUtilityFunction<IndexedDocument, IndexedDocument>(
'addDocumentToRAGList',
langchainChild,
document,
)
})
ipcMain.handle(
'addDocumentToRAGList',
(_event, document: IndexedDocument, phisonKmConfig?: PhisonKmIngestConfig) => {
return handleUtilityFunction<
{ document: IndexedDocument; phisonKmConfig?: PhisonKmIngestConfig },
IndexedDocument
>('addDocumentToRAGList', langchainChild, { document, phisonKmConfig })
},
)

ipcMain.handle('embedInputUsingRag', (_event, embedInquiry: EmbedInquiry) => {
return handleUtilityFunction<EmbedInquiry, KVObject>(
Expand All @@ -1291,6 +1298,14 @@ function initEventHandle() {
)
})

ipcMain.handle('warmupKVCacheForDocument', (_event, request: WarmupRequest) => {
return handleUtilityFunction<WarmupRequest, { success: boolean }>(
'warmupKVCacheForDocument',
langchainChild,
request,
)
})

ipcMain.on('openDevTools', () => {
win?.webContents.openDevTools({ mode: 'detach', activate: true })
})
Expand Down
12 changes: 10 additions & 2 deletions WebUI/electron/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { contextBridge, ipcRenderer, webUtils } from 'electron'
import pkg from '../package.json'
import { LocalSettings } from './main'
import { ModelPaths } from '@/assets/js/store/models'
import { EmbedInquiry, IndexedDocument } from '@/assets/js/store/textInference'
import {
EmbedInquiry,
IndexedDocument,
WarmupRequest,
PhisonKmIngestConfig,
} from '@/assets/js/store/textInference'

contextBridge.exposeInMainWorld('envVars', {
platformTitle: import.meta.env.VITE_PLATFORM_TITLE,
Expand Down Expand Up @@ -80,9 +85,12 @@ contextBridge.exposeInMainWorld('electronAPI', {
callback(seriveName, normalExit),
),
existsPath: (path: string) => ipcRenderer.invoke('existsPath', path),
addDocumentToRAGList: (doc: IndexedDocument) => ipcRenderer.invoke('addDocumentToRAGList', doc),
addDocumentToRAGList: (doc: IndexedDocument, phisonKmConfig?: PhisonKmIngestConfig) =>
ipcRenderer.invoke('addDocumentToRAGList', doc, phisonKmConfig),
embedInputUsingRag: (embedInquiry: EmbedInquiry) =>
ipcRenderer.invoke('embedInputUsingRag', embedInquiry),
warmupKVCacheForDocument: (request: WarmupRequest) =>
ipcRenderer.invoke('warmupKVCacheForDocument', request),
getEmbeddingServerUrl: (serviceName: string) =>
ipcRenderer.invoke('getEmbeddingServerUrl', serviceName),
getInitSetting: () => ipcRenderer.invoke('getInitSetting'),
Expand Down
Loading