Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -82,6 +82,16 @@ Multiplayer_Custom_Hosting_Game_Servers_For_Simulated_Worlds = """
|
|
| 82 |
29. Valheim
|
| 83 |
"""
|
| 84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
def generate_timestamp_filename(query):
|
| 86 |
"""Generate filename with format: 1103AM 11032024 (Query).md"""
|
| 87 |
# Get current time in Central timezone
|
|
@@ -92,21 +102,14 @@ def generate_timestamp_filename(query):
|
|
| 92 |
time_str = current_time.strftime("%I%M%p") # 1103AM format
|
| 93 |
date_str = current_time.strftime("%m%d%Y") # 11032024 format
|
| 94 |
|
| 95 |
-
# Clean up the query for filename
|
| 96 |
safe_query = sanitize_filename(query)
|
| 97 |
|
| 98 |
-
# Construct filename: "1103AM 11032024 (Input).md"
|
| 99 |
filename = f"{time_str} {date_str} ({safe_query}).md"
|
| 100 |
|
| 101 |
return filename
|
| 102 |
|
| 103 |
-
def sanitize_filename(text):
|
| 104 |
-
"""Create a safe filename from text."""
|
| 105 |
-
# Remove or replace unsafe characters
|
| 106 |
-
safe_text = re.sub(r'[^\w\s-]', '_', text)
|
| 107 |
-
safe_text = re.sub(r'\s+', '_', safe_text)
|
| 108 |
-
return safe_text[:50] # Limit length to 50 chars
|
| 109 |
-
|
| 110 |
def save_ai_interaction(query, ai_result):
|
| 111 |
"""Save AI interaction to a markdown file with new filename format."""
|
| 112 |
filename = generate_timestamp_filename(query)
|
|
|
|
| 82 |
29. Valheim
|
| 83 |
"""
|
| 84 |
|
| 85 |
+
def sanitize_filename(text):
|
| 86 |
+
"""Create a safe filename from text while preserving spaces."""
|
| 87 |
+
# First replace unsafe characters with spaces
|
| 88 |
+
safe_text = re.sub(r'[^\w\s-]', ' ', text)
|
| 89 |
+
# Remove any multiple spaces
|
| 90 |
+
safe_text = re.sub(r'\s+', ' ', safe_text)
|
| 91 |
+
# Trim leading/trailing spaces
|
| 92 |
+
safe_text = safe_text.strip()
|
| 93 |
+
return safe_text[:50] # Limit length to 50 chars
|
| 94 |
+
|
| 95 |
def generate_timestamp_filename(query):
|
| 96 |
"""Generate filename with format: 1103AM 11032024 (Query).md"""
|
| 97 |
# Get current time in Central timezone
|
|
|
|
| 102 |
time_str = current_time.strftime("%I%M%p") # 1103AM format
|
| 103 |
date_str = current_time.strftime("%m%d%Y") # 11032024 format
|
| 104 |
|
| 105 |
+
# Clean up the query for filename - now preserving spaces
|
| 106 |
safe_query = sanitize_filename(query)
|
| 107 |
|
| 108 |
+
# Construct filename: "1103AM 11032024 (Input with spaces).md"
|
| 109 |
filename = f"{time_str} {date_str} ({safe_query}).md"
|
| 110 |
|
| 111 |
return filename
|
| 112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
def save_ai_interaction(query, ai_result):
|
| 114 |
"""Save AI interaction to a markdown file with new filename format."""
|
| 115 |
filename = generate_timestamp_filename(query)
|