Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- ui/gradio_app.py +0 -22
ui/gradio_app.py
CHANGED
|
@@ -14,15 +14,6 @@ def explore(collection: CollectionState) -> tuple[str, MushroomState, list[dict[
|
|
| 14 |
"""Gradio callback for the Start Exploring button."""
|
| 15 |
mushroom, current, history = discover_mushroom(collection)
|
| 16 |
return mushroom_card(mushroom), current, history, dex_markdown(collection), progress_markdown(collection)
|
| 17 |
-
from game.engine import collect_current, discover_mushroom, myco_reply
|
| 18 |
-
from game.state import CollectionState, MushroomState, welcome_history
|
| 19 |
-
from ui.renderers import dex_markdown, mushroom_card
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
def explore(collection: CollectionState) -> tuple[str, MushroomState, list[dict[str, str]], str]:
|
| 23 |
-
"""Gradio callback for the Explore button."""
|
| 24 |
-
mushroom, current, history = discover_mushroom(collection)
|
| 25 |
-
return mushroom_card(mushroom), current, history, dex_markdown(collection)
|
| 26 |
|
| 27 |
|
| 28 |
def ask_myco(
|
|
@@ -66,10 +57,6 @@ def mushroom_card_from_state(current: MushroomState | None) -> str:
|
|
| 66 |
if current is None:
|
| 67 |
return mushroom_card(None)
|
| 68 |
return mushroom_card(Mushroom.from_dict(current))
|
| 69 |
-
) -> tuple[CollectionState, str, list[dict[str, str]]]:
|
| 70 |
-
"""Gradio callback for collecting the current mushroom."""
|
| 71 |
-
updated_collection, updated_history = collect_current(current, collection, history)
|
| 72 |
-
return updated_collection, dex_markdown(updated_collection), updated_history
|
| 73 |
|
| 74 |
|
| 75 |
def build_app() -> gr.Blocks:
|
|
@@ -96,14 +83,12 @@ def build_app() -> gr.Blocks:
|
|
| 96 |
eat_button = gr.Button("Eat")
|
| 97 |
collect_button = gr.Button("Collect")
|
| 98 |
study_button = gr.Button("Study")
|
| 99 |
-
explore_button = gr.Button("Explore", variant="primary")
|
| 100 |
add_button = gr.Button("Add to MycoDex")
|
| 101 |
with gr.Column(scale=3):
|
| 102 |
chat = gr.Chatbot(value=welcome_history(), label="Myco Chat", height=360)
|
| 103 |
with gr.Row():
|
| 104 |
prompt = gr.Textbox(
|
| 105 |
label="Ask Myco",
|
| 106 |
-
placeholder="Myco, should I eat this?",
|
| 107 |
placeholder="What do you know about this mushroom?",
|
| 108 |
scale=4,
|
| 109 |
)
|
|
@@ -112,7 +97,6 @@ def build_app() -> gr.Blocks:
|
|
| 112 |
with gr.Row():
|
| 113 |
progress = gr.Markdown(progress_markdown([]), elem_id="progress-panel")
|
| 114 |
dex = gr.Markdown(dex_markdown([]), elem_id="mycodex")
|
| 115 |
-
dex = gr.Markdown(dex_markdown([]), elem_id="mycodex")
|
| 116 |
|
| 117 |
explore_button.click(
|
| 118 |
explore,
|
|
@@ -129,11 +113,5 @@ def build_app() -> gr.Blocks:
|
|
| 129 |
study_button.click(study_mushroom, inputs=[current_mushroom, chat], outputs=[current_mushroom, discovery, chat])
|
| 130 |
eat_button.click(eat_mushroom, inputs=[current_mushroom, chat], outputs=[chat])
|
| 131 |
|
| 132 |
-
outputs=[discovery, current_mushroom, chat, dex],
|
| 133 |
-
)
|
| 134 |
-
ask_button.click(ask_myco, inputs=[prompt, chat, current_mushroom], outputs=[prompt, chat])
|
| 135 |
-
prompt.submit(ask_myco, inputs=[prompt, chat, current_mushroom], outputs=[prompt, chat])
|
| 136 |
-
add_button.click(add_to_dex, inputs=[current_mushroom, collection, chat], outputs=[collection, dex, chat])
|
| 137 |
-
|
| 138 |
demo._theme = theme
|
| 139 |
return demo
|
|
|
|
| 14 |
"""Gradio callback for the Start Exploring button."""
|
| 15 |
mushroom, current, history = discover_mushroom(collection)
|
| 16 |
return mushroom_card(mushroom), current, history, dex_markdown(collection), progress_markdown(collection)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
|
| 19 |
def ask_myco(
|
|
|
|
| 57 |
if current is None:
|
| 58 |
return mushroom_card(None)
|
| 59 |
return mushroom_card(Mushroom.from_dict(current))
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
|
| 62 |
def build_app() -> gr.Blocks:
|
|
|
|
| 83 |
eat_button = gr.Button("Eat")
|
| 84 |
collect_button = gr.Button("Collect")
|
| 85 |
study_button = gr.Button("Study")
|
|
|
|
| 86 |
add_button = gr.Button("Add to MycoDex")
|
| 87 |
with gr.Column(scale=3):
|
| 88 |
chat = gr.Chatbot(value=welcome_history(), label="Myco Chat", height=360)
|
| 89 |
with gr.Row():
|
| 90 |
prompt = gr.Textbox(
|
| 91 |
label="Ask Myco",
|
|
|
|
| 92 |
placeholder="What do you know about this mushroom?",
|
| 93 |
scale=4,
|
| 94 |
)
|
|
|
|
| 97 |
with gr.Row():
|
| 98 |
progress = gr.Markdown(progress_markdown([]), elem_id="progress-panel")
|
| 99 |
dex = gr.Markdown(dex_markdown([]), elem_id="mycodex")
|
|
|
|
| 100 |
|
| 101 |
explore_button.click(
|
| 102 |
explore,
|
|
|
|
| 113 |
study_button.click(study_mushroom, inputs=[current_mushroom, chat], outputs=[current_mushroom, discovery, chat])
|
| 114 |
eat_button.click(eat_mushroom, inputs=[current_mushroom, chat], outputs=[chat])
|
| 115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
demo._theme = theme
|
| 117 |
return demo
|