Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,8 @@ from inference import predict
|
|
3 |
from logger import log_feedback_to_firebase
|
4 |
import openai
|
5 |
import os
|
|
|
|
|
6 |
|
7 |
openai.api_key = os.environ["OPENAI_API_KEY"] # Add this secret in your Hugging Face Space
|
8 |
|
@@ -23,7 +25,6 @@ def compare(goal, sol1, sol2, correct):
|
|
23 |
evo = predict(goal, sol1, sol2)
|
24 |
gpt = gpt_predict(goal, sol1, sol2)
|
25 |
|
26 |
-
# Determine outcome
|
27 |
if evo == gpt == correct:
|
28 |
verdict = "β
Both Evo and GPT-3.5 are correct!"
|
29 |
elif evo == correct and gpt != correct:
|
@@ -33,45 +34,56 @@ def compare(goal, sol1, sol2, correct):
|
|
33 |
else:
|
34 |
verdict = "β Both models got it wrong."
|
35 |
|
36 |
-
# Log to Firebase
|
37 |
log_feedback_to_firebase(goal, sol1, sol2, evo, gpt, correct, "from app.py")
|
38 |
|
39 |
return evo, gpt, verdict
|
40 |
|
|
|
|
|
|
|
|
|
41 |
with gr.Blocks() as demo:
|
42 |
-
gr.
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
from logger import log_feedback_to_firebase
|
4 |
import openai
|
5 |
import os
|
6 |
+
from watchdog import manual_retrain
|
7 |
+
from dashboard import render_dashboard
|
8 |
|
9 |
openai.api_key = os.environ["OPENAI_API_KEY"] # Add this secret in your Hugging Face Space
|
10 |
|
|
|
25 |
evo = predict(goal, sol1, sol2)
|
26 |
gpt = gpt_predict(goal, sol1, sol2)
|
27 |
|
|
|
28 |
if evo == gpt == correct:
|
29 |
verdict = "β
Both Evo and GPT-3.5 are correct!"
|
30 |
elif evo == correct and gpt != correct:
|
|
|
34 |
else:
|
35 |
verdict = "β Both models got it wrong."
|
36 |
|
|
|
37 |
log_feedback_to_firebase(goal, sol1, sol2, evo, gpt, correct, "from app.py")
|
38 |
|
39 |
return evo, gpt, verdict
|
40 |
|
41 |
+
def trigger_retrain():
|
42 |
+
success = manual_retrain()
|
43 |
+
return "β
Evo retrained successfully!" if success else "β οΈ Retraining failed."
|
44 |
+
|
45 |
with gr.Blocks() as demo:
|
46 |
+
with gr.Tab("βοΈ Evo vs GPT-3.5 Showdown"):
|
47 |
+
gr.Markdown("## βοΈ Evo vs GPT-3.5 β Real-Time Commonsense Showdown")
|
48 |
+
gr.Markdown(
|
49 |
+
"> π§ EvoTransformer v2.1 β PIQA Accuracy: 69.7% (vs GPT-3.5 β 81%)\n"
|
50 |
+
"> 13M Parameters β’ Fully Scratch-Trained β’ Leans Smart\n"
|
51 |
+
"> π§ͺ *Note: EvoTransformer is a scratch-built model trained on 1K PIQA examples. It may occasionally misinterpret context or idioms. Thatβs part of its evolution.*"
|
52 |
+
)
|
53 |
+
gr.Markdown(
|
54 |
+
"> π *EvoTransformer is not static. Every time you provide feedback, Evo learns and evolves. Welcome to real-time neural evolution.*"
|
55 |
+
)
|
56 |
+
|
57 |
+
with gr.Row():
|
58 |
+
goal = gr.Text(label="Goal")
|
59 |
+
with gr.Row():
|
60 |
+
sol1 = gr.Text(label="Solution 1")
|
61 |
+
sol2 = gr.Text(label="Solution 2")
|
62 |
+
correct = gr.Radio(choices=["Solution 1", "Solution 2"], label="β
Which is actually correct?", value="Solution 1")
|
63 |
+
|
64 |
+
btn = gr.Button("Submit")
|
65 |
+
evo_out = gr.Text(label="π§ EvoTransformer Response")
|
66 |
+
gpt_out = gr.Text(label="π€ GPT-3.5 Response")
|
67 |
+
verdict_out = gr.Text(label="βοΈ Verdict")
|
68 |
+
|
69 |
+
btn.click(fn=compare, inputs=[goal, sol1, sol2, correct], outputs=[evo_out, gpt_out, verdict_out])
|
70 |
+
|
71 |
+
gr.Markdown("#### π Try These Examples:")
|
72 |
+
examples = [
|
73 |
+
["Start a fire", "Use a match", "Pour water", "Solution 1"],
|
74 |
+
["Warm up food", "Use microwave", "Put it in fridge", "Solution 1"],
|
75 |
+
["Charge a phone", "Plug it in", "Put it on grass", "Solution 1"],
|
76 |
+
["Get rid of bad smell", "Open window", "Close door", "Solution 1"],
|
77 |
+
]
|
78 |
+
gr.Examples(examples=examples, inputs=[goal, sol1, sol2, correct])
|
79 |
+
|
80 |
+
retrain_btn = gr.Button("π Retrain EvoTransformer")
|
81 |
+
retrain_status = gr.Text(label="π’ Retrain Status")
|
82 |
+
retrain_btn.click(fn=trigger_retrain, outputs=[retrain_status])
|
83 |
+
|
84 |
+
gr.Markdown("Made with β€οΈ by Dr. Heman Mohabeer β EvoTransformer is not just code. It's evolution.")
|
85 |
+
|
86 |
+
with gr.Tab("π Evo Dashboard"):
|
87 |
+
render_dashboard()
|
88 |
+
|
89 |
+
demo.launch()
|