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

This commit is contained in:
Lars 2025-12-28 18:53:11 +01:00
parent c7cd641f89
commit fdf99b2bb0

View File

@ -133,7 +133,6 @@ class GraphExplorerService:
return "\n\n".join(full_text) return "\n\n".join(full_text)
except: except:
return "Fehler beim Laden des Volltexts." return "Fehler beim Laden des Volltexts."
def _fetch_previews_for_nodes(self, node_ids): def _fetch_previews_for_nodes(self, node_ids):
""" """
Holt Batch-weise den ersten relevanten Textabschnitt für eine Liste von Nodes. Holt Batch-weise den ersten relevanten Textabschnitt für eine Liste von Nodes.
@ -193,20 +192,13 @@ class GraphExplorerService:
titles_to_check = [] titles_to_check = []
if note_title: if note_title:
titles_to_check.append(note_title) titles_to_check.append(note_title)
# Aliase laden für robuste Verlinkung
# Aliase laden für robuste Verlinkung (auch wenn note_title fehlt)
for nid in note_ids: for nid in note_ids:
note = self._fetch_note_cached(nid) note = self._fetch_note_cached(nid)
if note: if note:
# Füge Titel hinzu, falls noch nicht vorhanden
note_title_from_db = note.get("title")
if note_title_from_db and note_title_from_db not in titles_to_check:
titles_to_check.append(note_title_from_db)
# Aliase hinzufügen
aliases = note.get("aliases", []) aliases = note.get("aliases", [])
if isinstance(aliases, str): if isinstance(aliases, str): aliases = [aliases]
aliases = [aliases] titles_to_check.extend([a for a in aliases if a not in titles_to_check])
titles_to_check.extend([a for a in aliases if a and a not in titles_to_check])
# Exakte Titel-Matches hinzufügen # Exakte Titel-Matches hinzufügen
for t in titles_to_check: for t in titles_to_check:
@ -339,9 +331,8 @@ class GraphExplorerService:
self._ref_resolution_cache[ref_str] = note self._ref_resolution_cache[ref_str] = note
return note return note
# 2. Versuch: Titel-Suche (erst exakt, dann Text-Suche für Fuzzy-Matching) # 2. Versuch: Titel-Suche (Keyword-Match)
try: try:
# 2a: Exakte Übereinstimmung
res, _ = self.client.scroll( res, _ = self.client.scroll(
collection_name=self.notes_col, collection_name=self.notes_col,
scroll_filter=models.Filter(must=[ scroll_filter=models.Filter(must=[
@ -353,25 +344,6 @@ class GraphExplorerService:
payload = res[0].payload payload = res[0].payload
self._ref_resolution_cache[ref_str] = payload self._ref_resolution_cache[ref_str] = payload
return payload return payload
# 2b: Text-Suche für Fuzzy-Matching (falls exakt fehlschlägt)
res, _ = self.client.scroll(
collection_name=self.notes_col,
scroll_filter=models.Filter(must=[
models.FieldCondition(key="title", match=models.MatchText(text=base_ref))
]),
limit=10, with_payload=True
)
if res:
# Prüfe alle Ergebnisse und nimm das beste Match
for r in res:
if r.payload:
note_title = r.payload.get("title", "")
# Exakte Übereinstimmung oder beginnt mit base_ref
if note_title == base_ref or note_title.startswith(base_ref):
payload = r.payload
self._ref_resolution_cache[ref_str] = payload
return payload
except Exception: except Exception:
pass pass