* Vectorize a fullsheet from message content * * @param {string} characterName - Character name * @param {string} content - Fullsheet content * @returns {Promise } Success status
(characterName, content)
| 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 | */ |
| 3808 | async 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 |
no test coverage detected