awacke1 commited on
Commit
f1ee5b9
·
verified ·
1 Parent(s): dcbdb57

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -14
app.py CHANGED
@@ -192,7 +192,7 @@ def clean_text_for_filename(text: str) -> str:
192
 
193
 
194
 
195
- def generate_filename(prompt, response, file_type="md", max_length=120):
196
  """
197
  Generate a shortened filename by:
198
  1. Extracting high-info terms
@@ -201,23 +201,12 @@ def generate_filename(prompt, response, file_type="md", max_length=120):
201
  4. Truncating if needed
202
  """
203
  prefix = format_timestamp_prefix() + "_"
204
-
205
- # Combine prompt+response but keep it from getting huge:
206
- combined_text = (prompt + " " + response)[:2000] # limit huge text input
207
-
208
- # Grab top info terms (10 might be too many; reduce if it still runs long)
209
- info_terms = get_high_info_terms(combined_text, top_n=8)
210
-
211
- # Make a small snippet (truncate at 80 chars total)
212
  snippet = (prompt[:40] + " " + response[:40]).strip()
213
  snippet_cleaned = clean_text_for_filename(snippet)
214
-
215
- # Combine them into a single string, joined by underscores
216
  name_parts = info_terms + [snippet_cleaned]
217
  full_name = '_'.join(name_parts).strip('_')
218
-
219
- # Finally, ensure we do not exceed max_length
220
- # (minus room for prefix and file extension)
221
  leftover_chars = max_length - len(prefix) - len(file_type) - 1
222
  if len(full_name) > leftover_chars:
223
  full_name = full_name[:leftover_chars]
 
192
 
193
 
194
 
195
+ def generate_filename(prompt, response, file_type="md", max_length=200):
196
  """
197
  Generate a shortened filename by:
198
  1. Extracting high-info terms
 
201
  4. Truncating if needed
202
  """
203
  prefix = format_timestamp_prefix() + "_"
204
+ combined_text = (prompt + " " + response)[:200] # limit huge text input
205
+ info_terms = get_high_info_terms(combined_text, top_n=5)
 
 
 
 
 
 
206
  snippet = (prompt[:40] + " " + response[:40]).strip()
207
  snippet_cleaned = clean_text_for_filename(snippet)
 
 
208
  name_parts = info_terms + [snippet_cleaned]
209
  full_name = '_'.join(name_parts).strip('_')
 
 
 
210
  leftover_chars = max_length - len(prefix) - len(file_type) - 1
211
  if len(full_name) > leftover_chars:
212
  full_name = full_name[:leftover_chars]