import gradio as gr from BasicAgent import BasicAgent from CustomAgent import CustomAgent from utils import get_agents, run_and_submit_all # Get all available agents AGENTS = get_agents(globals(), BasicAgent) # Demo app with gr.Blocks() as demo: gr.Markdown("# Agents Course Final Assignment Evaluation Runner") gr.Markdown( """\ **Instructions:** 1. Please clone this space, then modify the code to define your agent's logic, the tools, the necessary packages, etc ... 2. Log in to your Hugging Face account using the button below. This uses your HF username for submission. 3. Click 'Run Evaluation & Submit All Answers' to fetch questions, run your agent, submit answers, and see the score. Note: 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). --- **Implementation:** CustomAgent is a subclass of BasicAgent that uses a custom system prompt and integrates with an OpenAI-compatible model (llama-3.1-8b-instant via Groq API). It leverages the magentic library for prompt chaining and function calling, allowing the agent to use external tools such as web search. """ ) gr.LoginButton() run_button = gr.Button("Run Evaluation & Submit All Answers") agent_dropdown = gr.Dropdown(choices=list(AGENTS.keys()), label="Select Agent") status_output = gr.Textbox( label="Run Status / Submission Result", lines=5, interactive=False ) results_table = gr.DataFrame( label="Questions and Agent Answers", wrap=True ) def wrapper(profile: gr.OAuthProfile | None, a: str) -> tuple[str, list]: return run_and_submit_all(profile, AGENTS.get(a, BasicAgent)) run_button.click( fn=wrapper, inputs=[agent_dropdown], outputs=[status_output, results_table] ) # Run app if __name__ == "__main__": demo.launch(debug=True, share=False)