MCPcopy Create free account
hub / github.com/Coneja-Chibi/CarrotKernel / apiInsertVectorItems

Function apiInsertVectorItems

fullsheet-rag.js:395–424  ·  view source on GitHub ↗

* Insert vector items into a collection

(collectionId, items)

Source from the content-addressed store, hash-verified

393 * Insert vector items into a collection
394 */
395async function apiInsertVectorItems(collectionId, items) {
396 ensureVectorConfig();
397
398 const args = await getAdditionalVectorArgs(items.map(item => item.text));
399 const body = {
400 ...getVectorsRequestBody(args),
401 collectionId: collectionId,
402 items: items.map(item => ({
403 hash: item.hash,
404 text: item.text,
405 index: item.index,
406 })),
407 source: getVectorSettings().source,
408 };
409 debugLog('[API] apiInsertVectorItems request body:', body); // ADDED
410
411 const response = await fetch('/api/vector/insert', {
412 method: 'POST',
413 headers: getRequestHeaders(),
414 credentials: 'same-origin',
415 body: JSON.stringify(body), // MODIFIED
416 });
417
418 if (!response.ok) {
419 const errorText = await response.text(); // ADDED
420 debugLog('[API] apiInsertVectorItems ERROR:', { status: response.status, text: errorText }); // ADDED
421 throw new Error(`Failed to insert vector items for collection ${collectionId}. Status: ${response.status}. Message: ${errorText}`); // MODIFIED
422 }
423 debugLog('[API] apiInsertVectorItems SUCCESS'); // ADDED
424}
425
426/**
427 * Query a vector collection

Callers 2

updateChunksInLibraryFunction · 0.85

Calls 5

ensureVectorConfigFunction · 0.85
getAdditionalVectorArgsFunction · 0.85
getVectorsRequestBodyFunction · 0.85
getVectorSettingsFunction · 0.85
debugLogFunction · 0.85

Tested by

no test coverage detected