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

Function vectorizeFullsheetFromMessage

index.js:139–170  ·  view source on GitHub ↗
(characterName, content)

Source from the content-addressed store, hash-verified

137async function detectFullsheetInMessage(message) {
138 await fullsheetRAGPromise;
139 return fullsheetAPI.detectFullsheetInMessage?.(message);
140}
141
142async function vectorizeFullsheetFromMessage(characterName, content) {
143 await fullsheetRAGPromise;
144
145 // Prompt user for custom collection name
146 const defaultName = characterName;
147 const customName = prompt('Enter a name for this collection:', defaultName);
148
149 // User cancelled the prompt
150 if (customName === null) {
151 toastr.info('Vectorization cancelled');
152 return false;
153 }
154
155 // Proceed with vectorization
156 const success = await fullsheetAPI.vectorizeFullsheetFromMessage?.(characterName, content) || Promise.resolve(false);
157
158 // If vectorization succeeded and user provided a custom name (different from default), save it
159 if (success && customName.trim() !== '' && customName.trim() !== defaultName) {
160 const ragState = extension_settings[extensionName]?.rag;
161 if (ragState) {
162 // We need to get the collection ID to save the custom name
163 // The collection ID is generated based on characterName and current context
164 if (globalThis.CarrotKernelFullsheetRag?.generateCollectionId) {
165 const collectionId = globalThis.CarrotKernelFullsheetRag.generateCollectionId(characterName);
166 await setCollectionName(collectionId, customName.trim());
167 CarrotDebug.ui(`Set custom name "${customName.trim()}" for collection ${collectionId}`);
168 }
169 }
170 }
171
172 return success;
173}

Callers 1

finalizeChunksFunction · 0.90

Calls 2

setCollectionNameFunction · 0.85
uiMethod · 0.80

Tested by

no test coverage detected