Update app.py
Browse files
app.py
CHANGED
|
@@ -13,7 +13,7 @@ def get_file_content_tool(task_id: str) -> str:
|
|
| 13 |
Args:
|
| 14 |
task_id: The ID of the task requiring a file.
|
| 15 |
"""
|
| 16 |
-
url = f"https://agents-course-unit4-
|
| 17 |
response = requests.get(url)
|
| 18 |
if response.status_code == 200:
|
| 19 |
filename = f"temp_{task_id}"
|
|
@@ -38,22 +38,22 @@ def run_evaluation(username):
|
|
| 38 |
if not username:
|
| 39 |
return "Please log in with your Hugging Face account first."
|
| 40 |
|
| 41 |
-
#
|
| 42 |
-
api_base = "https://agents-course-unit4-
|
| 43 |
|
| 44 |
-
|
| 45 |
try:
|
| 46 |
-
resp = requests.get(f"{api_base}/questions", timeout=
|
| 47 |
except Exception as e:
|
| 48 |
return f"Connection error when reaching evaluation server: {str(e)}"
|
| 49 |
|
| 50 |
if resp.status_code != 200:
|
| 51 |
-
return f"Failed to fetch questions. Status code: {resp.status_code}. Response: {resp.text
|
| 52 |
|
| 53 |
try:
|
| 54 |
questions_data = resp.json()
|
| 55 |
except Exception:
|
| 56 |
-
return f"Invalid JSON response from server: {resp.text
|
| 57 |
|
| 58 |
answers = []
|
| 59 |
log_output = ""
|
|
@@ -91,7 +91,7 @@ def run_evaluation(username):
|
|
| 91 |
}
|
| 92 |
|
| 93 |
try:
|
| 94 |
-
sub_resp = requests.post(f"{api_base}/submit", json=payload, timeout=
|
| 95 |
if sub_resp.status_code == 200:
|
| 96 |
result_json = sub_resp.json()
|
| 97 |
log_output += f"\nSubmission Successful! Response: {result_json}"
|
|
|
|
| 13 |
Args:
|
| 14 |
task_id: The ID of the task requiring a file.
|
| 15 |
"""
|
| 16 |
+
url = f"https://agents-course-unit4-scoring.hf.space/files/{task_id}"
|
| 17 |
response = requests.get(url)
|
| 18 |
if response.status_code == 200:
|
| 19 |
filename = f"temp_{task_id}"
|
|
|
|
| 38 |
if not username:
|
| 39 |
return "Please log in with your Hugging Face account first."
|
| 40 |
|
| 41 |
+
# Updated scoring API base URL
|
| 42 |
+
api_base = "https://agents-course-unit4-scoring.hf.space"
|
| 43 |
|
| 44 |
+
headers = {"User-Agent": "Mozilla/5.0"}
|
| 45 |
try:
|
| 46 |
+
resp = requests.get(f"{api_base}/questions", headers=headers, timeout=15)
|
| 47 |
except Exception as e:
|
| 48 |
return f"Connection error when reaching evaluation server: {str(e)}"
|
| 49 |
|
| 50 |
if resp.status_code != 200:
|
| 51 |
+
return f"Failed to fetch questions. Status code: {resp.status_code}. Response: {resp.text}"
|
| 52 |
|
| 53 |
try:
|
| 54 |
questions_data = resp.json()
|
| 55 |
except Exception:
|
| 56 |
+
return f"Invalid JSON response from server: {resp.text}"
|
| 57 |
|
| 58 |
answers = []
|
| 59 |
log_output = ""
|
|
|
|
| 91 |
}
|
| 92 |
|
| 93 |
try:
|
| 94 |
+
sub_resp = requests.post(f"{api_base}/submit", json=payload, headers=headers, timeout=20)
|
| 95 |
if sub_resp.status_code == 200:
|
| 96 |
result_json = sub_resp.json()
|
| 97 |
log_output += f"\nSubmission Successful! Response: {result_json}"
|