MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / chunkFile

Function chunkFile

src/context/retrieval.ts:73–86  ·  view source on GitHub ↗
(rel: string, content: string, chunkLines: number, overlap: number)

Source from the content-addressed store, hash-verified

71}
72
73export function chunkFile(rel: string, content: string, chunkLines: number, overlap: number): Chunk[] {
74 const lines = content.split('\n');
75 const out: Chunk[] = [];
76 for (let i = 0; i < lines.length; i += (chunkLines - overlap)) {
77 const start = i;
78 const end = Math.min(i + chunkLines, lines.length);
79 if (end - start < 5) continue;
80 const text = lines.slice(start, end).join('\n');
81 const hash = createHash('sha1').update(text).digest('hex').slice(0, 12);
82 out.push({ file: rel, startLine: start + 1, endLine: end, text, hash });
83 if (end >= lines.length) break;
84 }
85 return out;
86}
87
88export async function ollamaEmbed(baseUrl: string, model: string, texts: string[], signal?: AbortSignal): Promise<number[][]> {
89 const r = await fetch(`${baseUrl.replace(/\/$/, '')}/api/embed`, {

Callers 2

retrieval.test.tsFile · 0.85
buildIndexFunction · 0.85

Calls 2

updateMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected