Spaces:
Sleeping
Sleeping
File size: 869 Bytes
c1eb573 77145ac c1eb573 77145ac c1eb573 9fa751e | 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 | """State helpers for Myco's first playable loop."""
from models.mushroom import Mushroom
WELCOME_MESSAGE = "Hello! I'm Myco. Let's explore the forest."
EMPTY_DEX = "Your MycoDex is empty. Discover a mushroom, then add it here."
ChatHistory = list[dict[str, str]]
MushroomState = dict[str, str]
CollectionState = list[MushroomState]
def welcome_history() -> ChatHistory:
"""Return the opening Myco companion message."""
return [{"role": "assistant", "content": WELCOME_MESSAGE}]
def mushroom_from_state(current: MushroomState) -> Mushroom:
"""Hydrate a mushroom from Gradio state."""
return Mushroom.from_dict(current)
def collection_contains(collection: CollectionState, mushroom_name: str) -> bool:
"""Return whether the MycoDex already has a mushroom by name."""
return any(entry.get("name") == mushroom_name for entry in collection)
|