Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -114,7 +114,29 @@ def clean_text_for_filename(text: str) -> str:
|
|
| 114 |
return '_'.join(filtered)[:200]
|
| 115 |
|
| 116 |
def generate_filename(prompt, response, file_type="md"):
|
| 117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
combined = (prompt + " " + response).strip()
|
| 119 |
info_terms = get_high_info_terms(combined)
|
| 120 |
|
|
|
|
| 114 |
return '_'.join(filtered)[:200]
|
| 115 |
|
| 116 |
def generate_filename(prompt, response, file_type="md"):
|
| 117 |
+
# Adjust timezone to Central Time
|
| 118 |
+
central_tz = pytz.timezone('America/Chicago')
|
| 119 |
+
central_time = datetime.now(central_tz)
|
| 120 |
+
|
| 121 |
+
# Format the prefix to include the required format
|
| 122 |
+
prefix = central_time.strftime("%m-%d-%y_%I-%M-%p_") # e.g., 12-20-24_11-34-AM_
|
| 123 |
+
|
| 124 |
+
combined = (prompt + " " + response).strip()
|
| 125 |
+
info_terms = get_high_info_terms(combined)
|
| 126 |
+
|
| 127 |
+
snippet = (prompt[:100] + " " + response[:100]).strip()
|
| 128 |
+
snippet_cleaned = clean_text_for_filename(snippet)
|
| 129 |
+
name_parts = info_terms + [snippet_cleaned]
|
| 130 |
+
full_name = '_'.join(name_parts)
|
| 131 |
+
|
| 132 |
+
if len(full_name) > 150:
|
| 133 |
+
full_name = full_name[:150]
|
| 134 |
+
|
| 135 |
+
filename = f"{prefix}{full_name}.{file_type}"
|
| 136 |
+
return filename
|
| 137 |
+
|
| 138 |
+
def generate_filename_old(prompt, response, file_type="md"):
|
| 139 |
+
prefix = datetime.now().strftime("%m%d_%hh%mm") + "_"
|
| 140 |
combined = (prompt + " " + response).strip()
|
| 141 |
info_terms = get_high_info_terms(combined)
|
| 142 |
|