Implement Data Bank vectors querying

This commit is contained in:
Cohee
2024-04-17 02:09:22 +03:00
parent 4665db62f4
commit 9a1ea7f226
6 changed files with 310 additions and 16 deletions

View File

@@ -757,7 +757,7 @@ async function openAttachmentManager() {
*/
async function openWebpageScraper(target, callback) {
const template = $(await renderExtensionTemplateAsync('attachments', 'web-scrape', {}));
const link = await callGenericPopup(template, POPUP_TYPE.INPUT, '', { wide: false, large: false });
const link = await callGenericPopup(template, POPUP_TYPE.INPUT, '', { wide: false, large: false, okButton: 'Scrape', cancelButton: 'Cancel' });
if (!link) {
return;
@@ -825,7 +825,7 @@ async function openFandomScraper(target, callback) {
output = String($(this).val());
});
const confirm = await callGenericPopup(template, POPUP_TYPE.CONFIRM, '', { wide: false, large: false });
const confirm = await callGenericPopup(template, POPUP_TYPE.CONFIRM, '', { wide: false, large: false, okButton: 'Scrape', cancelButton: 'Cancel' });
if (confirm !== POPUP_RESULT.AFFIRMATIVE) {
return;
@@ -994,6 +994,19 @@ function ensureAttachmentsExist() {
}
}
/**
* Gets all currently available attachments.
* @returns {FileAttachment[]} List of attachments
*/
export function getDataBankAttachments() {
ensureAttachmentsExist();
const globalAttachments = extension_settings.attachments ?? [];
const chatAttachments = chat_metadata.attachments ?? [];
const characterAttachments = characters[this_chid]?.data?.extensions?.attachments ?? [];
return [...globalAttachments, ...chatAttachments, ...characterAttachments];
}
/**
* Probes the server to check if the Fandom plugin is available.
* @returns {Promise<boolean>} True if the plugin is available, false otherwise.