Spaces:
Sleeping
Sleeping
File size: 1,301 Bytes
f866820 |
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 |
"""Pydantic models for API request/response."""
from typing import List, Dict, Any, Optional
from pydantic import BaseModel
# Request models
class QueryRequest(BaseModel):
query: str
top_k: int = 3
use_hybrid: bool = True
use_reranking: bool = True
class IngestRequest(BaseModel):
docs_dir: str
output_path: str = "data/chunks.jsonl"
provider: str = "sentence-transformers"
class SyncRequest(BaseModel):
chunks_path: str = "data/chunks.jsonl"
batch_size: int = 100
# Response models
class Citation(BaseModel):
id: Optional[str] = None
score: float = 0.0
snippet: str = ""
class QueryResponse(BaseModel):
answer: str
sources: List[Citation] = []
citations: List[Citation] = []
query_rewrite: Optional[Dict[str, Any]] = None
retrieval_meta: Optional[Dict[str, Any]] = None
error: Optional[str] = None
class IngestResponse(BaseModel):
status: str
documents: int = 0
chunks: int = 0
output_path: str = ""
errors: List[str] = []
class SyncResponse(BaseModel):
status: str
vectors_upserted: int = 0
errors: List[str] = []
class StatusResponse(BaseModel):
exists: bool = False
chunks: int = 0
documents: int = 0
path: Optional[str] = None
error: Optional[str] = None
|