MCPcopy Create free account
hub / github.com/SecureAI-Tools/SecureAI-Tools / indexDocuments

Function indexDocuments

apps/web/lib/fe/components/chat.tsx:276–301  ·  view source on GitHub ↗
(docs: DocumentsWithIndexingStatus[])

Source from the content-addressed store, hash-verified

274 };
275
276 const indexDocuments = async (docs: DocumentsWithIndexingStatus[]): Promise<boolean> => {
277 try {
278 // TODO: See if we can parallelize this in batches!
279 for (let i = 0; i < docs.length; i++) {
280 const doc = docs[i]!;
281 setProcessingDocumentName(doc.name);
282 await indexDocument({
283 collectionId: Id.from(chat.documentCollectionId!),
284 doc: doc,
285 onGeneratedChunk: (chunk) => {
286 if (chunk.status) {
287 setProcessingDocumentStatus(chunk.status);
288 }
289 },
290 });
291 setNumberOfProcessedDocuments(i + 1);
292 }
293 setProcessingDocumentName("");
294 setProcessingDocumentStatus("Processed all documents");
295 } catch (e) {
296 console.error("could not index documents: ", e);
297 return false;
298 }
299
300 return true;
301 };
302
303 useEffect(() => {
304 const chatTitle = chat.title;

Callers 1

ChatFunction · 0.85

Calls 2

indexDocumentFunction · 0.85
fromMethod · 0.45

Tested by

no test coverage detected