app/core/retriever.py aktualisiert
All checks were successful
Deploy mindnet to llm-node / deploy (push) Successful in 3s

This commit is contained in:
Lars 2025-12-04 11:16:33 +01:00
parent 1688cf0a1e
commit 110f0dbcf5

View File

@ -1,7 +1,7 @@
from __future__ import annotations from __future__ import annotations
import time import time
from typing import Any, Dict, List, Tuple, Iterable from typing import Any, Dict, List, Tuple
from app.config import get_settings from app.config import get_settings
from app.models.dto import QueryRequest, QueryResponse, QueryHit from app.models.dto import QueryRequest, QueryResponse, QueryHit
@ -141,7 +141,8 @@ def _build_hits_from_semantic(
edge_bonus = 0.0 edge_bonus = 0.0
cent_bonus = 0.0 cent_bonus = 0.0
if subgraph is not None: if subgraph is not None:
node_key = payload.get("chunk_id") or payload.get("note_id") # WICHTIG: Knoten im Graphen sind note_ids, nicht chunk_ids.
node_key = payload.get("note_id")
if node_key: if node_key:
try: try:
edge_bonus = float(subgraph.edge_bonus(node_key)) edge_bonus = float(subgraph.edge_bonus(node_key))
@ -216,10 +217,12 @@ def hybrid_retrieve(req: QueryRequest) -> QueryResponse:
depth, edge_types = _extract_expand_options(req) depth, edge_types = _extract_expand_options(req)
subgraph = None subgraph = None
if depth > 0: if depth > 0:
# Seeds: stabile IDs aus dem Payload (chunk_id bevorzugt, sonst note_id) # Seeds: stabile IDs aus dem Payload
# WICHTIG: Wir verwenden note_id als Knoten-ID, da Edges zwischen Notes
# modelliert sind (source_id/target_id = note_id).
seed_ids: List[str] = [] seed_ids: List[str] = []
for _, _score, payload in hits: for _, _score, payload in hits:
key = payload.get("chunk_id") or payload.get("note_id") key = payload.get("note_id")
if key and key not in seed_ids: if key and key not in seed_ids:
seed_ids.append(key) seed_ids.append(key)