Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,64 @@
|
|
1 |
-
# β
|
2 |
-
default_example = {
|
3 |
-
"goal": "Light a dark room",
|
4 |
-
"sol1": "Use a candle",
|
5 |
-
"sol2": "Close the curtains"
|
6 |
-
}
|
7 |
|
8 |
import gradio as gr
|
9 |
from inference import predict
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
def compare(goal, sol1, sol2):
|
12 |
if not goal.strip() or not sol1.strip() or not sol2.strip():
|
13 |
return "β οΈ Please provide all three inputs."
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
)
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# β
Enhanced EvoTransformer Gradio App β Vivid, Live, Intelligent
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
import gradio as gr
|
4 |
from inference import predict
|
5 |
|
6 |
+
EXAMPLES = [
|
7 |
+
[
|
8 |
+
"Start a fire in a fireplace",
|
9 |
+
"Put a lit match on dry wood",
|
10 |
+
"Pour water on logs"
|
11 |
+
],
|
12 |
+
[
|
13 |
+
"Warm a cup of tea",
|
14 |
+
"Put it in a microwave",
|
15 |
+
"Put it in the freezer"
|
16 |
+
],
|
17 |
+
[
|
18 |
+
"Open a locked door",
|
19 |
+
"Use a key",
|
20 |
+
"Look at the door intensely"
|
21 |
+
],
|
22 |
+
[
|
23 |
+
"Charge a phone",
|
24 |
+
"Plug it into a charger",
|
25 |
+
"Place it on a glass table"
|
26 |
+
]
|
27 |
+
]
|
28 |
+
|
29 |
def compare(goal, sol1, sol2):
|
30 |
if not goal.strip() or not sol1.strip() or not sol2.strip():
|
31 |
return "β οΈ Please provide all three inputs."
|
32 |
+
result = predict(goal, sol1, sol2)
|
33 |
+
explanation = f"β
EvoTransformer believes **{result}** is the better choice for the goal \"{goal}\"."
|
34 |
+
return explanation
|
35 |
+
|
36 |
+
with gr.Blocks(title="EvoTransformer: Real-Time Reasoning AI") as demo:
|
37 |
+
gr.Markdown("""
|
38 |
+
# π§ EvoTransformer v2.1 β Commonsense Reasoning in Action
|
39 |
+
Trained on the PIQA dataset. Designed to **choose the most logical solution** between two options.
|
40 |
+
EvoTransformer runs lean β no big GPUs required β and still delivers intelligent behavior.
|
41 |
+
""")
|
42 |
+
|
43 |
+
with gr.Row():
|
44 |
+
goal = gr.Textbox(label="Goal", placeholder="e.g., Heat up food")
|
45 |
+
with gr.Row():
|
46 |
+
sol1 = gr.Textbox(label="Solution 1", placeholder="e.g., Use a microwave")
|
47 |
+
sol2 = gr.Textbox(label="Solution 2", placeholder="e.g., Put it in the fridge")
|
48 |
+
out = gr.Markdown()
|
49 |
+
|
50 |
+
submit = gr.Button("Let Evo Decide")
|
51 |
+
submit.click(fn=compare, inputs=[goal, sol1, sol2], outputs=out)
|
52 |
+
|
53 |
+
gr.Markdown("### π Try These Examples:")
|
54 |
+
gr.Examples(
|
55 |
+
examples=EXAMPLES,
|
56 |
+
inputs=[goal, sol1, sol2],
|
57 |
+
outputs=[out],
|
58 |
+
fn=compare,
|
59 |
+
cache_examples=False
|
60 |
+
)
|
61 |
+
|
62 |
+
gr.Markdown("---\nMade with β€οΈ by Dr. Heman Mohabeer β EvoTransformer is not just code. It's evolution.")
|
63 |
+
|
64 |
+
demo.launch()
|