Spaces:
Build error
Build error
Update utils.py
Browse files
utils.py
CHANGED
|
@@ -9,6 +9,8 @@ from fastapi import UploadFile
|
|
| 9 |
from prompt_template import template_format_instructions, template
|
| 10 |
from typing import List
|
| 11 |
|
|
|
|
|
|
|
| 12 |
# Create a directory to store temporary files
|
| 13 |
TEMP_DIR = "/temp_files"
|
| 14 |
# if not os.path.exists(TEMP_DIR):
|
|
@@ -117,3 +119,29 @@ def generate_json_structured_resume(resume, chat_llm):
|
|
| 117 |
result = chain.invoke({"text": resume})
|
| 118 |
|
| 119 |
return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
from prompt_template import template_format_instructions, template
|
| 10 |
from typing import List
|
| 11 |
|
| 12 |
+
|
| 13 |
+
|
| 14 |
# Create a directory to store temporary files
|
| 15 |
TEMP_DIR = "/temp_files"
|
| 16 |
# if not os.path.exists(TEMP_DIR):
|
|
|
|
| 119 |
result = chain.invoke({"text": resume})
|
| 120 |
|
| 121 |
return result
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
def delete_files_in_directory(directory):
|
| 125 |
+
"""
|
| 126 |
+
Deletes all files in the specified directory.
|
| 127 |
+
|
| 128 |
+
Args:
|
| 129 |
+
directory (str): The path to the directory containing files to be deleted.
|
| 130 |
+
|
| 131 |
+
Returns:
|
| 132 |
+
None
|
| 133 |
+
"""
|
| 134 |
+
# Check if the directory exists
|
| 135 |
+
if not os.path.exists(directory):
|
| 136 |
+
print(f"Directory '{directory}' does not exist.")
|
| 137 |
+
return
|
| 138 |
+
|
| 139 |
+
# Get a list of all files in the directory
|
| 140 |
+
files = os.listdir(directory)
|
| 141 |
+
|
| 142 |
+
# Iterate over each file and delete it
|
| 143 |
+
for file in files:
|
| 144 |
+
file_path = os.path.join(directory, file)
|
| 145 |
+
if os.path.isfile(file_path):
|
| 146 |
+
os.remove(file_path)
|
| 147 |
+
print(f"Deleted file: {file_path}")
|