Only reindex if the size increased

This commit is contained in:
Louis Dureuil 2024-09-02 13:52:18 +02:00
parent 66bda2ce8a
commit ed19b7c3c3
No known key found for this signature in database

View File

@ -196,12 +196,23 @@ impl SettingsDiff {
ReindexAction::RegeneratePrompts,
);
}
if document_template_max_bytes.apply(new_document_template_max_bytes) {
let previous_document_template_max_bytes =
document_template_max_bytes.set().unwrap_or(default_max_bytes().get());
let new_document_template_max_bytes =
new_document_template_max_bytes.set().unwrap_or(default_max_bytes().get());
// only reindex if the size increased. Reasoning:
// - size decrease is a performance optimization, so we don't reindex and we keep the more accurate vectors
// - size increase is an accuracy optimization, so we want to reindex
if new_document_template_max_bytes > previous_document_template_max_bytes {
ReindexAction::push_action(
&mut reindex_action,
ReindexAction::RegeneratePrompts,
)
}
}
distribution.apply(new_distribution);
api_key.apply(new_api_key);