bugfix
This commit is contained in:
1 parent
d2ee48555a
commit
a7cda3f51c
3 files changed
+102
-63
No files matched your search
@@ -102,9 +102,12 @@ class DiscoveryService:
|
||||
path = os.getenv("MINDNET_TYPES_FILE", "config/types.yaml")
|
||||
if not os.path.exists(path):
|
||||
# Fallback relative Pfade
|
||||
if os.path.exists("types.yaml"): path = "types.yaml"
|
||||
elif os.path.exists("../config/types.yaml"): path = "../config/types.yaml"
|
||||
else: return {}
|
||||
if os.path.exists("types.yaml"):
|
||||
path = "types.yaml"
|
||||
elif os.path.exists("../config/types.yaml"):
|
||||
path = "../config/types.yaml"
|
||||
else:
|
||||
return {}
|
||||
|
||||
try:
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
@@ -132,7 +135,7 @@ class DiscoveryService:
|
||||
# 3. Fallback, falls nichts konfiguriert ist
|
||||
return "related_to"
|
||||
|
||||
# --- Core Logic (Unverändert) ---
|
||||
# --- Core Logic ---
|
||||
|
||||
def _fetch_all_titles_and_aliases(self) -> List[Dict]:
|
||||
notes = []
|
||||
@@ -150,15 +153,19 @@ class DiscoveryService:
|
||||
)
|
||||
for point in res:
|
||||
pl = point.payload or {}
|
||||
|
||||
# Aliases robust lesen (kann Liste oder String sein)
|
||||
aliases = pl.get("aliases") or []
|
||||
if isinstance(aliases, str): aliases = [aliases]
|
||||
if isinstance(aliases, str):
|
||||
aliases = [aliases]
|
||||
|
||||
notes.append({
|
||||
"id": pl.get("note_id"),
|
||||
"title": pl.get("title"),
|
||||
"aliases": aliases
|
||||
})
|
||||
if next_page is None: break
|
||||
if next_page is None:
|
||||
break
|
||||
except Exception as e:
|
||||
logger.error(f"Error fetching titles: {e}")
|
||||
return []
|
||||
@@ -168,14 +175,25 @@ class DiscoveryService:
|
||||
found = []
|
||||
text_lower = text.lower()
|
||||
for entity in entities:
|
||||
# 1. Title Match
|
||||
title = entity.get("title")
|
||||
if title and title.lower() in text_lower:
|
||||
found.append({"match": title, "title": title, "id": entity["id"]})
|
||||
found.append({
|
||||
"match": title,
|
||||
"title": title,
|
||||
"id": entity["id"]
|
||||
})
|
||||
continue
|
||||
|
||||
# 2. Alias Match
|
||||
aliases = entity.get("aliases", [])
|
||||
for alias in aliases:
|
||||
if alias and str(alias).lower() in text_lower:
|
||||
found.append({"match": alias, "title": title, "id": entity["id"]})
|
||||
found.append({
|
||||
"match": alias,
|
||||
"title": title,
|
||||
"id": entity["id"]
|
||||
})
|
||||
break
|
||||
return found
|
||||
|
||||
@@ -184,5 +202,6 @@ class DiscoveryService:
|
||||
try:
|
||||
res = hybrid_retrieve(req)
|
||||
return res.results
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
logger.error(f"Semantic suggestion error: {e}")
|
||||
return []
|
||||
Reference in new issue
Block a user