HemanM commited on
Commit
b7194b1
Β·
verified Β·
1 Parent(s): 3bfaa31

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -10
app.py CHANGED
@@ -1,5 +1,11 @@
1
-
2
  import os
 
 
 
 
 
 
 
3
 
4
  # βœ… Check if trained_model/config.json exists, if not, initialize the model
5
  if not os.path.exists("trained_model/config.json"):
@@ -7,14 +13,40 @@ if not os.path.exists("trained_model/config.json"):
7
  print("βš™οΈ Reinitializing EvoTransformer model...")
8
  initialize_and_save_model()
9
 
10
-
11
-
12
- import gradio as gr
13
- from inference import generate_response
14
- from logger import log_user_feedback
15
- from dashboard import update_dashboard_plot
16
- from watchdog import retrain_model
17
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  evo_output = gr.Textbox(label="🧠 EvoTransformer Suggestion")
19
  gpt_output = gr.Textbox(label="πŸ’¬ GPT-3.5 Suggestion")
20
  feedback_output = gr.Textbox(visible=False)
@@ -41,7 +73,9 @@ with gr.Blocks(title="EvoTransformer v2.1 – Compare Options and Learn") as dem
41
  option1_input = gr.Textbox(label="Option 1", placeholder="e.g. Exit house through main door")
42
  option2_input = gr.Textbox(label="Option 2", placeholder="e.g. Hide under bed")
43
 
44
- compare_btn = gr.Button("πŸ” Compare")
 
 
45
 
46
  with gr.Row():
47
  evo_output.render()
@@ -59,6 +93,12 @@ with gr.Blocks(title="EvoTransformer v2.1 – Compare Options and Learn") as dem
59
  outputs=[evo_output, gpt_output]
60
  )
61
 
 
 
 
 
 
 
62
  feedback_btn.click(
63
  fn=handle_feedback,
64
  inputs=[goal_input, option1_input, option2_input, winner_dropdown],
 
 
1
  import os
2
+ import gradio as gr
3
+ import random
4
+
5
+ from inference import generate_response
6
+ from logger import log_user_feedback
7
+ from dashboard import update_dashboard_plot
8
+ from watchdog import retrain_model
9
 
10
  # βœ… Check if trained_model/config.json exists, if not, initialize the model
11
  if not os.path.exists("trained_model/config.json"):
 
13
  print("βš™οΈ Reinitializing EvoTransformer model...")
14
  initialize_and_save_model()
15
 
16
+ # 🎲 Random examples
17
+ examples = [
18
+ {
19
+ "goal": "Escape from a burning house",
20
+ "option1": "Run out through the front door",
21
+ "option2": "Hide in the bathroom"
22
+ },
23
+ {
24
+ "goal": "Improve sleep quality",
25
+ "option1": "Use phone in bed",
26
+ "option2": "Turn off screens 1 hour before bed"
27
+ },
28
+ {
29
+ "goal": "Increase productivity at work",
30
+ "option1": "Multitask all day",
31
+ "option2": "Use Pomodoro technique"
32
+ },
33
+ {
34
+ "goal": "Lose weight safely",
35
+ "option1": "Skip meals",
36
+ "option2": "Exercise regularly and eat balanced meals"
37
+ },
38
+ {
39
+ "goal": "Ace an exam",
40
+ "option1": "Cram the night before",
41
+ "option2": "Study consistently for 2 weeks"
42
+ },
43
+ ]
44
+
45
+ def load_random_example():
46
+ example = random.choice(examples)
47
+ return example["goal"], example["option1"], example["option2"]
48
+
49
+ # 🧠 Model suggestion UI
50
  evo_output = gr.Textbox(label="🧠 EvoTransformer Suggestion")
51
  gpt_output = gr.Textbox(label="πŸ’¬ GPT-3.5 Suggestion")
52
  feedback_output = gr.Textbox(visible=False)
 
73
  option1_input = gr.Textbox(label="Option 1", placeholder="e.g. Exit house through main door")
74
  option2_input = gr.Textbox(label="Option 2", placeholder="e.g. Hide under bed")
75
 
76
+ with gr.Row():
77
+ compare_btn = gr.Button("πŸ” Compare")
78
+ random_btn = gr.Button("🎲 Load Random Example")
79
 
80
  with gr.Row():
81
  evo_output.render()
 
93
  outputs=[evo_output, gpt_output]
94
  )
95
 
96
+ random_btn.click(
97
+ fn=load_random_example,
98
+ inputs=[],
99
+ outputs=[goal_input, option1_input, option2_input]
100
+ )
101
+
102
  feedback_btn.click(
103
  fn=handle_feedback,
104
  inputs=[goal_input, option1_input, option2_input, winner_dropdown],