Update app.py
Browse files
app.py
CHANGED
|
@@ -3,9 +3,19 @@ import gradio as gr
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
-
from agent import
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
# (Keep Constants as is)
|
| 9 |
# --- Constants ---
|
| 10 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 11 |
|
|
@@ -20,7 +30,7 @@ class BasicAgent:
|
|
| 20 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
| 21 |
return fixed_answer
|
| 22 |
|
| 23 |
-
def run_and_submit_all(
|
| 24 |
"""
|
| 25 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
| 26 |
and displays the results.
|
|
@@ -42,7 +52,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 42 |
# 1. Instantiate Agent ( modify this part to create your agent)
|
| 43 |
try:
|
| 44 |
# agent = BasicAgent()
|
| 45 |
-
agent =
|
| 46 |
except Exception as e:
|
| 47 |
print(f"Error instantiating agent: {e}")
|
| 48 |
return f"Error initializing agent: {e}", None
|
|
@@ -148,11 +158,9 @@ with gr.Blocks() as demo:
|
|
| 148 |
gr.Markdown(
|
| 149 |
"""
|
| 150 |
**Instructions:**
|
| 151 |
-
|
| 152 |
1. Please clone this space, then modify the code to define your agent's logic, the tools, the necessary packages, etc ...
|
| 153 |
2. Log in to your Hugging Face account using the button below. This uses your HF username for submission.
|
| 154 |
3. Click 'Run Evaluation & Submit All Answers' to fetch questions, run your agent, submit answers, and see the score.
|
| 155 |
-
|
| 156 |
---
|
| 157 |
**Disclaimers:**
|
| 158 |
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).
|
|
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
+
from agent import ClaudeAgent
|
| 7 |
+
from dotenv import load_dotenv
|
| 8 |
+
|
| 9 |
+
# Load environment variables
|
| 10 |
+
load_dotenv()
|
| 11 |
+
|
| 12 |
+
# Check for API keys
|
| 13 |
+
anthropic_key = os.getenv("ANTHROPIC_API_KEY")
|
| 14 |
+
if anthropic_key:
|
| 15 |
+
print(f"✅ Found ANTHROPIC_API_KEY: {anthropic_key[:5]}***")
|
| 16 |
+
else:
|
| 17 |
+
print("⚠️ ANTHROPIC_API_KEY not found - Make sure it's set in your Hugging Face Space secrets")
|
| 18 |
|
|
|
|
| 19 |
# --- Constants ---
|
| 20 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 21 |
|
|
|
|
| 30 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
| 31 |
return fixed_answer
|
| 32 |
|
| 33 |
+
def run_and_submit_all(profile: gr.OAuthProfile | None):
|
| 34 |
"""
|
| 35 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
| 36 |
and displays the results.
|
|
|
|
| 52 |
# 1. Instantiate Agent ( modify this part to create your agent)
|
| 53 |
try:
|
| 54 |
# agent = BasicAgent()
|
| 55 |
+
agent = ClaudeAgent()
|
| 56 |
except Exception as e:
|
| 57 |
print(f"Error instantiating agent: {e}")
|
| 58 |
return f"Error initializing agent: {e}", None
|
|
|
|
| 158 |
gr.Markdown(
|
| 159 |
"""
|
| 160 |
**Instructions:**
|
|
|
|
| 161 |
1. Please clone this space, then modify the code to define your agent's logic, the tools, the necessary packages, etc ...
|
| 162 |
2. Log in to your Hugging Face account using the button below. This uses your HF username for submission.
|
| 163 |
3. Click 'Run Evaluation & Submit All Answers' to fetch questions, run your agent, submit answers, and see the score.
|
|
|
|
| 164 |
---
|
| 165 |
**Disclaimers:**
|
| 166 |
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).
|