Spaces:
Sleeping
Sleeping
| from pydantic import BaseModel, Field, validator | |
| from typing import List, Optional, Dict, Any | |
| from app.configs.settings import settings | |
| class ImageAnalysisResult(BaseModel): | |
| filename: str | |
| text_used: str | |
| result: Dict[str, Any] | |
| class VideoAnalysisResult(BaseModel): | |
| filename: str | |
| result: Dict[str, Any] | |
| class MediaAnalysisRequest(BaseModel): | |
| image_analysis_results: Optional[List[ImageAnalysisResult]] = None | |
| video_analysis_result: Optional[VideoAnalysisResult] = None | |
| class LocationAnalysisRequest(BaseModel): | |
| latitude: float = Field(..., description="Latitude of the media") | |
| longitude: float = Field(..., description="Longitude of the media") | |
| google_maps_name: str = Field(..., description="Google maps name of the media") | |
| class ReportRequest(BaseModel): | |
| media_id: str = Field(..., description="Media ID") | |
| # media_file_obj_id: Optional[str] = Field(None, description="Media file object ID. The id of the file object in the Google Cloud Storage. This is the id of the file object that is uploaded to the Google Cloud Storage. Use client.files.upload() to upload the media to the Google Cloud Storage.") | |
| media_transcript: Optional[str] = Field(None, description="Media transcript if the media is a video") | |
| media_type: str = Field(..., description="Type of the media. Video or Image") | |
| media: List[str] = Field(..., description="List of media base64 encoded strings") | |
| title: Optional[str] = Field(None, description="Title of the media") | |
| description: Optional[str] = Field(None, description="Description of the media") | |
| location: Optional[str] = Field(None, description="Location of the media") | |
| category: Optional[str] = Field(None, description="Category of the media") | |
| violence_level: Optional[str] = Field(None, description="Violence level of the media") | |
| media_url: Optional[str] = Field(None, description="Media link of the media") | |
| timestamp: Optional[str] = Field(None, description="Timestamp of the media") | |
| source_url: Optional[str] = Field(None, description="Source URL of the evidence that verified the timestamp") | |
| location_analysis: Optional[LocationAnalysisRequest] = Field(None, description="Location analysis of the media") | |
| media_analysis: Optional[MediaAnalysisRequest] = Field(None, description="Media analysis of the media") | |
| language: Optional[str] = Field(None, description="Language of the report") | |
| def validate_media(cls, v): | |
| if not v or len(v) == 0: | |
| raise ValueError('At least one media is required') | |
| if len(v) > settings.max_images: | |
| raise ValueError('Too many media provided') | |
| return v | |
| # Response | |
| class ReportResponse(BaseModel): | |
| readme_content: dict[str, Any] = Field(..., description="Readme content of the report") | |
| processing_time: float = Field(..., description="Processing time of the report in seconds") |