Commit
·
d7be3df
1
Parent(s):
a992787
Update agent logic and add test interface
Browse files
app.py
CHANGED
@@ -189,56 +189,36 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
189 |
|
190 |
# --- Build Gradio Interface using Blocks ---
|
191 |
with gr.Blocks() as demo:
|
192 |
-
gr.Markdown("#
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
|
|
|
|
220 |
|
221 |
if __name__ == "__main__":
|
222 |
-
|
223 |
-
# Check for SPACE_HOST and SPACE_ID at startup for information
|
224 |
-
space_host_startup = os.getenv("SPACE_HOST")
|
225 |
-
space_id_startup = os.getenv("SPACE_ID") # Get SPACE_ID at startup
|
226 |
-
|
227 |
-
if space_host_startup:
|
228 |
-
print(f"✅ SPACE_HOST found: {space_host_startup}")
|
229 |
-
print(f" Runtime URL should be: https://{space_host_startup}.hf.space")
|
230 |
-
else:
|
231 |
-
print("ℹ️ SPACE_HOST environment variable not found (running locally?).")
|
232 |
-
|
233 |
-
if space_id_startup: # Print repo URLs if SPACE_ID is found
|
234 |
-
print(f"✅ SPACE_ID found: {space_id_startup}")
|
235 |
-
print(f" Repo URL: https://huggingface.co/spaces/{space_id_startup}")
|
236 |
-
print(f" Repo Tree URL: https://huggingface.co/spaces/{space_id_startup}/tree/main")
|
237 |
-
else:
|
238 |
-
print("ℹ️ SPACE_ID environment variable not found (running locally?). Repo URL cannot be determined.")
|
239 |
-
|
240 |
-
print("-"*(60 + len(" App Starting ")) + "\n")
|
241 |
-
|
242 |
-
print("Launching Gradio Interface for Basic Agent Evaluation...")
|
243 |
-
demo.launch(debug=True, share=False)
|
244 |
-
test_interface.launch(debug=True, share=False)
|
|
|
189 |
|
190 |
# --- Build Gradio Interface using Blocks ---
|
191 |
with gr.Blocks() as demo:
|
192 |
+
gr.Markdown("# 🤖 GAIA Final Assignment: Agent Runner")
|
193 |
+
|
194 |
+
with gr.Tab("🔍 Test Your Agent"):
|
195 |
+
gr.Markdown("Use this to test how your agent responds to custom questions before running full evaluation.")
|
196 |
+
test_input = gr.Textbox(label="Enter a Question", placeholder="e.g., How many studio albums...")
|
197 |
+
test_output = gr.Textbox(label="Agent's Answer", interactive=False)
|
198 |
+
test_button = gr.Button("Test Agent")
|
199 |
+
test_button.click(fn=test_agent_response, inputs=test_input, outputs=test_output)
|
200 |
+
|
201 |
+
with gr.Tab("📤 Run Evaluation & Submit"):
|
202 |
+
gr.Markdown(
|
203 |
+
"""
|
204 |
+
**Instructions:**
|
205 |
+
|
206 |
+
1. Modify your agent logic.
|
207 |
+
2. Log in to Hugging Face below.
|
208 |
+
3. Click 'Run Evaluation & Submit All Answers' to fetch questions, run your agent, and see your score.
|
209 |
+
|
210 |
+
---
|
211 |
+
"""
|
212 |
+
)
|
213 |
+
gr.LoginButton()
|
214 |
+
run_button = gr.Button("Run Evaluation & Submit All Answers")
|
215 |
+
status_output = gr.Textbox(label="Submission Result", lines=5, interactive=False)
|
216 |
+
results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
|
217 |
+
|
218 |
+
run_button.click(
|
219 |
+
fn=run_and_submit_all,
|
220 |
+
outputs=[status_output, results_table]
|
221 |
+
)
|
222 |
|
223 |
if __name__ == "__main__":
|
224 |
+
demo.launch(debug=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|