Spaces:
Sleeping

byte-vortex commited on
Commit
726f49a
·
verified ·
1 Parent(s): 4613522

Deploy Myco from CI

Browse files
Files changed (1) hide show
  1. ui/gradio_app.py +1 -19
ui/gradio_app.py CHANGED
@@ -3,12 +3,7 @@
3
  Callbacks intentionally avoid complex type annotations because Hugging Face Spaces
4
  was serving an older broken annotated version of this file.
5
  """
6
- """Gradio app composition for Myco."""
7
 
8
- import gradio as gr
9
-
10
- from game.engine import collect_current, discover_mushroom, eat_current, myco_reply, study_current
11
- from game.state import welcome_history
12
  from __future__ import annotations
13
 
14
  import gradio as gr
@@ -20,7 +15,7 @@ from ui.renderers import dex_markdown, forest_scene, hero_markdown, mushroom_car
20
 
21
 
22
  # Keep Gradio callback signatures plain for Hugging Face Spaces parser stability.
23
- def explore(collection):
24
  """Gradio callback for the Start Exploring button."""
25
  mushroom, current, history = discover_mushroom(collection)
26
  return (
@@ -33,13 +28,6 @@ def explore(collection):
33
  )
34
 
35
 
36
- def ask_myco(message, history, current):
37
- def explore(collection: CollectionState) -> tuple[str, MushroomState, list[dict[str, str]], str, str]:
38
- """Gradio callback for the Start Exploring button."""
39
- mushroom, current, history = discover_mushroom(collection)
40
- return mushroom_card(mushroom), current, history, dex_markdown(collection), progress_markdown(collection)
41
-
42
-
43
  def ask_myco(
44
  message: str,
45
  history: list[dict[str, str]],
@@ -49,7 +37,6 @@ def ask_myco(
49
  return myco_reply(message, history, current)
50
 
51
 
52
- def add_to_dex(current, collection, history):
53
  def add_to_dex(
54
  current: MushroomState | None,
55
  collection: CollectionState,
@@ -66,7 +53,6 @@ def add_to_dex(
66
  )
67
 
68
 
69
- def study_mushroom(current, history, collection):
70
  def study_mushroom(
71
  current: MushroomState | None,
72
  history: list[dict[str, str]],
@@ -82,7 +68,6 @@ def study_mushroom(
82
  )
83
 
84
 
85
- def eat_mushroom(current, history):
86
  def eat_mushroom(
87
  current: MushroomState | None,
88
  history: list[dict[str, str]],
@@ -91,7 +76,6 @@ def eat_mushroom(
91
  return eat_current(current, history)
92
 
93
 
94
- def mushroom_card_from_state(current):
95
  def mushroom_card_from_state(current: MushroomState | None) -> str:
96
  """Render a mushroom card from Gradio state."""
97
  if current is None:
@@ -99,7 +83,6 @@ def mushroom_card_from_state(current: MushroomState | None) -> str:
99
  return mushroom_card(Mushroom.from_dict(current))
100
 
101
 
102
- def build_app():
103
  def build_app() -> gr.Blocks:
104
  """Build the Gradio interface for Hugging Face Spaces."""
105
  with gr.Blocks(title="Myco") as demo:
@@ -134,7 +117,6 @@ def build_app() -> gr.Blocks:
134
  explore,
135
  inputs=[collection],
136
  outputs=[scene, discovery, current_mushroom, chat, dex, progress],
137
- outputs=[discovery, current_mushroom, chat, dex, progress],
138
  )
139
  ask_button.click(ask_myco, inputs=[prompt, chat, current_mushroom], outputs=[prompt, chat])
140
  prompt.submit(ask_myco, inputs=[prompt, chat, current_mushroom], outputs=[prompt, chat])
 
3
  Callbacks intentionally avoid complex type annotations because Hugging Face Spaces
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 Gradio 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)
21
  return (
 
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:
 
117
  explore,
118
  inputs=[collection],
119
  outputs=[scene, discovery, current_mushroom, chat, dex, progress],
 
120
  )
121
  ask_button.click(ask_myco, inputs=[prompt, chat, current_mushroom], outputs=[prompt, chat])
122
  prompt.submit(ask_myco, inputs=[prompt, chat, current_mushroom], outputs=[prompt, chat])