|
import random |
|
from typing import Annotated, Type, List |
|
import json |
|
|
|
from pydantic import BaseModel, field_validator |
|
|
|
MAX_DESCRIPTION_LEN = 10 |
|
|
|
|
|
class AnimalDescriptionModel(BaseModel): |
|
|
|
description: Annotated[str, "A brief description of the animal"] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ChameleonDecisionModel(BaseModel): |
|
will_guess: bool |
|
|
|
|
|
class AnimalGuessModel(BaseModel): |
|
animal_name: str |
|
|
|
|
|
class ChameleonGuessDecisionModel(BaseModel): |
|
decision: Annotated[str, "Must be one of: ['guess', 'pass']"] |
|
|
|
@field_validator('decision') |
|
@classmethod |
|
def check_decision(cls, v) -> str: |
|
if v.lower() not in ['guess', 'pass']: |
|
raise ValueError("Decision must be one of: ['guess', 'pass']") |
|
return v |
|
|
|
|
|
class ChameleonGuessAnimalModel(BaseModel): |
|
animal: Annotated[str, "The name of the animal the chameleon is guessing"] |
|
|
|
@field_validator('animal') |
|
@classmethod |
|
def is_one_word(cls, v) -> str: |
|
if len(v.split()) > 1: |
|
raise ValueError("Animal's name must be one word") |
|
return v |
|
|
|
|
|
class VoteModel(BaseModel): |
|
vote: Annotated[str, "The name of the player you are voting for"] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|