File size: 824 Bytes
135e71f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from pydantic import BaseModel, Field
from typing import List

class PredictionEntry(BaseModel):
    model: str = Field(..., description="Name of the model used for prediction")
    predicted_class: int = Field(..., description="Predicted class index")
    confidence: float = Field(..., ge=0.0, le=1.0, description="Prediction confidence (0-1)")

class ImagePredictionResponse(BaseModel):
    predictions: List[PredictionEntry] = Field(..., description="List of predictions with model, class, and confidence")

class TextPredictionRequest(BaseModel):
    text: str = Field(..., example="This is a sample text to classify")


class TextPredictionResponse(BaseModel):
    predicted_class: str = Field(..., description="Predicted label for the input text")
    confidence: float = Field(..., ge=0.0, le=1.0)