awacke1 commited on
Commit
a97d00c
·
1 Parent(s): 7528b80

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -34,12 +34,18 @@ from templates import css, bot_template, user_template
34
  st.set_page_config(page_title="GPT Streamlit Document Reasoner", layout="wide")
35
  should_save = st.sidebar.checkbox("💾 Save", value=True)
36
 
37
- def generate_filename(prompt, file_type):
38
  central = pytz.timezone('US/Central')
39
  safe_date_time = datetime.now(central).strftime("%m%d_%H%M") # Date and time DD-HHMM
40
  safe_prompt = "".join(x for x in prompt if x.isalnum())[:90] # Limit file name size and trim whitespace
41
  return f"{safe_date_time}_{safe_prompt}.{file_type}" # Return a safe file name
42
 
 
 
 
 
 
 
43
 
44
  def transcribe_audio(openai_key, file_path, model):
45
  OPENAI_API_URL = "https://api.openai.com/v1/audio/transcriptions"
 
34
  st.set_page_config(page_title="GPT Streamlit Document Reasoner", layout="wide")
35
  should_save = st.sidebar.checkbox("💾 Save", value=True)
36
 
37
+ def generate_filename_old(prompt, file_type):
38
  central = pytz.timezone('US/Central')
39
  safe_date_time = datetime.now(central).strftime("%m%d_%H%M") # Date and time DD-HHMM
40
  safe_prompt = "".join(x for x in prompt if x.isalnum())[:90] # Limit file name size and trim whitespace
41
  return f"{safe_date_time}_{safe_prompt}.{file_type}" # Return a safe file name
42
 
43
+ def generate_filename(prompt, file_type):
44
+ central = pytz.timezone('US/Central')
45
+ safe_date_time = datetime.now(central).strftime("%m%d_%H%M")
46
+ replaced_prompt = prompt.replace(" ", "_").replace("\n", "_")
47
+ safe_prompt = "".join(x for x in replaced_prompt if x.isalnum() or x == "_")[:90]
48
+ return f"{safe_date_time}_{safe_prompt}.{file_type}"
49
 
50
  def transcribe_audio(openai_key, file_path, model):
51
  OPENAI_API_URL = "https://api.openai.com/v1/audio/transcriptions"