HemanM commited on
Commit
e256998
Β·
verified Β·
1 Parent(s): e127a0b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +57 -23
app.py CHANGED
@@ -1,30 +1,64 @@
1
- # βœ… Fixed app.py for Hugging Face Space
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
- return predict(goal, sol1, sol2)
15
-
16
- demo = gr.Interface(
17
- fn=compare,
18
- inputs=[
19
- gr.Textbox(label="Goal", value=default_example["goal"]),
20
- gr.Textbox(label="Solution 1", value=default_example["sol1"]),
21
- gr.Textbox(label="Solution 2", value=default_example["sol2"])
22
- ],
23
- outputs=gr.Textbox(label="Preferred Solution"),
24
- title="EvoTransformer v2.1 - PIQA Commonsense Reasoning",
25
- theme="dark",
26
- allow_flagging="never",
27
- live=True
28
- )
29
-
30
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()