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

Function vectorizeFullsheetFromMessage

fullsheet-rag.js:3784–3929  ·  view source on GitHub ↗

* Vectorize a fullsheet from message content * * @param {string} characterName - Character name * @param {string} content - Fullsheet content * @returns {Promise } Success status

(characterName, content)

Source from the content-addressed store, hash-verified

3782 } catch (error) {
3783 CarrotDebug.error('RAG vectorization error:', error);
3784 const originalHTML = button.html();
3785 button.html('<i class="fa-solid fa-xmark"></i> Failed')
3786 .css('background', 'linear-gradient(135deg, #ef4444, #dc2626)');
3787
3788 setTimeout(() => {
3789 button.html(originalHTML).css({
3790 'background': 'linear-gradient(135deg, #8b5cf6, #7c3aed)',
3791 'pointer-events': 'auto'
3792 });
3793 }, 2000);
3794
3795 if (typeof toastr !== 'undefined') {
3796 toastr.error(`Failed to vectorize fullsheet: ${error.message}`);
3797 }
3798 }
3799}
3800
3801/**
3802 * Vectorize a fullsheet from message content
3803 *
3804 * @param {string} characterName - Character name
3805 * @param {string} content - Fullsheet content
3806 * @returns {Promise<boolean>} Success status
3807 */
3808async function vectorizeFullsheetFromMessage(characterName, content) {
3809 CarrotDebug.ui('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
3810 CarrotDebug.ui('🔬 VECTORIZATION STARTED');
3811 CarrotDebug.ui(` Character: ${characterName}`);
3812 CarrotDebug.ui(` Content length: ${content.length} chars`);
3813 CarrotDebug.ui('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
3814
3815 const settings = getRAGSettings();
3816 const collectionId = generateCollectionId(characterName);
3817
3818 CarrotDebug.ui(`📋 Settings:`, {
3819 enabled: settings.enabled,
3820 simpleChunking: settings.simpleChunking,
3821 chunkSize: settings.chunkSize,
3822 chunkOverlap: settings.chunkOverlap,
3823 contextLevel: getCurrentContextLevel()
3824 });
3825 CarrotDebug.ui(`🗂️ Collection ID: ${collectionId}`);
3826
3827 try {
3828 // Step 1: Chunk the fullsheet
3829 CarrotDebug.ui('\n📦 STEP 1: Chunking fullsheet...');
3830 const chunks = chunkFullsheet(content, characterName, settings.chunkSize, settings.chunkOverlap);
3831
3832 if (!chunks || chunks.length === 0) {
3833 CarrotDebug.error('❌ STEP 1 FAILED: Chunking resulted in 0 chunks');
3834 throw new Error('Fullsheet chunking resulted in 0 chunks');
3835 }
3836
3837 CarrotDebug.ui(`✅ STEP 1 COMPLETE: Created ${chunks.length} chunks`);
3838 CarrotDebug.ui(` First chunk preview:`, chunks[0].text.substring(0, 100) + '...');
3839 CarrotDebug.ui(` Chunk hashes:`, chunks.map(c => c.hash));
3840
3841 // Step 2: Get existing hashes

Callers 2

handleRAGButtonClickFunction · 0.70
autoVectorizeMessageFunction · 0.70

Calls 11

getRAGSettingsFunction · 0.85
generateCollectionIdFunction · 0.85
chunkFullsheetFunction · 0.85
apiGetSavedHashesFunction · 0.85
apiInsertVectorItemsFunction · 0.85
ensureRagStateFunction · 0.85
getVectorSettingsFunction · 0.85
uiMethod · 0.80
errorMethod · 0.80
getCurrentContextLevelFunction · 0.70
getContextualLibraryFunction · 0.70

Tested by

no test coverage detected