jatinror commited on
Commit
339faa0
·
verified ·
1 Parent(s): 0105865

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -14
app.py CHANGED
@@ -11,9 +11,9 @@ import gradio as gr
11
  BASE_URL = "https://agents-course-unit4-scoring.hf.space"
12
 
13
  # Hugging Face username
14
- HF_USERNAME = "jatinror" # replace with your HF username if different
15
 
16
- # Your Space ID
17
  SPACE_ID = "jatinror/Final_Assignment"
18
  AGENT_CODE_URL = f"https://huggingface.co/spaces/{SPACE_ID}/tree/main"
19
 
@@ -93,33 +93,30 @@ def submit_answers(answers):
93
  "agent_code": AGENT_CODE_URL,
94
  "answers": answers
95
  }
96
- print("Submitting payload...")
97
  response = requests.post(f"{BASE_URL}/submit", json=payload)
98
  print("Server response:", response.text)
 
99
 
100
  # ===============================
101
  # MAIN PIPELINE
102
  # ===============================
103
 
104
  def run_agent():
105
- print("Fetching GAIA questions...")
106
  questions = get_questions()
107
  answers = []
108
  for q in questions:
109
  task_id = q["task_id"]
110
  question = q["question"]
111
- print("Solving:", task_id)
112
  try:
113
  result = solve_question(question, task_id)
114
- except Exception as e:
115
- print("Error:", e)
116
  result = ""
117
  answers.append({
118
  "task_id": task_id,
119
  "submitted_answer": result.strip()
120
  })
121
- submit_answers(answers)
122
- print("Finished submission.")
123
 
124
  # ===============================
125
  # GRADIO BLOCKS UI
@@ -127,16 +124,14 @@ def run_agent():
127
 
128
  def run_pipeline():
129
  try:
130
- run_agent()
131
- return "✅ GAIA submission completed. Check leaderboard."
132
  except Exception as e:
133
  return f"❌ Error occurred: {str(e)}"
134
 
135
  with gr.Blocks() as demo:
136
  run_button = gr.Button("Run GAIA Agent")
137
- output_text = gr.Textbox(label="Output", lines=4)
138
-
139
- # Link button click to function
140
  run_button.click(fn=run_pipeline, inputs=[], outputs=output_text)
141
 
142
  if __name__ == "__main__":
 
11
  BASE_URL = "https://agents-course-unit4-scoring.hf.space"
12
 
13
  # Hugging Face username
14
+ HF_USERNAME = "jatinror" # your HF username
15
 
16
+ # Your Space ID (updated)
17
  SPACE_ID = "jatinror/Final_Assignment"
18
  AGENT_CODE_URL = f"https://huggingface.co/spaces/{SPACE_ID}/tree/main"
19
 
 
93
  "agent_code": AGENT_CODE_URL,
94
  "answers": answers
95
  }
 
96
  response = requests.post(f"{BASE_URL}/submit", json=payload)
97
  print("Server response:", response.text)
98
+ return response.text # Return response to output box
99
 
100
  # ===============================
101
  # MAIN PIPELINE
102
  # ===============================
103
 
104
  def run_agent():
 
105
  questions = get_questions()
106
  answers = []
107
  for q in questions:
108
  task_id = q["task_id"]
109
  question = q["question"]
 
110
  try:
111
  result = solve_question(question, task_id)
112
+ except:
 
113
  result = ""
114
  answers.append({
115
  "task_id": task_id,
116
  "submitted_answer": result.strip()
117
  })
118
+ server_response = submit_answers(answers)
119
+ return server_response # return server response
120
 
121
  # ===============================
122
  # GRADIO BLOCKS UI
 
124
 
125
  def run_pipeline():
126
  try:
127
+ response = run_agent()
128
+ return f"✅ GAIA submission completed.\nServer response: {response}"
129
  except Exception as e:
130
  return f"❌ Error occurred: {str(e)}"
131
 
132
  with gr.Blocks() as demo:
133
  run_button = gr.Button("Run GAIA Agent")
134
+ output_text = gr.Textbox(label="Output", lines=6)
 
 
135
  run_button.click(fn=run_pipeline, inputs=[], outputs=output_text)
136
 
137
  if __name__ == "__main__":