"""Pydantic request/response schemas (API contract).""" from __future__ import annotations from pydantic import BaseModel, Field class HealthResponse(BaseModel): status: str db: str version: str environment: str class SuggestionList(BaseModel): suggestions: list[str] class ChatRequest(BaseModel): message: str = Field(min_length=1, max_length=4000) class SourceRef(BaseModel): source: str path: str title: str class ChatDoneEvent(BaseModel): """Final SSE event of a chat turn: metadata for the finished answer.""" type: str = "done" deflected: bool sources: list[SourceRef] suggestions: list[str] = [] class ChatErrorEvent(BaseModel): """SSE error event: a turn that cannot complete (PLAN ยง4). The client's loading-feedback state machine (phase 06) keys off this exact shape โ€” ``{type: "error", detail: str}`` โ€” to flip to the error state and re-enable the send button. """ type: str = "error" detail: str class DocSummary(BaseModel): """One indexed document as shown on the Sources page / API.""" id: str source: str path: str title: str chunks: int indexed_at: str class DocList(BaseModel): """Response of ``GET /api/docs`` (empty list โ†’ designed empty state).""" documents: list[DocSummary] class DocContent(BaseModel): """One indexed document's full content (feeds the viewer page, phase 10).""" source: str path: str title: str format: str content: str indexed_at: str chunks: int