Add vector retrieval score threshold

This commit is contained in:
Cohee
2024-05-23 17:28:43 +03:00
parent 039f3b875b
commit 967a7980f5
3 changed files with 34 additions and 11 deletions

View File

@@ -52,6 +52,7 @@ const settings = {
insert: 3,
query: 2,
message_chunk_size: 400,
score_threshold: 0.25,
// For files
enabled_files: false,
@@ -760,6 +761,7 @@ async function queryCollection(collectionId, searchText, topK) {
searchText: searchText,
topK: topK,
source: settings.source,
threshold: settings.score_threshold,
}),
});
@@ -788,6 +790,7 @@ async function queryMultipleCollections(collectionIds, searchText, topK) {
searchText: searchText,
topK: topK,
source: settings.source,
threshold: settings.score_threshold,
}),
});
@@ -1310,6 +1313,12 @@ jQuery(async () => {
saveSettingsDebounced();
});
$('#vectors_score_threshold').val(settings.score_threshold).on('input', () => {
settings.score_threshold = Number($('#vectors_score_threshold').val());
Object.assign(extension_settings.vectors, settings);
saveSettingsDebounced();
});
const validSecret = !!secret_state[SECRET_KEYS.NOMICAI];
const placeholder = validSecret ? '✔️ Key saved' : '❌ Missing key';
$('#api_key_nomicai').attr('placeholder', placeholder);