Files
CipherTalk/electron/sessionVectorIndexWorker.ts
T
ILoveBingLu a8c0d27dd3 feat: add session and keyword statistics to MCP and AI services
- Introduced new tools: `get_session_statistics` and `get_keyword_statistics` in MCP.
- Added interfaces for session and keyword statistics, including detailed participant and message metrics.
- Updated `ChatSearchIndexService` to handle vector indexing with improved batching and idle time management.
- Enhanced `LocalEmbeddingModelService` to optimize CPU threading for embedding models.
- Implemented cancellation handling for vector indexing in `sessionVectorIndexWorker`.
- Improved UI components in `AISummaryWindow` and `ChatPage` for displaying evidence and vector indexing status.
- Added styles for vector indexing buttons and badges in `ChatPage.scss`.
- Updated AI types to include new session and keyword statistics events.
2026-04-26 20:46:15 +08:00

40 lines
930 B
TypeScript

import { parentPort, workerData } from 'worker_threads'
import { chatSearchIndexService } from './services/search/chatSearchIndexService'
type VectorWorkerData = {
sessionId: string
}
const data = workerData as VectorWorkerData
parentPort?.on('message', (message: { type?: string }) => {
if (message?.type === 'cancel') {
chatSearchIndexService.cancelSessionVectorIndex(data.sessionId)
}
})
async function run() {
try {
const state = await chatSearchIndexService.prepareSessionVectorIndex(data.sessionId, (progress) => {
parentPort?.postMessage({
type: 'progress',
sessionId: data.sessionId,
progress
})
})
parentPort?.postMessage({
type: 'completed',
sessionId: data.sessionId,
state
})
} catch (error) {
parentPort?.postMessage({
type: 'error',
sessionId: data.sessionId,
error: String(error)
})
}
}
void run()