Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files
agent.py
CHANGED
@@ -134,8 +134,5 @@ def get_tools() -> List[BaseTool]:
|
|
134 |
web_tool
|
135 |
]
|
136 |
|
137 |
-
# REMOVED circular import from app.py
|
138 |
-
# This file now just defines tools and doesn't attempt to build the agent
|
139 |
-
|
140 |
if __name__ == "__main__":
|
141 |
print("This module defines tools for the agent. Run app.py or standalone_debug.py to test the agent.")
|
|
|
134 |
web_tool
|
135 |
]
|
136 |
|
|
|
|
|
|
|
137 |
if __name__ == "__main__":
|
138 |
print("This module defines tools for the agent. Run app.py or standalone_debug.py to test the agent.")
|
app.py
CHANGED
@@ -284,72 +284,37 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
284 |
results_df = pd.DataFrame(results_log)
|
285 |
return status_message, results_df
|
286 |
|
287 |
-
# Try to load Gradio components, handling potential OAuth errors
|
288 |
-
try:
|
289 |
-
# --- Build Gradio Interface using Blocks ---
|
290 |
-
with gr.Blocks() as demo:
|
291 |
-
gr.Markdown("# Basic Agent Evaluation Runner")
|
292 |
-
gr.Markdown(
|
293 |
-
"""
|
294 |
-
**Instructions:**
|
295 |
|
296 |
-
|
297 |
-
|
298 |
-
|
|
|
|
|
|
|
299 |
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
This space provides a basic setup and is intentionally sub-optimal to encourage you to develop your own, more robust solution. For instance for the delay process of the submit button, a solution could be to cache the answers and submit in a seperate action or even to answer the questions in async.
|
304 |
-
"""
|
305 |
-
)
|
306 |
|
307 |
-
|
|
|
|
|
|
|
|
|
|
|
308 |
|
309 |
-
|
310 |
|
311 |
-
|
312 |
-
results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
|
313 |
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
# Create a minimal demo without OAuth if running locally
|
323 |
-
try:
|
324 |
-
import gradio as gr
|
325 |
-
with gr.Blocks() as demo:
|
326 |
-
gr.Markdown("# Agent Test Environment (Local Mode)")
|
327 |
-
gr.Markdown("OAuth dependencies not found. Running in local test mode.")
|
328 |
-
|
329 |
-
with gr.Row():
|
330 |
-
with gr.Column():
|
331 |
-
question_input = gr.Textbox(label="Enter your question", lines=2)
|
332 |
-
test_button = gr.Button("Test Agent")
|
333 |
-
|
334 |
-
with gr.Column():
|
335 |
-
answer_output = gr.Textbox(label="Agent Answer", lines=10)
|
336 |
-
|
337 |
-
def test_agent_locally(question):
|
338 |
-
try:
|
339 |
-
agent = BasicAgent()
|
340 |
-
result = agent(question)
|
341 |
-
return result
|
342 |
-
except Exception as e:
|
343 |
-
return f"Error: {str(e)}\n\n{traceback.format_exc()}"
|
344 |
-
|
345 |
-
test_button.click(
|
346 |
-
fn=test_agent_locally,
|
347 |
-
inputs=[question_input],
|
348 |
-
outputs=[answer_output]
|
349 |
-
)
|
350 |
-
except Exception as e:
|
351 |
-
print(f"Failed to create even minimal Gradio interface: {e}")
|
352 |
-
demo = None
|
353 |
|
354 |
if __name__ == "__main__":
|
355 |
print("\n" + "-"*30 + " App Starting " + "-"*30)
|
@@ -373,3 +338,4 @@ if __name__ == "__main__":
|
|
373 |
print("-"*(60 + len(" App Starting ")) + "\n")
|
374 |
|
375 |
print("Launching Gradio Interface for Basic Agent Evaluation...")
|
|
|
|
284 |
results_df = pd.DataFrame(results_log)
|
285 |
return status_message, results_df
|
286 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
|
288 |
+
# --- Build Gradio Interface using Blocks ---
|
289 |
+
with gr.Blocks() as demo:
|
290 |
+
gr.Markdown("# Basic Agent Evaluation Runner")
|
291 |
+
gr.Markdown(
|
292 |
+
"""
|
293 |
+
**Instructions:**
|
294 |
|
295 |
+
1. Please clone this space, then modify the code to define your agent's logic, the tools, the necessary packages, etc ...
|
296 |
+
2. Log in to your Hugging Face account using the button below. This uses your HF username for submission.
|
297 |
+
3. Click 'Run Evaluation & Submit All Answers' to fetch questions, run your agent, submit answers, and see the score.
|
|
|
|
|
|
|
298 |
|
299 |
+
---
|
300 |
+
**Disclaimers:**
|
301 |
+
Once clicking on the "submit button, it can take quite some time ( this is the time for the agent to go through all the questions).
|
302 |
+
This space provides a basic setup and is intentionally sub-optimal to encourage you to develop your own, more robust solution. For instance for the delay process of the submit button, a solution could be to cache the answers and submit in a seperate action or even to answer the questions in async.
|
303 |
+
"""
|
304 |
+
)
|
305 |
|
306 |
+
gr.LoginButton()
|
307 |
|
308 |
+
run_button = gr.Button("Run Evaluation & Submit All Answers")
|
|
|
309 |
|
310 |
+
status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
|
311 |
+
# Removed max_rows=10 from DataFrame constructor
|
312 |
+
results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
|
313 |
+
|
314 |
+
run_button.click(
|
315 |
+
fn=run_and_submit_all,
|
316 |
+
outputs=[status_output, results_table]
|
317 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
318 |
|
319 |
if __name__ == "__main__":
|
320 |
print("\n" + "-"*30 + " App Starting " + "-"*30)
|
|
|
338 |
print("-"*(60 + len(" App Starting ")) + "\n")
|
339 |
|
340 |
print("Launching Gradio Interface for Basic Agent Evaluation...")
|
341 |
+
demo.launch(debug=True, share=False)
|