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