Fix embeddings not at top

(only affecting the "include embeddings in normal results" option)
This commit is contained in:
DominikDoom
2023-10-02 00:16:58 +02:00
parent 3108daf0e8
commit bd0ddfbb24

View File

@@ -1158,8 +1158,14 @@ async function autocomplete(textArea, prompt, fixedTag = null) {
const aUseStats = counts.find(c => c.name === aName && c.type === a.type);
const bUseStats = counts.find(c => c.name === bName && c.type === b.type);
const aWeight = calculateUsageBias(a.count || 0, aUseStats ? aUseStats.count : 0);
const bWeight = calculateUsageBias(b.count || 0, bUseStats ? bUseStats.count : 0);
let aNoCountFallback = 0;
let bNoCountFallback = 0;
if (TAC_CFG.includeEmbeddingsInNormalResults) {
aNoCountFallback = a.type === ResultType.embedding ? Infinity : 0;
bNoCountFallback = b.type === ResultType.embedding ? Infinity : 0;
}
const aWeight = calculateUsageBias(a.count || aNoCountFallback, aUseStats ? aUseStats.count : 0);
const bWeight = calculateUsageBias(b.count || bNoCountFallback, bUseStats ? bUseStats.count : 0);
return bWeight - aWeight;
});