Spaces:
Sleeping
Sleeping
from pydantic import BaseModel | |
from typing import List, Dict, Optional | |
from datetime import datetime | |
class Response(BaseModel): | |
config_id: str | |
query_v: Dict[str, int] | |
query_p0: Dict[str, int] | |
query_p1: Dict[str, int] | |
comment: Optional[str] | |
timestamp: str | |
class Feedback(BaseModel): | |
id: int | |
user_id: str | |
time_stamp: datetime | |
responses: List[Response] | |
# Override the method to serialize datetime | |
def dict(self, *args, **kwargs): | |
feedback_data = super().dict(*args, **kwargs) | |
feedback_data['time_stamp'] = self.time_stamp.isoformat() # Convert datetime to ISO string | |
return feedback_data | |