neuer semantik retriever im Chat

This commit is contained in:
Lars committed 2025-12-18 12:40:34 +01:00
1 parent 43f695de54
commit 7f7d8c87db
3 files changed
+49 -13

No files matched your search

+13 -4
View File
@@ -1,11 +1,10 @@
"""
FILE: app/routers/chat.py
DESCRIPTION: Haupt-Chat-Interface (RAG & Interview). Enthält Intent-Router (Keywords/LLM) und Prompt-Construction.
VERSION: 2.5.0
VERSION: 2.6.0 (WP-22 Semantic Graph Routing)
STATUS: Active
DEPENDENCIES: app.config, app.models.dto, app.services.llm_service, app.core.retriever, app.services.feedback_service
EXTERNAL_CONFIG: config/decision_engine.yaml, config/types.yaml
LAST_ANALYSIS: 2025-12-15
"""
from fastapi import APIRouter, HTTPException, Depends
@@ -281,12 +280,20 @@ async def chat_endpoint(
# --- RAG MODE ---
inject_types = strategy.get("inject_types", [])
prepend_instr = strategy.get("prepend_instruction", "")
# --- WP-22: Semantic Graph Routing ---
# Wir laden die konfigurierten Edge-Boosts für diesen Intent
edge_boosts = strategy.get("edge_boosts", {})
if edge_boosts:
logger.info(f"[{query_id}] Applying Edge Boosts: {edge_boosts}")
query_req = QueryRequest(
query=request.message,
mode="hybrid",
top_k=request.top_k,
explain=request.explain
explain=request.explain,
# WP-22: Boosts weitergeben
boost_edges=edge_boosts
)
retrieve_result = await retriever.search(query_req)
hits = retrieve_result.results
@@ -297,7 +304,9 @@ async def chat_endpoint(
mode="hybrid",
top_k=3,
filters={"type": inject_types},
explain=False
explain=False,
# WP-22: Boosts auch hier anwenden (Konsistenz)
boost_edges=edge_boosts
)
strategy_result = await retriever.search(strategy_req)
existing_ids = {h.node_id for h in hits}