File size: 1,936 Bytes
10e9b7d e80aab9 184dc24 e80aab9 184dc24 97b4618 e80aab9 fa63e3d e80aab9 fa63e3d 0ee0419 fa63e3d e80aab9 f7fc39c fa63e3d 20e5c62 df0be25 fa63e3d 31243f4 184dc24 fa63e3d 184dc24 8cc2e88 184dc24 31243f4 184dc24 31243f4 e80aab9 7d65c66 fa63e3d |
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
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)
|