File size: 2,609 Bytes
d44b33d | 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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | """Pydantic request bodies and query-parameter models for the HTTP API.
Used by FastAPI route handlers for validation and OpenAPI schema generation.
"""
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",
)
|