Update chunking system to version 3.9.9, synchronizing parameters with the orchestrator and enhancing edge detection. Implement robust parsing to prevent duplicate edges in section propagation. Adjust comments for clarity and consistency across the codebase.

This commit is contained in:
Lars committed 2025-12-30 08:40:19 +01:00
1 parent 33dff04d47
commit 6aa6b32a6c
5 files changed
+68 -29

No files matched your search

+12 -7
View File
@@ -1,7 +1,8 @@
"""
FILE: app/core/chunking/chunking_propagation.py
DESCRIPTION: Injiziert Sektions-Kanten physisch in den Text (Embedding-Enrichment).
Fix v3.3.5: Erkennt Wikilink-Targets, um Dopplungen zu verhindern.
Fix v3.3.6: Nutzt robustes Parsing zur Erkennung vorhandener Kanten,
um Dopplungen direkt hinter [!edge] Callouts format-agnostisch zu verhindern.
"""
from typing import List, Dict, Set
from .chunking_models import Chunk
@@ -34,15 +35,19 @@ def propagate_section_edges(chunks: List[Chunk]) -> List[Chunk]:
if not edges_to_add:
continue
# Vorhandene Kanten (Typ:Ziel) in DIESEM Chunk ermitteln,
# um Dopplungen (z.B. durch Callouts) zu vermeiden.
existing_edges = parse_edges_robust(ch.text)
injections = []
for e_str in edges_to_add:
kind, target = e_str.split(':', 1)
# DER FIX: Wir prüfen, ob das Ziel (target) bereits im Text vorkommt.
# Wir suchen nach [[target]] (Callout-Stil) oder |target]] (Rel-Stil).
if f"[[{target}]]" in ch.text or f"|{target}]]" in ch.text:
# Sortierung für deterministische Ergebnisse
for e_str in sorted(list(edges_to_add)):
# Wenn die Kante (Typ + Ziel) bereits vorhanden ist (egal welches Format),
# überspringen wir die Injektion für diesen Chunk.
if e_str in existing_edges:
continue
kind, target = e_str.split(':', 1)
injections.append(f"[[rel:{kind}|{target}]]")
if injections: