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

+10 -7
View File
@@ -1,10 +1,9 @@
"""
FILE: app/models/dto.py
DESCRIPTION: Pydantic-Modelle (DTOs) für Request/Response Bodies. Definiert das API-Schema.
VERSION: 0.6.2
VERSION: 2.6.0 (WP-22 Semantic Graph Routing & Lifecycle)
STATUS: Active
DEPENDENCIES: pydantic, typing, uuid
LAST_ANALYSIS: 2025-12-15
"""
from __future__ import annotations
@@ -12,7 +11,7 @@ from pydantic import BaseModel, Field
from typing import List, Literal, Optional, Dict, Any
import uuid
EdgeKind = Literal["references", "references_at", "backlink", "next", "prev", "belongs_to", "depends_on", "related_to", "similar_to"]
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"]
# --- Basis-DTOs ---
@@ -56,6 +55,11 @@ 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):
@@ -97,7 +101,8 @@ class ScoreBreakdown(BaseModel):
class Reason(BaseModel):
"""Ein semantischer Grund für das Ranking."""
kind: Literal["semantic", "edge", "type", "centrality"]
# 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
details: Optional[Dict[str, Any]] = None
@@ -151,6 +156,4 @@ class ChatResponse(BaseModel):
sources: List[QueryHit] = Field(..., description="Die für die Antwort genutzten Quellen")
latency_ms: int
intent: Optional[str] = Field("FACT", description="WP-06: Erkannter Intent (FACT/DECISION)")
intent_source: Optional[str] = Field("Unknown", description="WP-06: Quelle der Intent-Erkennung (Keyword vs. LLM)")
intent_source: Optional[str] = Field("Unknown", description="WP-06: Quelle der Intent-Erkennung (Keyword vs. LLM)")