Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,11 +20,10 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 20 |
|
| 21 |
# --- Helper function to parse the agent's output ---
|
| 22 |
def parse_final_answer(agent_response: str) -> str:
|
| 23 |
-
|
| 24 |
-
if match: return match.group(1).strip()
|
| 25 |
lines = [line for line in agent_response.split('\n') if line.strip()]
|
| 26 |
if lines: return lines[-1].strip()
|
| 27 |
-
return "Could not parse
|
| 28 |
|
| 29 |
def detect_file_type_robust(url: str) -> Tuple[str, dict]:
|
| 30 |
"""
|
|
@@ -206,8 +205,10 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
| 206 |
print(f"\n--- Running Task {i+1}/{len(questions_data)} (ID: {task_id}) ---")
|
| 207 |
|
| 208 |
# Get file URL if it exists
|
| 209 |
-
file_url = item.get("
|
| 210 |
-
|
|
|
|
|
|
|
| 211 |
# Create structured prompt with robust file analysis
|
| 212 |
structured_prompt = create_structured_prompt(question_text, file_url)
|
| 213 |
|
|
|
|
| 20 |
|
| 21 |
# --- Helper function to parse the agent's output ---
|
| 22 |
def parse_final_answer(agent_response: str) -> str:
|
| 23 |
+
# Remove the FINAL ANSWER pattern search entirely
|
|
|
|
| 24 |
lines = [line for line in agent_response.split('\n') if line.strip()]
|
| 25 |
if lines: return lines[-1].strip()
|
| 26 |
+
return "Could not parse answer."
|
| 27 |
|
| 28 |
def detect_file_type_robust(url: str) -> Tuple[str, dict]:
|
| 29 |
"""
|
|
|
|
| 205 |
print(f"\n--- Running Task {i+1}/{len(questions_data)} (ID: {task_id}) ---")
|
| 206 |
|
| 207 |
# Get file URL if it exists
|
| 208 |
+
file_url = f"{DEFAULT_API_URL}/files/{task_id}" if item.get("has_file") else None
|
| 209 |
+
|
| 210 |
+
if file_url = None:
|
| 211 |
+
print ("No File Url")
|
| 212 |
# Create structured prompt with robust file analysis
|
| 213 |
structured_prompt = create_structured_prompt(question_text, file_url)
|
| 214 |
|