awacke1 commited on
Commit
2625a2d
·
verified ·
1 Parent(s): 54e4022

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -9
app.py CHANGED
@@ -3,6 +3,7 @@ import os
3
  import glob
4
  import re
5
  import base64
 
6
  from urllib.parse import quote
7
  from gradio_client import Client
8
  from datetime import datetime
@@ -81,6 +82,24 @@ Multiplayer_Custom_Hosting_Game_Servers_For_Simulated_Worlds = """
81
  29. Valheim
82
  """
83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  def sanitize_filename(text):
85
  """Create a safe filename from text."""
86
  # Remove or replace unsafe characters
@@ -89,16 +108,11 @@ def sanitize_filename(text):
89
  return safe_text[:50] # Limit length to 50 chars
90
 
91
  def save_ai_interaction(query, ai_result):
92
- """Save AI interaction to a markdown file."""
93
- timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
94
- safe_query = sanitize_filename(query)
95
- filename = f"ai_interaction_{timestamp}_{safe_query}.md"
96
 
97
  # Format the content
98
- content = f"""# AI Interaction - {datetime.now().strftime("%Y-%m-%d %H:%M:%S")}
99
-
100
- ## Query
101
- {query}
102
 
103
  ## AI Response
104
  {ai_result}
@@ -251,7 +265,6 @@ def file_management_sidebar():
251
  st.session_state.selected_file = new_filename
252
  st.session_state.view_mode = 'edit'
253
 
254
-
255
  def main():
256
  st.title("Markdown Content with AI Lookup and File Management")
257
 
 
3
  import glob
4
  import re
5
  import base64
6
+ import pytz
7
  from urllib.parse import quote
8
  from gradio_client import Client
9
  from datetime import datetime
 
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
88
+ central = pytz.timezone('US/Central')
89
+ current_time = datetime.now(central)
90
+
91
+ # Format the timestamp parts
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
 
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)
 
 
113
 
114
  # Format the content
115
+ content = f"""# Query: {query}
 
 
 
116
 
117
  ## AI Response
118
  {ai_result}
 
265
  st.session_state.selected_file = new_filename
266
  st.session_state.view_mode = 'edit'
267
 
 
268
  def main():
269
  st.title("Markdown Content with AI Lookup and File Management")
270