Gradii commited on
Commit
1900ea7
·
1 Parent(s): 7c5da40
backend/README.md CHANGED
@@ -81,7 +81,7 @@ Content-Type: application/json
81
  "is_deepfake": true,
82
  "confidence": 0.847,
83
  "analysis_time": 1.234,
84
- "model_used": "mock"
85
  }
86
  ```
87
 
 
81
  "is_deepfake": true,
82
  "confidence": 0.847,
83
  "analysis_time": 1.234,
84
+ "used_model": "mock"
85
  }
86
  ```
87
 
backend/app/api/routes.py CHANGED
@@ -29,8 +29,28 @@ async def health_check() -> HealthResponse:
29
  settings = get_settings()
30
  logger.info("Health check endpoint accessed")
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  return HealthResponse(
33
- status="ok",
34
  service="Deepfake Detection Service",
35
  version=settings.APP_VERSION,
36
  available_models=settings.AVAILABLE_MODELS,
@@ -86,7 +106,6 @@ async def analyze(request: AnalysisRequest) -> AnalysisResponse:
86
 
87
  analysis_result = await analyze_image(image_bytes)
88
 
89
- # 4. Globalna obsługa błędów
90
  except ValueError as e:
91
  raise HTTPException(status_code=400, detail=str(e))
92
  except DeepfakeDetectionError as e:
@@ -101,6 +120,6 @@ async def analyze(request: AnalysisRequest) -> AnalysisResponse:
101
  is_deepfake=analysis_result["is_deepfake"],
102
  confidence=analysis_result["confidence"],
103
  analysis_time=analysis_result["analysis_time"],
104
- model_used=model,
105
  content_type=content_type,
106
  )
 
29
  settings = get_settings()
30
  logger.info("Health check endpoint accessed")
31
 
32
+ handlers = {
33
+ "text": analyze_text,
34
+ "image": analyze_image,
35
+ }
36
+
37
+ models_status = {}
38
+ is_healthy = True
39
+
40
+ for content_type in settings.AVAILABLE_MODELS.keys():
41
+ handler = handlers.get(content_type)
42
+
43
+ if handler is not None and callable(handler):
44
+ models_status[content_type] = "ready"
45
+ else:
46
+ models_status[content_type] = "error_not_callable"
47
+ is_healthy = False
48
+ logger.error(f"Krytyczny brak! Handler dla typu '{content_type}' nie jest callable.")
49
+
50
+ overall_status = "ok" if is_healthy else "degraded"
51
+
52
  return HealthResponse(
53
+ status=overall_status,
54
  service="Deepfake Detection Service",
55
  version=settings.APP_VERSION,
56
  available_models=settings.AVAILABLE_MODELS,
 
106
 
107
  analysis_result = await analyze_image(image_bytes)
108
 
 
109
  except ValueError as e:
110
  raise HTTPException(status_code=400, detail=str(e))
111
  except DeepfakeDetectionError as e:
 
120
  is_deepfake=analysis_result["is_deepfake"],
121
  confidence=analysis_result["confidence"],
122
  analysis_time=analysis_result["analysis_time"],
123
+ used_model=model,
124
  content_type=content_type,
125
  )
backend/app/models/schemas.py CHANGED
@@ -66,7 +66,7 @@ class AnalysisResponse(BaseModel):
66
  is_deepfake: bool = Field(..., description="Whether the content is detected as a deepfake")
67
  confidence: float = Field(..., ge=0.0, le=1.0, description="Confidence score between 0.0 and 1.0")
68
  analysis_time: float = Field(..., description="Time taken for analysis in seconds")
69
- model_used: str = Field(..., description="The detector model that was used")
70
  content_type: str = Field(..., description="Type of content analyzed (text/image/video/file)")
71
 
72
  class Config:
@@ -75,7 +75,7 @@ class AnalysisResponse(BaseModel):
75
  "is_deepfake": True,
76
  "confidence": 0.847,
77
  "analysis_time": 1.234,
78
- "model_used": "mock",
79
  "content_type": "image"
80
  }
81
  }
 
66
  is_deepfake: bool = Field(..., description="Whether the content is detected as a deepfake")
67
  confidence: float = Field(..., ge=0.0, le=1.0, description="Confidence score between 0.0 and 1.0")
68
  analysis_time: float = Field(..., description="Time taken for analysis in seconds")
69
+ used_model: str = Field(..., description="The detector model that was used")
70
  content_type: str = Field(..., description="Type of content analyzed (text/image/video/file)")
71
 
72
  class Config:
 
75
  "is_deepfake": True,
76
  "confidence": 0.847,
77
  "analysis_time": 1.234,
78
+ "used_model": "mock",
79
  "content_type": "image"
80
  }
81
  }
index.js CHANGED
@@ -148,7 +148,7 @@ client.on(Events.InteractionCreate, async (interaction) => {
148
  `### Wyniki Analizy (${data.content_type.toUpperCase()})\n` +
149
  `${statusEmoji}\n\n` +
150
  `* **Pewność modelu:** \`${confidencePercent}%\`\n` +
151
- `* **Użyty model:** \`${data.model_used}\`\n` +
152
  `* **Czas przetwarzania:** \`${timeSec} sekund\`\n`;
153
 
154
  await interaction.editReply({
 
148
  `### Wyniki Analizy (${data.content_type.toUpperCase()})\n` +
149
  `${statusEmoji}\n\n` +
150
  `* **Pewność modelu:** \`${confidencePercent}%\`\n` +
151
+ `* **Użyty model:** \`${data.used_model}\`\n` +
152
  `* **Czas przetwarzania:** \`${timeSec} sekund\`\n`;
153
 
154
  await interaction.editReply({