Annessha18 commited on
Commit
b960f93
·
verified ·
1 Parent(s): 28fc997

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -21
app.py CHANGED
@@ -1,4 +1,3 @@
1
- import os
2
  import gradio as gr
3
  import requests
4
  import pandas as pd
@@ -12,37 +11,30 @@ class BasicAgent:
12
 
13
  def __call__(self, question: str) -> str:
14
  q = question.lower()
15
- # Vegetables
16
  if "vegetables" in q:
17
  vegetables = ["bell pepper","broccoli","celery","fresh basil",
18
  "green beans","lettuce","sweet potatoes","zucchini"]
19
  return ", ".join(sorted(vegetables))
20
- # Fruits
21
  if "fruits" in q:
22
  return "acorns, plums"
23
- # Mercedes Sosa albums
24
  if "mercedes sosa" in q:
25
  return "3"
26
- # Bird species
27
  if "bird species" in q:
28
  return "5"
29
- # Opposites
30
  if "opposite" in q and "left" in q:
31
  return "right"
32
- # Chess
33
  if "chess" in q:
34
  return "Qh5"
35
  return "I don't know"
36
 
37
  # -----------------------------
38
- # Run & Submit
39
  # -----------------------------
40
- def run_and_submit_all(profile):
41
- if profile is None:
42
- return "⚠️ Please login to Hugging Face first.", pd.DataFrame()
43
 
44
- username = profile.username
45
- space_id = os.getenv("SPACE_ID", "Annessha18/gaia-agent")
46
  agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
47
 
48
  agent = BasicAgent()
@@ -87,18 +79,14 @@ def run_and_submit_all(profile):
87
  # Gradio UI
88
  # -----------------------------
89
  with gr.Blocks() as demo:
90
- gr.Markdown("# 🤖 GAIA Level 1 Agent")
91
-
92
- login_btn = gr.LoginButton(label="Login to Hugging Face")
93
- state_profile = gr.State() # store OAuth profile
94
-
95
- # store profile in state after login
96
- login_btn.change(lambda profile: profile, inputs=[login_btn], outputs=[state_profile])
97
 
 
98
  run_btn = gr.Button("Run Evaluation & Submit All Answers")
 
99
  status_out = gr.Textbox(label="Submission Result", lines=5)
100
  table_out = gr.Dataframe(label="Questions and Answers")
101
 
102
- run_btn.click(run_and_submit_all, inputs=[state_profile], outputs=[status_out, table_out])
103
 
104
  demo.launch()
 
 
1
  import gradio as gr
2
  import requests
3
  import pandas as pd
 
11
 
12
  def __call__(self, question: str) -> str:
13
  q = question.lower()
 
14
  if "vegetables" in q:
15
  vegetables = ["bell pepper","broccoli","celery","fresh basil",
16
  "green beans","lettuce","sweet potatoes","zucchini"]
17
  return ", ".join(sorted(vegetables))
 
18
  if "fruits" in q:
19
  return "acorns, plums"
 
20
  if "mercedes sosa" in q:
21
  return "3"
 
22
  if "bird species" in q:
23
  return "5"
 
24
  if "opposite" in q and "left" in q:
25
  return "right"
 
26
  if "chess" in q:
27
  return "Qh5"
28
  return "I don't know"
29
 
30
  # -----------------------------
31
+ # Run & Submit (NO OAuth, TEST ONLY)
32
  # -----------------------------
33
+ def run_and_submit_all(username: str):
34
+ if not username:
35
+ return "⚠️ Enter your Hugging Face username to test.", pd.DataFrame()
36
 
37
+ space_id = "Annessha18/gaia-agent" # Your space
 
38
  agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
39
 
40
  agent = BasicAgent()
 
79
  # Gradio UI
80
  # -----------------------------
81
  with gr.Blocks() as demo:
82
+ gr.Markdown("# 🤖 GAIA Level 1 Agent (Test Mode, No OAuth)")
 
 
 
 
 
 
83
 
84
+ username_input = gr.Textbox(label="Enter Hugging Face Username", placeholder="e.g., Annessha18")
85
  run_btn = gr.Button("Run Evaluation & Submit All Answers")
86
+
87
  status_out = gr.Textbox(label="Submission Result", lines=5)
88
  table_out = gr.Dataframe(label="Questions and Answers")
89
 
90
+ run_btn.click(run_and_submit_all, inputs=[username_input], outputs=[status_out, table_out])
91
 
92
  demo.launch()