diff --git a/chat-server/src/config.ts b/chat-server/src/config.ts index 5f0c81af3..42e1e6b44 100644 --- a/chat-server/src/config.ts +++ b/chat-server/src/config.ts @@ -35,7 +35,7 @@ export const boostManual = makeBoostOnAtlasSearchFilter({ query: "snooty-docs", }, }, - k: 3, + k: 2, minScore: 0.88, }, totalMaxK: 5, diff --git a/chat-server/src/processors/makeBoostOnAtlasSearchFilter.test.ts b/chat-server/src/processors/makeBoostOnAtlasSearchFilter.test.ts index 8b481828c..777a9dbcd 100644 --- a/chat-server/src/processors/makeBoostOnAtlasSearchFilter.test.ts +++ b/chat-server/src/processors/makeBoostOnAtlasSearchFilter.test.ts @@ -11,7 +11,7 @@ describe("makeBoostOnAtlasSearchFilter()", () => { return text.split(" ").filter((s) => s !== " ").length <= 3; }, findNearestNeighborsOptions: { - k: 3, + k: 2, filter: { text: { path: "sourceName", @@ -97,16 +97,6 @@ describe("makeBoostOnAtlasSearchFilter()", () => { sourceName: "not-snooty-docs", // only important value score: 0.95, }, - { - _id: new ObjectId(), - url: "https://mongodb.com/docs/", - text: "everything you own in a box to the left", - tokenCount: 100, - embedding: [0.1, 0.2, 0.3], - updated: new Date(), - sourceName: "not-snooty-docs", // only important value - score: 0.95, - }, ]; const embedding = [0.1, 0.2, 0.3]; test("Boosts manual results", async () => { @@ -115,11 +105,12 @@ describe("makeBoostOnAtlasSearchFilter()", () => { existingResults, store: mockStore, }); - // expect(results).toHaveLength(5); - expect(results[0]).toStrictEqual(sharedResult); - expect(results[1]).toStrictEqual(mockBoostedResults[1]); - expect(results[2]).toStrictEqual(existingResults[0]); expect(results).toHaveLength(5); + expect(results[0]).toStrictEqual(existingResults[0]); + expect(results[1]).toStrictEqual(sharedResult); + expect(results[2]).toStrictEqual(existingResults[2]); + expect(results[3]).toStrictEqual(existingResults[3]); + expect(results[4]).toStrictEqual(mockBoostedResults[1]); }); }); }); diff --git a/chat-server/src/processors/makeBoostOnAtlasSearchFilter.ts b/chat-server/src/processors/makeBoostOnAtlasSearchFilter.ts index 17f4c7d7f..5eb369f7a 100644 --- a/chat-server/src/processors/makeBoostOnAtlasSearchFilter.ts +++ b/chat-server/src/processors/makeBoostOnAtlasSearchFilter.ts @@ -49,7 +49,9 @@ export function makeBoostOnAtlasSearchFilter({ (manualResult) => manualResult.text !== result.text ) ); - return [...boostedResults, ...newResults].slice(0, totalMaxK); + return [...boostedResults, ...newResults] + .sort((a, b) => b.score - a.score) + .slice(0, totalMaxK); }, }; }