MAS-AI-0000 commited on
Commit
bbbfa2c
·
verified ·
1 Parent(s): 4687d89

Update structure.py

Browse files
Files changed (1) hide show
  1. structure.py +20 -18
structure.py CHANGED
@@ -1,18 +1,20 @@
1
- from pydantic import BaseModel, Field
2
- from typing import List
3
-
4
- class PredictionEntry(BaseModel):
5
- model: str = Field(..., description="Name of the model used for prediction")
6
- predicted_class: int = Field(..., description="Predicted class index")
7
- confidence: float = Field(..., ge=0.0, le=1.0, description="Prediction confidence (0-1)")
8
-
9
- class ImagePredictionResponse(BaseModel):
10
- predictions: List[PredictionEntry] = Field(..., description="List of predictions with model, class, and confidence")
11
-
12
- class TextPredictionRequest(BaseModel):
13
- text: str = Field(..., example="This is a sample text to classify")
14
-
15
-
16
- class TextPredictionResponse(BaseModel):
17
- predicted_class: str = Field(..., description="Predicted label for the input text")
18
- confidence: float = Field(..., ge=0.0, le=1.0)
 
 
 
1
+ from pydantic import BaseModel, Field
2
+ from typing import List
3
+
4
+ class PredictionEntry(BaseModel):
5
+ model: str = Field(..., description="Name of the model used for prediction")
6
+ error: str | None = Field(None, description="Error message if prediction failed")
7
+ predicted_class: int = Field(..., description="Predicted class index")
8
+ confidence: float = Field(..., ge=-100.0, le=1.0, description="Prediction confidence (0-1)")
9
+
10
+ class ImagePredictionResponse(BaseModel):
11
+ predictions: List[PredictionEntry] = Field(..., description="List of predictions with model, class, and confidence")
12
+
13
+ class TextPredictionRequest(BaseModel):
14
+ text: str = Field(..., example="This is a sample text to classify")
15
+
16
+
17
+ class TextPredictionResponse(BaseModel):
18
+ predicted_class: str = Field(..., description="Predicted label: 'AI' or 'Human'")
19
+ confidence_ai: float = Field(..., ge=-100.0, le=1.0, description="Confidence score for AI (0-1)")
20
+ confidence_human: float = Field(..., ge=-100.0, le=1.0, description="Confidence score for Human (0-1)")