Spaces:
Sleeping
Sleeping
File size: 1,173 Bytes
09ed935 |
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 35 36 37 38 39 40 41 42 |
from typing import Literal
from dataclasses import field
import random
import os
import question_bank
import mesop as me
from models import Board
_NUM_CATEGORIES = 6
_QUESTION_SETS = question_bank.load()
@me.stateclass
class State:
selected_clue: str
board: Board = field(default_factory=lambda: make_default_board(_QUESTION_SETS))
# Used for clearing the text input.
response_value: str
response: str
score: int
# Key format: click-{row_index}-{col_index}
selected_question_key: str
# Set is not JSON serializable
# Key format: click-{row_index}-{col_index}
answered_questions: set[str] = field(default_factory=set)
# Gemini Live API
api_key: str = os.getenv("GOOGLE_API_KEY", "")
gemini_live_api_enabled: bool = False
gemini_live_api_config: str
audio_player_enabled: bool = False
audio_recorder_state: Literal["disabled", "initializing", "recording"] = "disabled"
tool_call_responses: str = ""
text_input: str = ""
def make_default_board(jeopardy_questions) -> Board:
"""Creates a board with some random jeopardy questions."""
random.shuffle(jeopardy_questions)
return Board(clues=jeopardy_questions[:_NUM_CATEGORIES])
|