| from typing import Optional | |
| from pydantic import BaseModel, ConfigDict, Field, HttpUrl | |
| class QueryRequest(BaseModel): | |
| model_config = ConfigDict(extra="forbid") | |
| question: str = Field(min_length=5, max_length=2000, description="Natural language question") | |
| collection_name: Optional[str] = Field( | |
| default="default", | |
| min_length=1, | |
| max_length=256, | |
| description="Chroma collection to search", | |
| ) | |
| top_k: int = Field(default=5, ge=1, le=20, description="Number of chunks to retrieve") | |
| user_id: str = Field(default="anonymous", max_length=256, description="Caller id for audit filtering") | |
| class SummariseRequest(BaseModel): | |
| model_config = ConfigDict(extra="forbid") | |
| collection_name: str = Field( | |
| default="default", | |
| min_length=1, | |
| max_length=256, | |
| description="Chroma collection to summarise", | |
| ) | |
| focus: str | None = Field( | |
| default=None, | |
| max_length=8000, | |
| description="Optional angle or scope for retrieval and the summary", | |
| ) | |
| user_id: str = Field(default="anonymous", max_length=256, description="Caller id for audit filtering") | |
| class URLIngestRequest(BaseModel): | |
| model_config = ConfigDict(extra="forbid") | |
| urls: list[HttpUrl] = Field( | |
| min_length=1, | |
| max_length=100, | |
| description="One or more HTTP(S) URLs to PDF, TXT, or Markdown documents", | |
| ) | |
| collection_name: Optional[str] = Field( | |
| default="default", | |
| min_length=1, | |
| max_length=256, | |
| description="Target Chroma collection name", | |
| ) | |
| class JobsListParams(BaseModel): | |
| model_config = ConfigDict(extra="forbid") | |
| limit: int = Field(default=10, ge=1, le=100, description="Max jobs to return") | |
| offset: int = Field(default=0, ge=0, description="Offset for pagination") | |
| class AuditListParams(BaseModel): | |
| model_config = ConfigDict(extra="forbid") | |
| limit: int = Field(default=50, ge=1, le=100, description="Max log entries to return") | |
| offset: int = Field(default=0, ge=0, description="Offset for pagination") | |
| user_id: str | None = Field(default=None, max_length=256, description="Filter by user id") | |
| from_date: str | None = Field( | |
| default=None, | |
| description="ISO 8601 datetime lower bound (inclusive) on timestamp", | |
| ) | |
| to_date: str | None = Field( | |
| default=None, | |
| description="ISO 8601 datetime upper bound (inclusive) on timestamp", | |
| ) | |