Skip to content

Commit 708b678

Browse files
committed
Merge remote-tracking branch 'origin/feat/221-rag-sources' into feat/rag-hybrid
# Conflicts: # __tests__/retrieval.test.ts # utils/hybridRetrieval.ts
2 parents d0c32fc + dadfaf5 commit 708b678

5 files changed

Lines changed: 6 additions & 12 deletions

File tree

__tests__/llmStore.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,12 @@ describe('runBenchmark', () => {
761761
await loadModel();
762762
useLLMStore.setState({ model: baseModel });
763763

764+
// The RN jest preset aliases performance.now to Date.now (1 ms resolution),
765+
// so on a fast machine startTime and the first token can share a millisecond
766+
// and the measured delta collapses to 0. Advance a virtual clock instead.
767+
let now = 0;
768+
jest.spyOn(performance, 'now').mockImplementation(() => (now += 10));
769+
764770
mockInstance.generate.mockImplementation(async () => {
765771
await flushFrame();
766772
capturedTokenCallback!('tok');

constants/citations.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@ export const CITATION_DOCUMENT_NAME_TOKEN_PATTERN = /[^a-z0-9ąćęłńóśźż]
88
export const THINK_OPEN = '<think>';
99
export const THINK_CLOSE = '</think>';
1010

11-
// English negation cues. Terms inside a negated clause say what a source does NOT
12-
// support, so they must not count as overlap evidence for citing it.
1311
export const NEGATION_CUE_EN =
1412
/\b(no|not|n[']t|never|none|neither|nor|without|lacks?|lacking)\b/i;
1513

16-
// Clause boundaries, so "covers X but does not mention Y" keeps X and drops only Y.
1714
export const CLAUSE_SPLIT_PATTERN =
1815
/[,;]|\b(?:but|however|although|though|whereas|while)\b/i;
1916

hooks/useAttachment.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@ export const useAttachment = () => {
7474
const vectorStoreRef = useRef(vectorStore);
7575
vectorStoreRef.current = vectorStore;
7676

77-
// A document is embedded as a source the moment it is attached, but it is only
78-
// tied to a chat on send. Sweep whenever one is abandoned instead, or it stays
79-
// in the store forever. cleanupOrphanedSources only removes unreferenced rows.
8077
const sweepAbandonedSources = useCallback(() => {
8178
const store = vectorStoreRef.current;
8279
if (store) useSourceStore.getState().cleanupOrphanedSources(store);

utils/embeddingModelMigration.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ export const migrateEmbeddingModelIfNeeded = async (
5252
const persistedDim = await readPersistedVectorDim(vectorStore);
5353
const incompatible =
5454
persistedDim !== null && persistedDim !== currentModelDim;
55-
// Leave the key unset when the wipe was partial so the next launch retries;
56-
// deleting again is idempotent.
5755
if (incompatible && !(await clearImportedSources(vectorStore, db))) {
5856
return true;
5957
}

utils/messageSources.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ export const visibleAnswer = (answer: string): string => {
123123
while (open !== -1) {
124124
parts.push(answer.slice(cursor, open));
125125
const close = answer.indexOf(THINK_CLOSE, open + THINK_OPEN.length);
126-
// Unterminated: the model is still reasoning, so nothing after it is visible.
127126
if (close === -1) return `${parts.join(' ')} `;
128127
cursor = close + THINK_CLOSE.length;
129128
open = answer.indexOf(THINK_OPEN, cursor);
@@ -133,9 +132,6 @@ export const visibleAnswer = (answer: string): string => {
133132
return parts.join(' ');
134133
};
135134

136-
// Keep only the clauses the reply actually asserts; a negated clause names a topic
137-
// the source does not cover, and scoring it as overlap cites the source for the
138-
// opposite of what it says. English-only for now.
139135
const affirmativeAnswer = (visibleReply: string): string =>
140136
(visibleReply.match(CITATION_SENTENCE_PATTERN) ?? [visibleReply])
141137
.flatMap((sentence) => sentence.split(CLAUSE_SPLIT_PATTERN))

0 commit comments

Comments
 (0)