bug fix
All checks were successful
Deploy mindnet to llm-node / deploy (push) Successful in 4s

This commit is contained in:
Lars 2025-12-28 11:57:49 +01:00
parent aa9d388337
commit 079d988034

View File

@ -19,6 +19,7 @@ class GraphExplorerService:
self.notes_col = f"{prefix}_notes"
self.chunks_col = f"{prefix}_chunks"
self.edges_col = f"{prefix}_edges"
self._note_cache = {} # Cache für Note-Payloads
self._note_cache = {}
def get_note_with_full_content(self, note_id):
@ -459,8 +460,20 @@ class GraphExplorerService:
# Der Teil vor dem ersten "#" ist der Titel
possible_title = ref_str.split("#")[0].strip()
if possible_title:
# Normalisierungs-Funktion (wie in _find_connected_edges)
def normalize_title(t):
if not t:
return ""
t = re.sub(r'\s*\([^)]*\)', '', t)
t = re.sub(r'\s*\d{4}[\s\-]*\d{0,4}', '', t)
t = re.sub(r'^(Mein|Meine)\s+', '', t, flags=re.IGNORECASE)
t = re.sub(r'\s+', ' ', t).strip()
return t.lower()
possible_title_norm = normalize_title(possible_title)
try:
# Suche nach exaktem Titel-Match
# Versuch 3a: Exakte Titel-Suche
res, _ = self.client.scroll(
collection_name=self.notes_col,
scroll_filter=models.Filter(must=[models.FieldCondition(key="title", match=models.MatchValue(value=possible_title))]),
@ -472,16 +485,25 @@ class GraphExplorerService:
except Exception:
pass
# Fallback: Text-Suche für Fuzzy-Matching
try:
# Versuch 3b: Text-Suche (kann Teilmatches finden)
res, _ = self.client.scroll(
collection_name=self.notes_col,
scroll_filter=models.Filter(must=[models.FieldCondition(key="title", match=models.MatchText(text=possible_title))]),
limit=1, with_payload=True
limit=10, with_payload=True # Mehr Ergebnisse für Fuzzy-Matching
)
if res and res[0].payload:
self._note_cache[res[0].payload['note_id']] = res[0].payload
return res[0].payload
if res:
# Prüfe alle Ergebnisse mit normalisiertem Vergleich
for r in res:
if r.payload:
note_title = r.payload.get("title", "")
note_title_norm = normalize_title(note_title)
if note_title_norm and possible_title_norm and len(possible_title_norm) > 5:
if (note_title_norm == possible_title_norm or
note_title_norm.startswith(possible_title_norm) or
possible_title_norm.startswith(note_title_norm)):
self._note_cache[r.payload['note_id']] = r.payload
return r.payload
except Exception:
pass