Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,6 +16,7 @@ from agent import solve
|
|
| 16 |
# --- Constants ---
|
| 17 |
GAIA_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 18 |
# The agent itself will handle API key checks internally, but we can do a preliminary check here.
|
|
|
|
| 19 |
TAVILY_API_KEY = os.environ.get("TAVILY_API_KEY")
|
| 20 |
OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
|
| 21 |
|
|
@@ -95,8 +96,8 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
| 95 |
username = profile.username
|
| 96 |
yield f"Authenticated as Hugging Face user: {username}"
|
| 97 |
|
| 98 |
-
if not OPENAI_API_KEY or not TAVILY_API_KEY:
|
| 99 |
-
yield "Error: API keys (OPENAI_API_KEY, TAVILY_API_KEY) are not set. Please configure them as Space secrets."
|
| 100 |
return
|
| 101 |
|
| 102 |
# Fetch questions from the API
|
|
@@ -134,8 +135,9 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
| 134 |
|
| 135 |
# Run the imported Groq agent using the solve function
|
| 136 |
try:
|
|
|
|
| 137 |
response = agent_executor.invoke({"input": question})
|
| 138 |
-
answer = response
|
| 139 |
yield f"Agent generated answer: {answer}"
|
| 140 |
except Exception as e:
|
| 141 |
yield f"An error occurred while running the agent: {e}"
|
|
|
|
| 16 |
# --- Constants ---
|
| 17 |
GAIA_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 18 |
# The agent itself will handle API key checks internally, but we can do a preliminary check here.
|
| 19 |
+
GROQ_API_KEY = os.environ.get("GROQ_API_KEY")
|
| 20 |
TAVILY_API_KEY = os.environ.get("TAVILY_API_KEY")
|
| 21 |
OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
|
| 22 |
|
|
|
|
| 96 |
username = profile.username
|
| 97 |
yield f"Authenticated as Hugging Face user: {username}"
|
| 98 |
|
| 99 |
+
if not OPENAI_API_KEY or not GROQ_API_KEY or not TAVILY_API_KEY:
|
| 100 |
+
yield "Error: API keys (OPENAI_API_KEY, GROQ_API_KEY, TAVILY_API_KEY) are not set. Please configure them as Space secrets."
|
| 101 |
return
|
| 102 |
|
| 103 |
# Fetch questions from the API
|
|
|
|
| 135 |
|
| 136 |
# Run the imported Groq agent using the solve function
|
| 137 |
try:
|
| 138 |
+
yield "Invoking agent..."
|
| 139 |
response = agent_executor.invoke({"input": question})
|
| 140 |
+
answer = solve(response)
|
| 141 |
yield f"Agent generated answer: {answer}"
|
| 142 |
except Exception as e:
|
| 143 |
yield f"An error occurred while running the agent: {e}"
|