Merge pull request #279 from zandko/perf/filter-first
perf: Optimize document filtering and sorting for performance
This commit is contained in:
commit
9bb0b64044
|
@ -177,9 +177,9 @@ const createBasicRedditSearchAnsweringChain = (
|
||||||
});
|
});
|
||||||
|
|
||||||
const sortedDocs = similarity
|
const sortedDocs = similarity
|
||||||
|
.filter((sim) => sim.similarity > 0.3)
|
||||||
.sort((a, b) => b.similarity - a.similarity)
|
.sort((a, b) => b.similarity - a.similarity)
|
||||||
.slice(0, 15)
|
.slice(0, 15)
|
||||||
.filter((sim) => sim.similarity > 0.3)
|
|
||||||
.map((sim) => docsWithContent[sim.index]);
|
.map((sim) => docsWithContent[sim.index]);
|
||||||
|
|
||||||
return sortedDocs;
|
return sortedDocs;
|
||||||
|
|
|
@ -175,8 +175,8 @@ const createBasicWebSearchAnsweringChain = (
|
||||||
});
|
});
|
||||||
|
|
||||||
const sortedDocs = similarity
|
const sortedDocs = similarity
|
||||||
.sort((a, b) => b.similarity - a.similarity)
|
|
||||||
.filter((sim) => sim.similarity > 0.5)
|
.filter((sim) => sim.similarity > 0.5)
|
||||||
|
.sort((a, b) => b.similarity - a.similarity)
|
||||||
.slice(0, 15)
|
.slice(0, 15)
|
||||||
.map((sim) => docsWithContent[sim.index]);
|
.map((sim) => docsWithContent[sim.index]);
|
||||||
|
|
||||||
|
|
|
@ -177,9 +177,9 @@ const createBasicYoutubeSearchAnsweringChain = (
|
||||||
});
|
});
|
||||||
|
|
||||||
const sortedDocs = similarity
|
const sortedDocs = similarity
|
||||||
|
.filter((sim) => sim.similarity > 0.3)
|
||||||
.sort((a, b) => b.similarity - a.similarity)
|
.sort((a, b) => b.similarity - a.similarity)
|
||||||
.slice(0, 15)
|
.slice(0, 15)
|
||||||
.filter((sim) => sim.similarity > 0.3)
|
|
||||||
.map((sim) => docsWithContent[sim.index]);
|
.map((sim) => docsWithContent[sim.index]);
|
||||||
|
|
||||||
return sortedDocs;
|
return sortedDocs;
|
||||||
|
|
Loading…
Reference in New Issue