brief-rags-bench/app/models/analysis.py

56 lines
1.5 KiB
Python

"""Analysis session Pydantic models."""
from typing import Any, Optional
from pydantic import BaseModel, Field
class SessionCreate(BaseModel):
"""Create new analysis session."""
environment: str = Field(..., description="Environment: ift, psi, or prod")
api_mode: str = Field(..., description="API mode: bench or backend")
request: list[Any] = Field(..., description="Array of request objects")
response: dict = Field(..., description="Response object (arbitrary structure)")
annotations: Optional[dict] = Field(default={}, description="Annotations by question index")
class SessionUpdate(BaseModel):
"""Update session annotations (PATCH).
According to DB_API_CONTRACT_V2.md:
- PATCH /users/{user_id}/sessions/{session_id}
- Used to update annotations after review
- Completely replaces existing annotations
"""
annotations: dict = Field(..., description="Annotations with numeric string keys ('0', '1', ...)")
class SessionResponse(BaseModel):
"""Analysis session response."""
session_id: str
user_id: str
environment: str
api_mode: str
request: list[Any]
response: dict
annotations: dict
created_at: str
updated_at: str
class SessionListItem(BaseModel):
"""Session list item for listing sessions."""
session_id: str
environment: str
created_at: str
class SessionList(BaseModel):
"""List of sessions with total count."""
sessions: list[SessionListItem]
total: int