neue debug Version im retriever
This commit is contained in:
1 parent
c61d9c8236
commit
babab3167b
2 files changed
+201
-186
No files matched your search
+10
-14
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
FILE: app/models/dto.py
|
||||
DESCRIPTION: Pydantic-Modelle (DTOs) für Request/Response Bodies. Definiert das API-Schema.
|
||||
VERSION: 0.6.4 (WP-22 Semantic Graph Routing, Lifecycle & Provenance)
|
||||
VERSION: 0.6.5 (WP-22 Debug & Verifiability Update)
|
||||
STATUS: Active
|
||||
DEPENDENCIES: pydantic, typing, uuid
|
||||
LAST_ANALYSIS: 2025-12-18
|
||||
@@ -12,7 +12,6 @@ from pydantic import BaseModel, Field
|
||||
from typing import List, Literal, Optional, Dict, Any
|
||||
import uuid
|
||||
|
||||
# WP-22: Definition der gültigen Kanten-Typen gemäß Manual
|
||||
EdgeKind = Literal["references", "references_at", "backlink", "next", "prev", "belongs_to", "depends_on", "related_to", "similar_to", "caused_by", "derived_from", "based_on", "solves", "blocks", "uses", "guides"]
|
||||
|
||||
|
||||
@@ -41,7 +40,6 @@ class EdgeDTO(BaseModel):
|
||||
target: str
|
||||
weight: float
|
||||
direction: Literal["out", "in", "undirected"] = "out"
|
||||
# WP-22: Provenance Tracking (Herkunft und Vertrauen)
|
||||
provenance: Optional[Literal["explicit", "rule", "smart", "structure"]] = "explicit"
|
||||
confidence: float = 1.0
|
||||
|
||||
@@ -60,22 +58,16 @@ class QueryRequest(BaseModel):
|
||||
filters: Optional[Dict] = None
|
||||
ret: Dict = {"with_paths": True, "with_notes": True, "with_chunks": True}
|
||||
explain: bool = False
|
||||
|
||||
# WP-22: Semantic Graph Routing
|
||||
# Erlaubt dem Router, Kantengewichte dynamisch zu überschreiben.
|
||||
# Format: {"caused_by": 3.0, "related_to": 0.5}
|
||||
boost_edges: Optional[Dict[str, float]] = None
|
||||
|
||||
|
||||
class FeedbackRequest(BaseModel):
|
||||
"""
|
||||
User-Feedback zu einem spezifischen Treffer oder der Gesamtantwort (Basis für WP-08).
|
||||
User-Feedback zu einem spezifischen Treffer oder der Gesamtantwort.
|
||||
Basis für WP-08 (Self-Tuning).
|
||||
"""
|
||||
query_id: str = Field(..., description="ID der ursprünglichen Suche")
|
||||
# node_id ist optional: Wenn leer oder "generated_answer", gilt es für die Antwort.
|
||||
# Wenn eine echte Chunk-ID, gilt es für die Quelle.
|
||||
node_id: str = Field(..., description="ID des bewerteten Treffers oder 'generated_answer'")
|
||||
# Update: Range auf 1-5 erweitert für differenziertes Tuning
|
||||
score: int = Field(..., ge=1, le=5, description="1 (Irrelevant/Falsch) bis 5 (Perfekt)")
|
||||
comment: Optional[str] = None
|
||||
|
||||
@@ -86,7 +78,6 @@ class ChatRequest(BaseModel):
|
||||
"""
|
||||
message: str = Field(..., description="Die Nachricht des Users")
|
||||
conversation_id: Optional[str] = Field(None, description="Optional: ID für Chat-Verlauf (noch nicht implementiert)")
|
||||
# RAG Parameter (Override defaults)
|
||||
top_k: int = 5
|
||||
explain: bool = False
|
||||
|
||||
@@ -102,11 +93,13 @@ class ScoreBreakdown(BaseModel):
|
||||
raw_edge_bonus: float
|
||||
raw_centrality: float
|
||||
node_weight: float
|
||||
# WP-22 Debug Fields
|
||||
status_multiplier: float = 1.0
|
||||
graph_boost_factor: float = 1.0
|
||||
|
||||
|
||||
class Reason(BaseModel):
|
||||
"""Ein semantischer Grund für das Ranking."""
|
||||
# WP-22: 'lifecycle' hinzugefügt für Status-Begründungen (Draft vs Stable)
|
||||
kind: Literal["semantic", "edge", "type", "centrality", "lifecycle"]
|
||||
message: str
|
||||
score_impact: Optional[float] = None
|
||||
@@ -118,6 +111,9 @@ class Explanation(BaseModel):
|
||||
breakdown: ScoreBreakdown
|
||||
reasons: List[Reason]
|
||||
related_edges: Optional[List[EdgeDTO]] = None
|
||||
# WP-22 Debug: Verifizierung des Routings
|
||||
applied_intent: Optional[str] = None
|
||||
applied_boosts: Optional[Dict[str, float]] = None
|
||||
|
||||
|
||||
# --- Response Models ---
|
||||
@@ -132,7 +128,7 @@ class QueryHit(BaseModel):
|
||||
total_score: float
|
||||
paths: Optional[List[List[Dict]]] = None
|
||||
source: Optional[Dict] = None
|
||||
payload: Optional[Dict] = None # Added for flexibility & WP-06 meta-data
|
||||
payload: Optional[Dict] = None
|
||||
explanation: Optional[Explanation] = None
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user