Muhammad-Izhan commited on
Commit
9781295
·
verified ·
1 Parent(s): 88f0a0f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -10
app.py CHANGED
@@ -1,10 +1,34 @@
1
- class BasicAgent:
2
- def __init__(self):
3
- print("BasicAgent initialized.")
4
-
5
- def __call__(self, question: str) -> str:
6
- print(f"Agent received question (first 50 chars): {question[:50]}...")
7
- # Replace this with your own logic to answer the questions
8
- fixed_answer = "This is a default answer."
9
- print(f"Agent returning fixed answer: {fixed_answer}")
10
- return fixed_answer
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+ import pandas as pd
4
+ from BasicAgent import BasicAgent # Import BasicAgent class
5
+
6
+ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
7
+
8
+ def run_and_submit_all(profile: gr.OAuthProfile | None):
9
+ # Your logic for fetching and submitting data here
10
+ agent = BasicAgent()
11
+ question = "What is the meaning of life?" # Example question, you can modify this
12
+ answer = agent(question) # Get answer from BasicAgent
13
+
14
+ # Mocking data as if agent has answered some questions
15
+ data = [{"Task ID": f"task_{i+1}", "Answer": f"Answer to question {i+1}"} for i in range(5)]
16
+
17
+ # You can modify the status and table as per your needs
18
+ return "Results submitted successfully!", pd.DataFrame(data)
19
+
20
+ # Initialize Gradio interface
21
+ with gr.Blocks() as demo:
22
+ gr.Markdown("# Basic Agent Evaluation Runner")
23
+ gr.LoginButton()
24
+
25
+ # Add run button and result output fields
26
+ run_button = gr.Button("Run Evaluation & Submit All Answers")
27
+ status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
28
+ results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
29
+
30
+ # Hook up button click to function
31
+ run_button.click(fn=run_and_submit_all, outputs=[status_output, results_table])
32
+
33
+ if __name__ == "__main__":
34
+ demo.launch(debug=True, share=False)