Spaces:
Sleeping
Sleeping
File size: 1,052 Bytes
342fe87 581b2e8 342fe87 581b2e8 342fe87 d3530f3 581b2e8 a7e5906 581b2e8 d3530f3 581b2e8 8e72e5b 581b2e8 342fe87 a7e5906 342fe87 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
from pydantic import BaseModel, Field, field_validator
from typing import Optional, List, Text
from src.enums import QuestionTypeEnum, ParagraphQuestionTypeEnum
class ModelInput(BaseModel):
"""General request model structure for flutter incoming req."""
user_id: Optional[str] = None
context: str
name: str
class IQuestionConfig(BaseModel):
question_type: ParagraphQuestionTypeEnum
num_question: int = Field(..., ge=1, le=5)
class ICreateQuestionForParagraph(BaseModel):
paragraph: Text
num_ans_per_question: int = Field(..., ge=2, le=6)
list_create_question: List[IQuestionConfig]
class ICreateQuestion(BaseModel):
question_type: QuestionTypeEnum
list_words: List[str]
num_ans_per_question: int = Field(..., ge=2, le=10)
num_question: int = Field(..., ge=1, le=10)
@field_validator('list_words')
def check_single_word(cls, value):
for word in value:
if " " in word:
raise ValueError("list_words_just_includes_single_word")
return value
|