feat: ConnectAI structural hardening and retrieval precision improvements
This commit is contained in:
@@ -52,12 +52,16 @@ export function selectWithinBudget(
|
||||
// 1. Sort by score descending
|
||||
const sorted = [...chunks].sort((a, b) => b.score - a.score);
|
||||
|
||||
// 2. Deduplicate by filePath
|
||||
const seen = new Set<string>();
|
||||
const deduped = sorted.filter((chunk) => {
|
||||
// 2. [Structural Fix] 파일당 청크 수 제한 완화 (Deduplication -> Multi-context)
|
||||
const fileChunkCounts = new Map<string, number>();
|
||||
const filtered = sorted.filter((chunk) => {
|
||||
const key = chunk.metadata.filePath || chunk.id;
|
||||
if (seen.has(key)) return false;
|
||||
seen.add(key);
|
||||
const count = fileChunkCounts.get(key) || 0;
|
||||
|
||||
// 파일당 최대 3개까지의 주요 맥락 허용 (정보 유실 방지)
|
||||
if (count >= 3) return false;
|
||||
|
||||
fileChunkCounts.set(key, count + 1);
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -66,7 +70,7 @@ export function selectWithinBudget(
|
||||
const dropped: RetrievalChunk[] = [];
|
||||
let tokensUsed = 0;
|
||||
|
||||
for (const chunk of deduped) {
|
||||
for (const chunk of filtered) {
|
||||
const chunkTokens = chunk.tokenEstimate || estimateTokens(chunk.content);
|
||||
|
||||
if (selected.length >= cfg.maxChunks) {
|
||||
|
||||
Reference in New Issue
Block a user