MCPcopy Create free account
hub / github.com/SillyTavern/Extension-WebSearch / isFileExistsInDataBank

Function isFileExistsInDataBank

index.js:704–720  ·  view source on GitHub ↗

* Checks if the file for the search query already exists in the Data Bank. * @param {string} query Search query * @returns {Promise } Whether the file exists

(query)

Source from the content-addressed store, hash-verified

702 * @returns {Promise<boolean>} Whether the file exists
703 */
704async function isFileExistsInDataBank(query) {
705 try {
706 const { getDataBankAttachmentsForSource } = await import('../../../chats.js');
707 const attachments = await getDataBankAttachmentsForSource('chat');
708 const existingAttachment = attachments.find(x => x.name.startsWith(`websearch - ${query} - `));
709 if (existingAttachment) {
710 console.debug('WebSearch: file for such query already exists in the Data Bank');
711 return true;
712 }
713 return false;
714 } catch (error) {
715 // Prevent visiting links if the Data Bank is not available
716 toastr.error('Data Bank module is not available');
717 console.error('WebSearch: failed to check if the file exists in the Data Bank', error);
718 return true;
719 }
720}
721
722/**
723 * Uploads the file to the Data Bank.

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected