@sentry/junior-memory 0.132.0 → 0.133.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +34 -8
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/store.ts +41 -10
package/dist/index.js
CHANGED
|
@@ -345,6 +345,8 @@ var DEFAULT_EXPIRED_ARCHIVE_LIMIT = 100;
|
|
|
345
345
|
var PREFERENCE_ADJUDICATION_CANDIDATE_LIMIT = 10;
|
|
346
346
|
var PREFERENCE_ADJUDICATION_VECTOR_LIMIT = 5;
|
|
347
347
|
var VECTOR_SEARCH_OVERFETCH = 4;
|
|
348
|
+
var LEXICAL_RANK_OVERFETCH = 4;
|
|
349
|
+
var MAX_LEXICAL_RANK_CANDIDATES = 1e3;
|
|
348
350
|
var MAX_MEMORY_CONTENT_CHARS = 4e3;
|
|
349
351
|
var EMBEDDING_METRIC = "cosine";
|
|
350
352
|
var nonEmptyStringSchema2 = z2.string().min(1);
|
|
@@ -903,16 +905,40 @@ async function searchVisibleLexicalMemories(args) {
|
|
|
903
905
|
)
|
|
904
906
|
FROM unnest(tsvector_to_array(${queryVector})) AS query_terms(term)
|
|
905
907
|
)`;
|
|
906
|
-
const
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
908
|
+
const candidateLimit = Math.min(
|
|
909
|
+
MAX_LEXICAL_RANK_CANDIDATES,
|
|
910
|
+
args.limit * LEXICAL_RANK_OVERFETCH
|
|
911
|
+
);
|
|
912
|
+
const candidates = args.db.select().from(juniorMemoryMemories).where(
|
|
913
|
+
and(predicate, sql2`${juniorMemoryMemories.searchVector} @@ ${tsquery}`)
|
|
914
|
+
).orderBy(
|
|
913
915
|
desc(juniorMemoryMemories.observedAtMs),
|
|
914
916
|
asc(juniorMemoryMemories.id)
|
|
915
|
-
).limit(
|
|
917
|
+
).limit(candidateLimit).as("lexical_candidates");
|
|
918
|
+
const textRank = sql2`ts_rank_cd(${candidates.searchVector}, ${tsquery})`;
|
|
919
|
+
const rows = await args.db.select({
|
|
920
|
+
memory: {
|
|
921
|
+
archiveReason: candidates.archiveReason,
|
|
922
|
+
archivedAtMs: candidates.archivedAtMs,
|
|
923
|
+
content: candidates.content,
|
|
924
|
+
createdAtMs: candidates.createdAtMs,
|
|
925
|
+
expiresAtMs: candidates.expiresAtMs,
|
|
926
|
+
id: candidates.id,
|
|
927
|
+
idempotencyKey: candidates.idempotencyKey,
|
|
928
|
+
kind: candidates.kind,
|
|
929
|
+
observedAtMs: candidates.observedAtMs,
|
|
930
|
+
scope: candidates.scope,
|
|
931
|
+
scopeKey: candidates.scopeKey,
|
|
932
|
+
searchVector: candidates.searchVector,
|
|
933
|
+
sourceKey: candidates.sourceKey,
|
|
934
|
+
sourcePlatform: candidates.sourcePlatform,
|
|
935
|
+
subjectKey: candidates.subjectKey,
|
|
936
|
+
subjectType: candidates.subjectType,
|
|
937
|
+
supersededAtMs: candidates.supersededAtMs,
|
|
938
|
+
supersededById: candidates.supersededById
|
|
939
|
+
},
|
|
940
|
+
textRank
|
|
941
|
+
}).from(candidates).orderBy(desc(textRank), desc(candidates.observedAtMs), asc(candidates.id)).limit(args.limit);
|
|
916
942
|
const ranks = denseRanks(rows, (row) => Number(row.textRank));
|
|
917
943
|
return rows.map((row, index2) => ({
|
|
918
944
|
lexical: { rank: ranks[index2] },
|