Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,60 +1,69 @@
|
|
1 |
import gradio as gr
|
2 |
-
import datetime
|
3 |
from inference import generate_response
|
4 |
-
from logger import
|
5 |
-
from
|
6 |
-
from
|
7 |
|
8 |
-
|
|
|
|
|
9 |
|
10 |
-
# Reinitialize EvoTransformer model on startup
|
11 |
-
initialize_evo_model()
|
12 |
-
|
13 |
-
# Gradio app logic
|
14 |
def evo_chat(goal, sol1, sol2):
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
return "", "", "", suggestion, "", gr.update(visible=True)
|
20 |
-
|
21 |
-
def log_user_feedback(goal, sol1, sol2, winner):
|
22 |
-
status = log_feedback(goal, sol1, sol2, winner)
|
23 |
-
return status
|
24 |
|
25 |
-
def
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
28 |
|
29 |
-
with gr.Blocks(
|
30 |
gr.Markdown("## π§ EvoTransformer v2.1 β Compare Options and Learn")
|
31 |
|
32 |
with gr.Row():
|
33 |
-
|
34 |
-
|
35 |
with gr.Row():
|
36 |
-
|
37 |
-
|
|
|
|
|
38 |
|
39 |
with gr.Row():
|
40 |
-
|
41 |
-
|
42 |
-
model_suggestion = gr.Textbox(label="Model Suggestion")
|
43 |
-
|
44 |
-
compare_button = gr.Button("π Compare")
|
45 |
-
compare_button.click(evo_chat, inputs=[goal, sol1, sol2], outputs=[error_box, sol1, sol2, model_suggestion, goal, compare_button])
|
46 |
|
47 |
with gr.Row():
|
48 |
-
|
49 |
feedback_btn = gr.Button("β
Log Feedback")
|
50 |
-
feedback_status = gr.Textbox(label="", interactive=False)
|
51 |
-
feedback_btn.click(log_user_feedback, inputs=[goal, sol1, sol2, winner_choice], outputs=[feedback_status])
|
52 |
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
with gr.Row():
|
55 |
retrain_button = gr.Button("β»οΈ Retrain Evo")
|
56 |
-
|
57 |
-
|
|
|
58 |
|
59 |
-
|
60 |
-
demo.launch(share=True
|
|
|
1 |
import gradio as gr
|
|
|
2 |
from inference import generate_response
|
3 |
+
from logger import log_user_feedback
|
4 |
+
from dashboard import update_dashboard_plot
|
5 |
+
from watchdog import retrain_model
|
6 |
|
7 |
+
evo_output = gr.Textbox(label="π§ EvoTransformer Suggestion")
|
8 |
+
gpt_output = gr.Textbox(label="π¬ GPT-3.5 Suggestion")
|
9 |
+
feedback_output = gr.Textbox(visible=False)
|
10 |
|
|
|
|
|
|
|
|
|
11 |
def evo_chat(goal, sol1, sol2):
|
12 |
+
response = generate_response(goal, sol1, sol2)
|
13 |
+
evo = response.get("evo_suggestion", "Error")
|
14 |
+
gpt = response.get("gpt_suggestion", "Error")
|
15 |
+
return evo, gpt
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
+
def handle_feedback(goal, sol1, sol2, winner):
|
18 |
+
try:
|
19 |
+
log_user_feedback(goal, sol1, sol2, winner)
|
20 |
+
return "β
Feedback logged. Thank you!"
|
21 |
+
except Exception as e:
|
22 |
+
return f"β Failed to log: {e}"
|
23 |
|
24 |
+
with gr.Blocks(title="EvoTransformer v2.1 β Compare Options and Learn") as demo:
|
25 |
gr.Markdown("## π§ EvoTransformer v2.1 β Compare Options and Learn")
|
26 |
|
27 |
with gr.Row():
|
28 |
+
goal_input = gr.Textbox(label="Goal", placeholder="e.g. Escape from house on fire")
|
|
|
29 |
with gr.Row():
|
30 |
+
option1_input = gr.Textbox(label="Option 1", placeholder="e.g. Exit house through main door")
|
31 |
+
option2_input = gr.Textbox(label="Option 2", placeholder="e.g. Hide under bed")
|
32 |
+
|
33 |
+
compare_btn = gr.Button("π Compare")
|
34 |
|
35 |
with gr.Row():
|
36 |
+
evo_output.render()
|
37 |
+
gpt_output.render()
|
|
|
|
|
|
|
|
|
38 |
|
39 |
with gr.Row():
|
40 |
+
winner_dropdown = gr.Radio(["Solution 1", "Solution 2"], label="Which was better?")
|
41 |
feedback_btn = gr.Button("β
Log Feedback")
|
|
|
|
|
42 |
|
43 |
+
feedback_output.render()
|
44 |
+
|
45 |
+
compare_btn.click(
|
46 |
+
fn=evo_chat,
|
47 |
+
inputs=[goal_input, option1_input, option2_input],
|
48 |
+
outputs=[evo_output, gpt_output]
|
49 |
+
)
|
50 |
+
|
51 |
+
feedback_btn.click(
|
52 |
+
fn=handle_feedback,
|
53 |
+
inputs=[goal_input, option1_input, option2_input, winner_dropdown],
|
54 |
+
outputs=[feedback_output]
|
55 |
+
)
|
56 |
+
|
57 |
+
with gr.Row():
|
58 |
+
gr.Markdown("### π Dashboard")
|
59 |
+
dashboard_plot = gr.Plot()
|
60 |
+
update_dashboard_plot(dashboard_plot)
|
61 |
+
|
62 |
with gr.Row():
|
63 |
retrain_button = gr.Button("β»οΈ Retrain Evo")
|
64 |
+
retrain_status = gr.Textbox(label="Retrain Status")
|
65 |
+
|
66 |
+
retrain_button.click(fn=retrain_model, inputs=[], outputs=[retrain_status])
|
67 |
|
68 |
+
if __name__ == "__main__":
|
69 |
+
demo.launch(share=True)
|