MCPcopy
hub / github.com/codedogQBY/ReadAny / triggerVectorizeBook

Function triggerVectorizeBook

packages/app/src/lib/rag/vectorize-trigger.ts:23–59  ·  view source on GitHub ↗
(
  bookId: string,
  filePath: string,
  onProgress?: VectorizeStatusCallback,
)

Source from the content-addressed store, hash-verified

21 * then delegates to the core pipeline.
22 */
23export async function triggerVectorizeBook(
24 bookId: string,
25 filePath: string,
26 onProgress?: VectorizeStatusCallback,
27): Promise<void> {
28 // Resolve managed relative paths (e.g., "books/{id}.epub") to the active desktop library root.
29 const resolvedPath = await resolveDesktopDataPath(filePath);
30
31 const vmState = useVectorModelStore.getState();
32
33 // Build platform-agnostic config from Zustand store
34 const config: VectorizeTriggerConfig = {
35 vectorModelEnabled: vmState.vectorModelEnabled,
36 vectorModelMode: vmState.vectorModelMode,
37 selectedBuiltinModelId: vmState.selectedBuiltinModelId,
38 remoteModel: (() => {
39 const selected = vmState.getSelectedVectorModel();
40 if (!selected) return null;
41 return {
42 url: selected.url,
43 apiKey: selected.apiKey,
44 modelId: selected.modelId,
45 };
46 })(),
47 };
48
49 // Build callbacks that write back to Zustand store
50 const callbacks = {
51 onBookUpdate: useLibraryStore.getState().updateBook,
52 };
53
54 // Extract chapters from the book file (platform-specific: Tauri + foliate-js)
55 const chapters = await extractBookChapters(resolvedPath);
56
57 // Delegate to core
58 await coreTriggerVectorizeBook(bookId, chapters, config, callbacks, onProgress);
59}

Callers 4

BookCard.tsxFile · 0.90
HomePageFunction · 0.90
library-store.tsFile · 0.90
openDesktopBookFunction · 0.90

Calls 2

resolveDesktopDataPathFunction · 0.90
extractBookChaptersFunction · 0.90

Tested by

no test coverage detected