File size: 3,647 Bytes
4fc93b8
c0426da
4fc93b8
 
8e30b6a
 
 
db0fed3
e8d43fa
4fc93b8
8e30b6a
 
 
 
27e6062
8e30b6a
 
 
 
 
 
 
db0fed3
e8d43fa
4fc93b8
 
 
 
8e30b6a
27e6062
8e30b6a
 
 
 
4fc93b8
8e30b6a
 
db0fed3
8e30b6a
 
da164cc
 
 
 
 
4fc93b8
8e30b6a
 
 
1900ea7
8e30b6a
da164cc
4fc93b8
 
 
 
 
 
 
1900ea7
da164cc
 
 
 
4fc93b8
 
 
 
 
 
 
8e30b6a
4fc93b8
 
 
 
 
 
8e30b6a
4fc93b8
 
 
 
 
 
 
 
c0426da
 
 
 
 
 
 
 
 
 
 
 
a4eee2b
c0426da
da164cc
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
from pydantic import BaseModel, HttpUrl, Field
from typing import Union, Literal, Optional, Dict, List


class TextAnalysisRequest(BaseModel):
    content_type: Literal["text"]
    text: str = Field(..., description="Text content to analyze for deepfake detection")
    guild_id: str = Field(..., description="ID serwera Discord, z kt贸rego pochodzi 偶膮danie")
    user_id: str = Field(..., description="ID u偶ytkownika Discord, kt贸ry wywo艂a艂 analiz臋")
    
    class Config:
        json_schema_extra = {
            "example": {
                "content_type": "text",
                "text": "Some text that might be AI-generated"
            }
        }


class ImageAnalysisRequest(BaseModel):
    content_type: Literal["image"]
    image_url: HttpUrl = Field(..., description="URL of the image to analyze")
    guild_id: str = Field(..., description="ID serwera Discord, z kt贸rego pochodzi 偶膮danie")
    user_id: str = Field(..., description="ID u偶ytkownika Discord, kt贸ry wywo艂a艂 analiz臋")
    
    class Config:
        json_schema_extra = {
            "example": {
                "content_type": "image",
                "image_url": "https://example.com/image.jpg"
            }
        }



AnalysisRequest = Union[
    TextAnalysisRequest,
    ImageAnalysisRequest
]

class ModelDetail(BaseModel):
    model: str
    is_deepfake: bool
    confidence: float
    
class AnalysisResponse(BaseModel):
    is_deepfake: bool = Field(..., description="Whether the content is detected as a deepfake")
    confidence: float = Field(..., ge=0.0, le=1.0, description="Confidence score between 0.0 and 1.0")
    analysis_time: float = Field(..., description="Time taken for analysis in seconds")
    used_model: str = Field(..., description="The detector model that was used")
    content_type: str = Field(..., description="Type of content analyzed (text/image/video/file)")
    details: Optional[List[ModelDetail]] = None
    
    class Config:
        json_schema_extra = {
            "example": {
                "is_deepfake": True,
                "confidence": 0.847,
                "analysis_time": 1.234,
                "used_model": "mock",
                "content_type": "image",
                "details": [
                    {"model": "mock", "is_deepfake": True, "confidence": 0.847}
                ]
            }
        }


class ErrorResponse(BaseModel):
    error: str = Field(..., description="Error message")
    status_code: int = Field(..., description="HTTP status code")
    details: Optional[str] = Field(None, description="Additional error details")
    
    class Config:
        json_schema_extra = {
            "example": {
                "error": "Invalid URL format",
                "status_code": 400,
                "details": "The provided URL is not valid"
            }
        }


class HealthResponse(BaseModel):
    status: str = Field(..., description="Service status")
    service: str = Field(..., description="Service name")
    version: str = Field(..., description="Service version")
    available_models: Dict[str, List[str]] = Field(
        ..., description="Lista dost臋pnych modeli pogrupowana wed艂ug typ贸w"
    )
    supported_types: List[str] = Field(
        ..., description="Obs艂ugiwane typy danych"
    )
    models_status: Dict[str, str] = Field(
        ..., description="Status gotowo艣ci handler贸w dla poszczeg贸lnych typ贸w"
    )
    
class GuildConfigSchema(BaseModel):
    active_text_model: Optional[str] = "none"
    active_image_model: Optional[str] = "none"
    log_channel_id: Optional[str] = None
    multi_model_workflow: Optional[bool] = False