milwright commited on
Commit
0db6dde
·
verified ·
1 Parent(s): edc649c

Upload 4 files

Browse files
Files changed (2) hide show
  1. app.py +77 -18
  2. config.json +2 -3
app.py CHANGED
@@ -19,12 +19,12 @@ SPACE_DESCRIPTION = 'Interactive STEM adventure game guide'
19
  DEFAULT_CONFIG = {
20
  'name': SPACE_NAME,
21
  'description': SPACE_DESCRIPTION,
22
- 'system_prompt': "Simulate an interactive game-based learning experience through Choose Your Own STEM Adventure games featuring historically significant scientific experiments. Open each session with an unicode-styled arcade menu that reads 'STEM_ADV_GAMES` one stacked on top of the other. Underneath, frame the game in two sentences and widely sample 3-4 optional adventures from Wikipedia's List of Experiments. In the first stage, be brief and incrementally build more narrative content into the chat, immersing players in vivid historical moments written in second person (e.g. 'You are Galileo Galilei') that establish the year, location, prevailing beliefs, and tensions between established wisdom and emerging observations. Each section has 4 numbered decision points per stage that reflect experimental choices that subtly demonstrate a facet of the scientific method, with each choice meaningfully distinct in affording paths forward. Always end scenes with new branching choices that build a narrative progression based on concrete experimental procedures in laboratory environments. Offer backtracking options to emphasize how so-called failed experiments provide insights, balancing historical accuracy with engaging gameplay that shows how systematic thinking and creative problem-solving combine in scientific breakthroughs. Simulate a playful tone and arcade-styled aesthetic to keep the experience fun and engaging, while still being educational.",
23
  'temperature': 0.9,
24
  'max_tokens': 750,
25
  'model': 'qwen/qwen3-30b-a3b-instruct-2507',
26
  'api_key_var': 'API_KEY',
27
- 'theme': 'Base',
28
  'grounding_urls': ["https://en.wikipedia.org/wiki/List_of_experiments", "https://en.wikipedia.org/wiki/Scientific_method"],
29
  'enable_dynamic_urls': True,
30
  'enable_file_upload': True,
@@ -683,24 +683,45 @@ def create_interface():
683
  with gr.Tab("⚙️ Configuration"):
684
  gr.Markdown("## Configuration Management")
685
 
686
- # Show authentication status
687
- if HF_ACCESS_VALID:
688
- gr.Markdown(f"✅ {HF_ACCESS_MESSAGE}")
689
- gr.Markdown("Configuration changes will be saved to the HuggingFace repository.")
690
- else:
691
- gr.Markdown(f"ℹ️ {HF_ACCESS_MESSAGE}")
692
- gr.Markdown("Set HF_TOKEN in Space secrets to enable auto-save.")
693
 
694
- # Configuration editor
695
- gr.Markdown("### ⚙️ Configuration Editor")
696
-
697
- # Show lock status if locked
698
- if config.get('locked', False):
699
- gr.Markdown("⚠️ **Note:** Configuration is locked.")
 
 
 
 
 
 
 
 
 
700
 
701
- # Basic settings
702
- with gr.Column():
703
- edit_name = gr.Textbox(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
704
  label="Space Name",
705
  value=config.get('name', ''),
706
  max_lines=1
@@ -871,6 +892,44 @@ def create_interface():
871
  edit_temperature, edit_max_tokens, edit_examples, edit_grounding_urls,
872
  edit_enable_dynamic_urls, edit_enable_file_upload, config_status]
873
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
874
 
875
  # Access control handler
876
  if ACCESS_CODE:
 
19
  DEFAULT_CONFIG = {
20
  'name': SPACE_NAME,
21
  'description': SPACE_DESCRIPTION,
22
+ 'system_prompt': "Simulate an interactive game-based learning experience through Choose Your Own STEM Adventure games featuring historically significant scientific experiments. Open each session with a unicode arcade menu that welcomes users and frames the game in 2-3 sentences, then presents 3-4 adventures to choose from before proceeding based on user input. Simulate these adventures games in terms of randomly sampled experiments from Wikipedia's List of Experiments. Each stage includes 4 numbered decision points that reflect experimental choices made by the scientists associated with the chosen experiment. Each choice should be historically accurate and meaningfully distinct in simulating different paths forward. Be concise in stages 1-2 and incrementally build more narrative content into the chat from stages 3 onward. In the process, situate players in historical moments written in second person ('You are Marie Curie'). By the second choice, establish the year, location, prevailing beliefs, and tensions between established wisdom and emerging observations in the scientific zeitgeist of the experiment in question. Always end scenes with new branching choices that progress narratively based on concrete experimental procedures in laboratory environments grounded in historical fact. Provide backtracking options as a matter of game design, but also to emphasize how so-called failed experiments provide insights through trial-and-error. Employ a choose-your-own-adventure narrative tone of voice throughout the process and do not break the simulation unless explicitly instructed to do so, in which case reset to the menu screen.",
23
  'temperature': 0.9,
24
  'max_tokens': 750,
25
  'model': 'qwen/qwen3-30b-a3b-instruct-2507',
26
  'api_key_var': 'API_KEY',
27
+ 'theme': 'Default',
28
  'grounding_urls': ["https://en.wikipedia.org/wiki/List_of_experiments", "https://en.wikipedia.org/wiki/Scientific_method"],
29
  'enable_dynamic_urls': True,
30
  'enable_file_upload': True,
 
683
  with gr.Tab("⚙️ Configuration"):
684
  gr.Markdown("## Configuration Management")
685
 
686
+ # State for config tab authentication
687
+ config_authenticated = gr.State(False)
 
 
 
 
 
688
 
689
+ # Authentication panel
690
+ with gr.Column(visible=True) as config_auth_panel:
691
+ gr.Markdown("### 🔐 Authentication Required")
692
+ gr.Markdown("Enter your HF_TOKEN to access configuration settings:")
693
+
694
+ with gr.Row():
695
+ config_password = gr.Textbox(
696
+ label="HF Token",
697
+ placeholder="Enter your HF_TOKEN...",
698
+ type="password",
699
+ scale=3
700
+ )
701
+ config_auth_btn = gr.Button("Authenticate", variant="primary", scale=1)
702
+
703
+ config_auth_status = gr.Markdown()
704
 
705
+ # Configuration panel (hidden until authenticated)
706
+ with gr.Column(visible=False) as config_panel:
707
+ # Show authentication status
708
+ if HF_ACCESS_VALID:
709
+ gr.Markdown(f"✅ {HF_ACCESS_MESSAGE}")
710
+ gr.Markdown("Configuration changes will be saved to the HuggingFace repository.")
711
+ else:
712
+ gr.Markdown(f"ℹ️ {HF_ACCESS_MESSAGE}")
713
+ gr.Markdown("Set HF_TOKEN in Space secrets to enable auto-save.")
714
+
715
+ # Configuration editor
716
+ gr.Markdown("### ⚙️ Configuration Editor")
717
+
718
+ # Show lock status if locked
719
+ if config.get('locked', False):
720
+ gr.Markdown("⚠️ **Note:** Configuration is locked.")
721
+
722
+ # Basic settings
723
+ with gr.Column():
724
+ edit_name = gr.Textbox(
725
  label="Space Name",
726
  value=config.get('name', ''),
727
  max_lines=1
 
892
  edit_temperature, edit_max_tokens, edit_examples, edit_grounding_urls,
893
  edit_enable_dynamic_urls, edit_enable_file_upload, config_status]
894
  )
895
+
896
+ # Configuration tab authentication handler
897
+ def handle_config_auth(password):
898
+ """Handle configuration tab authentication"""
899
+ if not HF_TOKEN:
900
+ return (
901
+ gr.update(visible=True), # Keep auth panel visible
902
+ gr.update(visible=False), # Keep config panel hidden
903
+ gr.update(value="❌ No HF_TOKEN is set in Space secrets. Configuration cannot be enabled."),
904
+ False
905
+ )
906
+
907
+ if password == HF_TOKEN:
908
+ return (
909
+ gr.update(visible=False), # Hide auth panel
910
+ gr.update(visible=True), # Show config panel
911
+ gr.update(value="✅ Authentication successful!"),
912
+ True
913
+ )
914
+ else:
915
+ return (
916
+ gr.update(visible=True), # Keep auth panel visible
917
+ gr.update(visible=False), # Keep config panel hidden
918
+ gr.update(value="❌ Invalid HF_TOKEN. Please try again."),
919
+ False
920
+ )
921
+
922
+ config_auth_btn.click(
923
+ handle_config_auth,
924
+ inputs=[config_password],
925
+ outputs=[config_auth_panel, config_panel, config_auth_status, config_authenticated]
926
+ )
927
+
928
+ config_password.submit(
929
+ handle_config_auth,
930
+ inputs=[config_password],
931
+ outputs=[config_auth_panel, config_panel, config_auth_status, config_authenticated]
932
+ )
933
 
934
  # Access control handler
935
  if ACCESS_CODE:
config.json CHANGED
@@ -2,7 +2,7 @@
2
  "name": "STEM Adventure Games",
3
  "tagline": "Interactive STEM adventure game guide",
4
  "description": "Interactive STEM adventure game guide",
5
- "system_prompt": "Simulate an interactive game-based learning experience through Choose Your Own STEM Adventure games featuring historically significant scientific experiments. Open each session with an unicode-styled arcade menu that reads 'STEM_ADV_GAMES` one stacked on top of the other. Underneath, frame the game in two sentences and widely sample 3-4 optional adventures from Wikipedia's List of Experiments. In the first stage, be brief and incrementally build more narrative content into the chat, immersing players in vivid historical moments written in second person (e.g. 'You are Galileo Galilei') that establish the year, location, prevailing beliefs, and tensions between established wisdom and emerging observations. Each section has 4 numbered decision points per stage that reflect experimental choices that subtly demonstrate a facet of the scientific method, with each choice meaningfully distinct in affording paths forward. Always end scenes with new branching choices that build a narrative progression based on concrete experimental procedures in laboratory environments. Offer backtracking options to emphasize how so-called failed experiments provide insights, balancing historical accuracy with engaging gameplay that shows how systematic thinking and creative problem-solving combine in scientific breakthroughs. Simulate a playful tone and arcade-styled aesthetic to keep the experience fun and engaging, while still being educational.",
6
  "model": "qwen/qwen3-30b-a3b-instruct-2507",
7
  "api_key_var": "API_KEY",
8
  "temperature": 0.9,
@@ -18,6 +18,5 @@
18
  ],
19
  "enable_dynamic_urls": true,
20
  "enable_file_upload": true,
21
- "theme": "Base",
22
- "locked": false
23
  }
 
2
  "name": "STEM Adventure Games",
3
  "tagline": "Interactive STEM adventure game guide",
4
  "description": "Interactive STEM adventure game guide",
5
+ "system_prompt": "Simulate an interactive game-based learning experience through Choose Your Own STEM Adventure games featuring historically significant scientific experiments. Open each session with a unicode arcade menu that welcomes users and frames the game in 2-3 sentences, then presents 3-4 adventures to choose from before proceeding based on user input. Simulate these adventures games in terms of randomly sampled experiments from Wikipedia's List of Experiments. Each stage includes 4 numbered decision points that reflect experimental choices made by the scientists associated with the chosen experiment. Each choice should be historically accurate and meaningfully distinct in simulating different paths forward. Be concise in stages 1-2 and incrementally build more narrative content into the chat from stages 3 onward. In the process, situate players in historical moments written in second person ('You are Marie Curie'). By the second choice, establish the year, location, prevailing beliefs, and tensions between established wisdom and emerging observations in the scientific zeitgeist of the experiment in question. Always end scenes with new branching choices that progress narratively based on concrete experimental procedures in laboratory environments grounded in historical fact. Provide backtracking options as a matter of game design, but also to emphasize how so-called failed experiments provide insights through trial-and-error. Employ a choose-your-own-adventure narrative tone of voice throughout the process and do not break the simulation unless explicitly instructed to do so, in which case reset to the menu screen.",
6
  "model": "qwen/qwen3-30b-a3b-instruct-2507",
7
  "api_key_var": "API_KEY",
8
  "temperature": 0.9,
 
18
  ],
19
  "enable_dynamic_urls": true,
20
  "enable_file_upload": true,
21
+ "theme": "Default"
 
22
  }