awacke1 commited on
Commit
836474e
·
verified ·
1 Parent(s): e06095f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py CHANGED
@@ -189,6 +189,18 @@ def generate_filename(prompt, file_type):
189
  safe_prompt = re.sub(r'\s+', ' ', replaced_prompt).strip()[:240]
190
  return f"{safe_date_time}_{safe_prompt}.{file_type}"
191
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  def create_and_save_file(content, file_type="md", prompt=None, is_image=False, should_save=True):
193
  """Create and save file with proper handling of different types."""
194
  if not should_save:
@@ -403,6 +415,8 @@ def create_zip_of_files(files):
403
  zipf.write(file)
404
  return zip_name
405
 
 
 
406
  def get_media_html(media_path, media_type="video", width="100%"):
407
  """Generate HTML for media player."""
408
  media_data = base64.b64encode(open(media_path, 'rb').read()).decode()
 
189
  safe_prompt = re.sub(r'\s+', ' ', replaced_prompt).strip()[:240]
190
  return f"{safe_date_time}_{safe_prompt}.{file_type}"
191
 
192
+
193
+
194
+
195
+ # Function to create and save a file (and avoid the black hole of lost data 🕳)
196
+ def create_file(filename, prompt, response, should_save=True):
197
+ if not should_save:
198
+ return
199
+ with open(filename, 'w', encoding='utf-8') as file:
200
+ file.write(prompt + "\n\n" + response)
201
+
202
+
203
+
204
  def create_and_save_file(content, file_type="md", prompt=None, is_image=False, should_save=True):
205
  """Create and save file with proper handling of different types."""
206
  if not should_save:
 
415
  zipf.write(file)
416
  return zip_name
417
 
418
+
419
+
420
  def get_media_html(media_path, media_type="video", width="100%"):
421
  """Generate HTML for media player."""
422
  media_data = base64.b64encode(open(media_path, 'rb').read()).decode()