payload durchreichen bis zum chat

This commit is contained in:
Lars committed 2025-12-09 18:11:25 +01:00
1 parent bd36d78025
commit 2310633de3
3 files changed
+17 -10

No files matched your search

+10 -7
View File
@@ -2,7 +2,7 @@
app/core/retriever.py — Hybrider Such-Algorithmus
Version:
0.5.2 (WP-05 Fix: Pass content in QueryHit source)
0.5.3 (WP-06 Fix: Populate 'payload' in QueryHit for meta-data access)
"""
from __future__ import annotations
@@ -127,7 +127,9 @@ def _build_explanation(
node_key: Optional[str]
) -> Explanation:
"""Erstellt ein Explanation-Objekt."""
sem_w, edge_w, cent_w = _get_scoring_weights()
sem_w, _edge_w, _cent_w = _get_scoring_weights()
# Scoring weights erneut laden für Reason-Details
_, edge_w_cfg, cent_w_cfg = _get_scoring_weights()
try:
type_weight = float(payload.get("retriever_weight", 1.0))
@@ -138,8 +140,8 @@ def _build_explanation(
breakdown = ScoreBreakdown(
semantic_contribution=(sem_w * semantic_score * type_weight),
edge_contribution=(edge_w * edge_bonus),
centrality_contribution=(cent_w * cent_bonus),
edge_contribution=(edge_w_cfg * edge_bonus),
centrality_contribution=(cent_w_cfg * cent_bonus),
raw_semantic=semantic_score,
raw_edge_bonus=edge_bonus,
raw_centrality=cent_bonus,
@@ -179,7 +181,7 @@ def _build_explanation(
all_edges = sorted(edges_dto, key=lambda e: e.weight, reverse=True)
for top_edge in all_edges[:3]:
impact = edge_w * top_edge.weight
impact = edge_w_cfg * top_edge.weight
dir_txt = "Verweist auf" if top_edge.direction == "out" else "Referenziert von"
tgt_txt = top_edge.target if top_edge.direction == "out" else top_edge.source
reasons.append(Reason(kind="edge", message=f"{dir_txt} '{tgt_txt}' via '{top_edge.kind}'", score_impact=impact, details={"kind": top_edge.kind}))
@@ -261,7 +263,6 @@ def _build_hits_from_semantic(
node_key=payload.get("chunk_id") or payload.get("note_id")
)
# FIX: Hier holen wir jetzt den Textinhalt (text, content oder page_content) aus dem Payload
text_content = payload.get("page_content") or payload.get("text") or payload.get("content")
results.append(QueryHit(
@@ -275,8 +276,10 @@ def _build_hits_from_semantic(
source={
"path": payload.get("path"),
"section": payload.get("section") or payload.get("section_title"),
"text": text_content # WICHTIG: Inhalt durchreichen
"text": text_content
},
# --- FIX: Wir füllen das payload-Feld explizit ---
payload=payload,
explanation=explanation_obj
))