"""Pydantic models for analysis endpoints""" from pydantic import BaseModel, Field, ConfigDict from typing import List, Optional class AnalysisRequest(BaseModel): """Request model for analysis with arguments""" model_config = ConfigDict( json_schema_extra={ "example": { "arguments": [ "Social media companies must NOT be allowed to track people across websites.", "I don't think universal basic income is a good idea — it'll disincentivize work.", "We must invest in renewable energy to combat climate change." ] } } ) arguments: List[str] = Field( ..., min_length=1, max_length=100, description="List of argument texts to analyze (max 100)" ) class AnalysisResult(BaseModel): """Model for a single analysis result""" model_config = ConfigDict( json_schema_extra={ "example": { "id": "123e4567-e89b-12d3-a456-426614174000", "user_id": "123e4567-e89b-12d3-a456-426614174000", "argument": "Social media companies must NOT be allowed to track people across websites.", "topic": "social media tracking and cross-website user privacy", "predicted_stance": "CON", "confidence": 0.9234, "probability_con": 0.9234, "probability_pro": 0.0766, "created_at": "2024-01-01T12:00:00Z", "updated_at": "2024-01-01T12:00:00Z" } } ) id: str = Field(..., description="Analysis result UUID") user_id: str = Field(..., description="User UUID") argument: str = Field(..., description="The argument text") topic: str = Field(..., description="Extracted topic") predicted_stance: str = Field(..., description="PRO or CON") confidence: float = Field(..., ge=0.0, le=1.0, description="Confidence score") probability_con: float = Field(..., ge=0.0, le=1.0, description="Probability of CON") probability_pro: float = Field(..., ge=0.0, le=1.0, description="Probability of PRO") created_at: str = Field(..., description="Creation timestamp") updated_at: str = Field(..., description="Last update timestamp") class AnalysisResponse(BaseModel): """Response model for analysis endpoint""" model_config = ConfigDict( json_schema_extra={ "example": { "results": [ { "id": "123e4567-e89b-12d3-a456-426614174000", "user_id": "123e4567-e89b-12d3-a456-426614174000", "argument": "Social media companies must NOT be allowed to track people across websites.", "topic": "social media tracking and cross-website user privacy", "predicted_stance": "CON", "confidence": 0.9234, "probability_con": 0.9234, "probability_pro": 0.0766, "created_at": "2024-01-01T12:00:00Z", "updated_at": "2024-01-01T12:00:00Z" } ], "total_processed": 1, "timestamp": "2024-01-01T12:00:00Z" } } ) results: List[AnalysisResult] = Field(..., description="List of analysis results") total_processed: int = Field(..., description="Number of arguments processed") timestamp: str = Field(..., description="Analysis timestamp") class GetAnalysisRequest(BaseModel): """Request model for getting user's analysis results""" limit: Optional[int] = Field(100, ge=1, le=1000, description="Maximum number of results") offset: Optional[int] = Field(0, ge=0, description="Number of results to skip") class GetAnalysisResponse(BaseModel): """Response model for getting analysis results""" results: List[AnalysisResult] = Field(..., description="List of analysis results") total: int = Field(..., description="Total number of results") limit: int = Field(..., description="Limit used") offset: int = Field(..., description="Offset used")