benjolo's picture
Uploading completed backend
ddc5bbd verified
raw
history blame
No virus
3.13 kB
import uuid
from typing import List, Dict, Optional
from datetime import datetime
from pydantic import BaseModel, Field, PrivateAttr
import sys
''' Class for storing captions generated by SeamlessM4T'''
class UserCaptions(BaseModel):
_id: uuid.UUID = PrivateAttr(default_factory=uuid.uuid4) # private attr not included in http calls
author_id: Optional[str] = None
author_username: Optional[str] = None
original_text: str
translated_text: str
timestamp: datetime = Field(default_factory=datetime.now)
class Config:
populate_by_name = True
json_schema_extra = {
"example": {
"author_id": "gLZrfTwXyLUPB3eT7xT2HZnZiZT2",
"author_username": "shamzino",
"original_text": "eng: This is original_text english text",
"translated_text": "spa: este es el texto traducido al español",
"timestamp": "2024-03-28T16:15:50.956055",
}
}
'''Class for storing past call records from users'''
class UserCall(BaseModel):
_id: uuid.UUID = PrivateAttr(default_factory=uuid.uuid4)
call_id: Optional[str] = None
caller_id: Optional[str] = None
callee_id: Optional[str] = None
creation_date: datetime = Field(default_factory=datetime.now, alias="date")
captions: Optional[List[UserCaptions]] = None
key_terms: Optional[dict] = None
summaries: Optional[dict] = None
class Config:
populate_by_name = True
json_schema_extra = {
"example": {
"call_id": "65eef930e9abd3b1e3506906",
"caller_id": "65ede65b6d246e52aaba9d4f",
"callee_id": "65edda944340ac84c1f00758",
"captions": [{"author_id": "gLZrfTwXyLUPB3eT7xT2HZnZiZT2", "author_username": "shamzino", "original_text": "eng: This is original_text english text", "translated_text": "spa: este es el texto traducido al español", "timestamp": "2024-03-28T16:15:50.956055"},
{"author_id": "g7pR1qCibzQf5mDP9dGtcoWeEc92", "author_username": "benjino", "original_text": "eng: This is source english text", "translated_text": "spa: este es el texto fuente al español", "timestamp": "2024-03-28T16:16:20.34625"}],
"key_terms": {"gLZrfTwXyLUPB3eT7xT2HZnZiZT2": ["original_text", "source", "english", "text"], "g7pR1qCibzQf5mDP9dGtcoWeEc92": ["translated_text", "destination", "spanish", "text"]},
"summaries": {"gLZrfTwXyLUPB3eT7xT2HZnZiZT2": "This is a short test on lanuguage translation", "65edda944340ac84c1f00758": "Esta es una breve prueba sobre traducción de idiomas."}
}
}
''' Class for updating User Call record'''
class UpdateCall(BaseModel):
call_id: Optional[str] = None
caller_id: Optional[str] = None
callee_id: Optional[str] = None
captions: Optional[List[UserCaptions]] = None
key_terms: Optional[List[str]] = None
class Config:
populate_by_name = True
json_schema_extra = {
"example": {
"duration": "500"
}
}