Spaces:
Sleeping
Sleeping
Deploy Myco from CI
Browse files- ui/gradio_app.py +0 -17
ui/gradio_app.py
CHANGED
|
@@ -4,10 +4,6 @@ Callbacks intentionally avoid complex type annotations because Hugging Face Spac
|
|
| 4 |
was serving an older broken annotated version of this file.
|
| 5 |
"""
|
| 6 |
|
| 7 |
-
import gradio as gr
|
| 8 |
-
|
| 9 |
-
from game.engine import collect_current, discover_mushroom, eat_current, myco_reply, study_current
|
| 10 |
-
from game.state import welcome_history
|
| 11 |
from __future__ import annotations
|
| 12 |
|
| 13 |
import gradio as gr
|
|
@@ -19,11 +15,6 @@ from ui.renderers import dex_markdown, forest_scene, hero_markdown, mushroom_car
|
|
| 19 |
|
| 20 |
|
| 21 |
# Keep callback signatures plain for Hugging Face Spaces parser stability.
|
| 22 |
-
def start_exploring(collection):
|
| 23 |
-
def handle_explore(collection):
|
| 24 |
-
def explore(collection):
|
| 25 |
-
# Keep Gradio callback signatures plain for Hugging Face Spaces parser stability.
|
| 26 |
-
def explore(collection):
|
| 27 |
def explore(collection: CollectionState) -> tuple[str, str, MushroomState, list[dict[str, str]], str, str]:
|
| 28 |
"""Gradio callback for the Start Exploring button."""
|
| 29 |
mushroom, current, history = discover_mushroom(collection)
|
|
@@ -37,7 +28,6 @@ def explore(collection: CollectionState) -> tuple[str, str, MushroomState, list[
|
|
| 37 |
)
|
| 38 |
|
| 39 |
|
| 40 |
-
def ask_myco(message, history, current):
|
| 41 |
def ask_myco(
|
| 42 |
message: str,
|
| 43 |
history: list[dict[str, str]],
|
|
@@ -47,7 +37,6 @@ def ask_myco(
|
|
| 47 |
return myco_reply(message, history, current)
|
| 48 |
|
| 49 |
|
| 50 |
-
def add_to_dex(current, collection, history):
|
| 51 |
def add_to_dex(
|
| 52 |
current: MushroomState | None,
|
| 53 |
collection: CollectionState,
|
|
@@ -64,7 +53,6 @@ def add_to_dex(
|
|
| 64 |
)
|
| 65 |
|
| 66 |
|
| 67 |
-
def study_mushroom(current, history, collection):
|
| 68 |
def study_mushroom(
|
| 69 |
current: MushroomState | None,
|
| 70 |
history: list[dict[str, str]],
|
|
@@ -80,7 +68,6 @@ def study_mushroom(
|
|
| 80 |
)
|
| 81 |
|
| 82 |
|
| 83 |
-
def eat_mushroom(current, history):
|
| 84 |
def eat_mushroom(
|
| 85 |
current: MushroomState | None,
|
| 86 |
history: list[dict[str, str]],
|
|
@@ -89,7 +76,6 @@ def eat_mushroom(
|
|
| 89 |
return eat_current(current, history)
|
| 90 |
|
| 91 |
|
| 92 |
-
def mushroom_card_from_state(current):
|
| 93 |
def mushroom_card_from_state(current: MushroomState | None) -> str:
|
| 94 |
"""Render a mushroom card from Gradio state."""
|
| 95 |
if current is None:
|
|
@@ -97,7 +83,6 @@ def mushroom_card_from_state(current: MushroomState | None) -> str:
|
|
| 97 |
return mushroom_card(Mushroom.from_dict(current))
|
| 98 |
|
| 99 |
|
| 100 |
-
def build_app():
|
| 101 |
def build_app() -> gr.Blocks:
|
| 102 |
"""Build the Gradio interface for Hugging Face Spaces."""
|
| 103 |
with gr.Blocks(title="Myco") as demo:
|
|
@@ -129,8 +114,6 @@ def build_app() -> gr.Blocks:
|
|
| 129 |
dex = gr.Markdown(dex_markdown([]), elem_id="mycodex")
|
| 130 |
|
| 131 |
explore_button.click(
|
| 132 |
-
start_exploring,
|
| 133 |
-
handle_explore,
|
| 134 |
explore,
|
| 135 |
inputs=[collection],
|
| 136 |
outputs=[scene, discovery, current_mushroom, chat, dex, progress],
|
|
|
|
| 4 |
was serving an older broken annotated version of this file.
|
| 5 |
"""
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
from __future__ import annotations
|
| 8 |
|
| 9 |
import gradio as gr
|
|
|
|
| 15 |
|
| 16 |
|
| 17 |
# Keep callback signatures plain for Hugging Face Spaces parser stability.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
def explore(collection: CollectionState) -> tuple[str, str, MushroomState, list[dict[str, str]], str, str]:
|
| 19 |
"""Gradio callback for the Start Exploring button."""
|
| 20 |
mushroom, current, history = discover_mushroom(collection)
|
|
|
|
| 28 |
)
|
| 29 |
|
| 30 |
|
|
|
|
| 31 |
def ask_myco(
|
| 32 |
message: str,
|
| 33 |
history: list[dict[str, str]],
|
|
|
|
| 37 |
return myco_reply(message, history, current)
|
| 38 |
|
| 39 |
|
|
|
|
| 40 |
def add_to_dex(
|
| 41 |
current: MushroomState | None,
|
| 42 |
collection: CollectionState,
|
|
|
|
| 53 |
)
|
| 54 |
|
| 55 |
|
|
|
|
| 56 |
def study_mushroom(
|
| 57 |
current: MushroomState | None,
|
| 58 |
history: list[dict[str, str]],
|
|
|
|
| 68 |
)
|
| 69 |
|
| 70 |
|
|
|
|
| 71 |
def eat_mushroom(
|
| 72 |
current: MushroomState | None,
|
| 73 |
history: list[dict[str, str]],
|
|
|
|
| 76 |
return eat_current(current, history)
|
| 77 |
|
| 78 |
|
|
|
|
| 79 |
def mushroom_card_from_state(current: MushroomState | None) -> str:
|
| 80 |
"""Render a mushroom card from Gradio state."""
|
| 81 |
if current is None:
|
|
|
|
| 83 |
return mushroom_card(Mushroom.from_dict(current))
|
| 84 |
|
| 85 |
|
|
|
|
| 86 |
def build_app() -> gr.Blocks:
|
| 87 |
"""Build the Gradio interface for Hugging Face Spaces."""
|
| 88 |
with gr.Blocks(title="Myco") as demo:
|
|
|
|
| 114 |
dex = gr.Markdown(dex_markdown([]), elem_id="mycodex")
|
| 115 |
|
| 116 |
explore_button.click(
|
|
|
|
|
|
|
| 117 |
explore,
|
| 118 |
inputs=[collection],
|
| 119 |
outputs=[scene, discovery, current_mushroom, chat, dex, progress],
|