mirror of
https://github.com/ILoveBingLu/CipherTalk.git
synced 2026-05-13 07:31:35 +08:00
a8c0d27dd3
- 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.
40 lines
930 B
TypeScript
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()
|