File size: 1,083 Bytes
4e316d6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""
Pydantic request/response schemas for the serving API.

Defines the wire format for chat, RAG, ingestion, and health
endpoints. Keeping schemas in a separate module makes them
importable for client-side validation and testing without
pulling in FastAPI.
"""

from pydantic import BaseModel, Field


class ChatMessage(BaseModel):
    role: str = Field(..., description="One of: system, user, assistant")
    content: str


class ChatRequest(BaseModel):
    messages: list[ChatMessage]
    max_tokens: int = Field(default=512, ge=1, le=4096)
    temperature: float = Field(default=0.7, ge=0.0, le=2.0)
    top_k: int = Field(default=20, ge=0)
    top_p: float = Field(default=0.95, ge=0.0, le=1.0)
    stream: bool = Field(default=True)


class RAGChatRequest(ChatRequest):
    top_k_docs: int = Field(default=3, ge=1, le=10, description="Number of retrieved chunks to inject as context")


class IngestResponse(BaseModel):
    filename: str
    num_chunks: int
    message: str


class HealthResponse(BaseModel):
    status: str
    model: str
    device: str
    num_chunks: int