Add read-only production runtime audit

This commit is contained in:
2026-08-17 11:17:40 +07:00
parent 057d4ed9dc
commit a1de4715a4
106 changed files with 6869 additions and 1782 deletions
+8 -3
View File
@@ -3,7 +3,7 @@ from __future__ import annotations
import uuid
from typing import Annotated, Any, Literal, Protocol
from fastapi import APIRouter, Depends, HTTPException, Request
from fastapi import APIRouter, Depends, HTTPException, Query, Request
from pydantic import BaseModel, Field
from rag.answer import DISCLAIMER, GroundedAnswerService
@@ -36,6 +36,7 @@ class RagQueryRequest(BaseModel):
# (follow-up inheritance, clarify, smalltalk). Absent → single-turn, exactly
# as before, so existing callers are unchanged.
conversation_id: str | None = Field(default=None, max_length=128)
response_mode: Literal["ai", "monograph"] = "ai"
class CitationResponse(BaseModel):
@@ -198,7 +199,7 @@ _HISTORY_LIMIT = 50
@router.get("/history", response_model=HistoryResponse)
def list_history(
conversation_id: str,
conversation_id: Annotated[str, Query(max_length=128)],
traces: Annotated[TraceWriter, Depends(_trace_writer)],
) -> HistoryResponse:
"""Feature-List #25: past queries for one session, most recent first, so
@@ -430,7 +431,11 @@ def query_rag(
# then routes to the safety-verified retrieval + grounded-answer
# engine. Replaces the old fuzzy resolver + keyword section router +
# manual follow-up inheritance for both single- and multi-turn.
reply = agent.handle(payload.query, payload.conversation_id)
reply = agent.handle(
payload.query,
payload.conversation_id,
response_mode=payload.response_mode,
)
decision = reply.decision
reason = reply.reason
answer = reply.clarification if reply.clarification is not None else reply.answer