Update tools/university_admin_agent.py
Browse filesmodified the get file script to allow better file processing
tools/university_admin_agent.py
CHANGED
|
@@ -34,18 +34,22 @@ def search_data(data, keyword):
|
|
| 34 |
def load_data(file_name):
|
| 35 |
#get current file directory
|
| 36 |
current_file_dir = Path(__file__).resolve().parent
|
|
|
|
| 37 |
#get directory where root is located
|
| 38 |
project_root = current_file_dir.parent.parent
|
| 39 |
-
#get the data folder
|
| 40 |
|
|
|
|
| 41 |
file_path = project_root /"data"/ file_name
|
| 42 |
"""Safely loads data from a JSON file."""
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
class UniversityAdminAgentTool(Tool):
|
| 51 |
name = "university_administrator_agent"
|
|
|
|
| 34 |
def load_data(file_name):
|
| 35 |
#get current file directory
|
| 36 |
current_file_dir = Path(__file__).resolve().parent
|
| 37 |
+
|
| 38 |
#get directory where root is located
|
| 39 |
project_root = current_file_dir.parent.parent
|
|
|
|
| 40 |
|
| 41 |
+
#get the data folder
|
| 42 |
file_path = project_root /"data"/ file_name
|
| 43 |
"""Safely loads data from a JSON file."""
|
| 44 |
+
# if not os.path.exists(file_path):
|
| 45 |
+
# print(f"Error: The file '{file_path}' was not found.")
|
| 46 |
+
# return []
|
| 47 |
+
try:
|
| 48 |
+
with open(file_path, "r", encoding="utf-8") as file:
|
| 49 |
+
return json.load(file)
|
| 50 |
+
except error:
|
| 51 |
+
print(f"error encountered: {error}")
|
| 52 |
+
|
| 53 |
|
| 54 |
class UniversityAdminAgentTool(Tool):
|
| 55 |
name = "university_administrator_agent"
|