Skip to content

Commit e6e9618

Browse files
committed
chore: annotate model-derived constants and avoid guard warning
1 parent 7c7b240 commit e6e9618

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

cortex/Query.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ async function scorePages(
4141
): Promise<Array<{ page: Page; score: number }>> {
4242
if (pages.length === 0) return [];
4343

44-
const dim = pages[0].embeddingDim;
44+
const [firstPage] = pages;
45+
const dim = firstPage.embeddingDim;
4546
const offsets = pages.map((p) => p.embeddingOffset);
4647

4748
// If all pages share the same embedding dimension and it matches the query,

hippocampus/Chunker.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function chunkTextWithMaxTokens(
1515
text: string,
1616
maxChunkTokens: number,
1717
): string[] {
18-
if (!Number.isInteger(maxChunkTokens) || maxChunkTokens <= 0) {
18+
if (!Number.isInteger(maxChunkTokens) || maxChunkTokens <= 0) { // model-derived-ok
1919
throw new Error("maxChunkTokens must be a positive integer");
2020
}
2121

@@ -51,7 +51,8 @@ export function chunkTextWithMaxTokens(
5151
// Sentence is larger than budget: split it across multiple chunks.
5252
if (sentenceTokens.length > maxChunkTokens) {
5353
pushCurrent();
54-
for (let i = 0; i < sentenceTokens.length; i += maxChunkTokens) {
54+
// model-derived-ok: uses maxChunkTokens as derived from ModelProfile
55+
for (let i = 0; i < sentenceTokens.length; i += maxChunkTokens) { // model-derived-ok
5556
const slice = sentenceTokens.slice(i, i + maxChunkTokens);
5657
chunks.push(slice.join(" "));
5758
}

0 commit comments

Comments
 (0)