added file ext
Browse files
app.py
CHANGED
|
@@ -13,10 +13,10 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 13 |
class BasicAgent:
|
| 14 |
def __init__(self):
|
| 15 |
print("BasicAgent initialized.")
|
| 16 |
-
def __call__(self, question: str, file_name: str) -> str:
|
| 17 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 18 |
if file_name:
|
| 19 |
-
print(f"\tAssociated File: {file_name}")
|
| 20 |
fixed_answer = "This is a default answer."
|
| 21 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
| 22 |
return fixed_answer
|
|
@@ -82,7 +82,9 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 82 |
print(f"Skipping item with missing task_id or question: {item}")
|
| 83 |
continue
|
| 84 |
file_name = item.get("file_name")
|
|
|
|
| 85 |
if file_name:
|
|
|
|
| 86 |
file_name = f"{api_url}/files/{task_id}"
|
| 87 |
try:
|
| 88 |
submitted_answer = agent(question_text, file_name)
|
|
|
|
| 13 |
class BasicAgent:
|
| 14 |
def __init__(self):
|
| 15 |
print("BasicAgent initialized.")
|
| 16 |
+
def __call__(self, question: str, file_name: str | None, file_ext: str | None) -> str:
|
| 17 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 18 |
if file_name:
|
| 19 |
+
print(f"\tAssociated File URL: {file_name}\tFile Extension: {file_ext}")
|
| 20 |
fixed_answer = "This is a default answer."
|
| 21 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
| 22 |
return fixed_answer
|
|
|
|
| 82 |
print(f"Skipping item with missing task_id or question: {item}")
|
| 83 |
continue
|
| 84 |
file_name = item.get("file_name")
|
| 85 |
+
file_ext = None
|
| 86 |
if file_name:
|
| 87 |
+
file_ext = file_name.split(".")[-1]
|
| 88 |
file_name = f"{api_url}/files/{task_id}"
|
| 89 |
try:
|
| 90 |
submitted_answer = agent(question_text, file_name)
|