Spaces:
Running
Running
| """ | |
| Application Layer - DTOs (Data Transfer Objects) | |
| """ | |
| from dataclasses import dataclass | |
| from typing import List, Optional | |
| from uuid import UUID | |
| class QueryDTO: | |
| """Query data transfer object""" | |
| query_text: str | |
| department: str | |
| user_id: Optional[str] = None | |
| session_id: Optional[str] = None | |
| top_k: int = 10 | |
| temperature: float = 0.7 | |
| max_tokens: int = 2048 | |
| filters: dict = None | |
| def __post_init__(self) -> None: | |
| if self.filters is None: | |
| self.filters = {} | |
| class SourceDTO: | |
| """Source citation DTO""" | |
| title: str | |
| content: str | |
| relevance_score: float | |
| document_id: str | |
| chunk_index: int | |
| metadata: dict | |
| class QueryResponseDTO: | |
| """Query response DTO""" | |
| query_id: str | |
| answer: str | |
| sources: List[SourceDTO] | |
| confidence: float | |
| processing_time_ms: int | |
| tokens_used: int | |
| model: str | |
| class DocumentUploadDTO: | |
| """Document upload DTO""" | |
| filename: str | |
| content: bytes | |
| department: str | |
| metadata: dict = None | |
| def __post_init__(self) -> None: | |
| if self.metadata is None: | |
| self.metadata = {} | |
| class DocumentDTO: | |
| """Document DTO""" | |
| id: str | |
| title: str | |
| filename: str | |
| file_type: str | |
| file_size: int | |
| department: str | |
| status: str | |
| uploaded_at: str | |
| indexed_at: Optional[str] = None | |
| metadata: dict = None | |