awacke1 commited on
Commit
7f9bfe7
Β·
1 Parent(s): 2a0fe4c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -10
app.py CHANGED
@@ -49,7 +49,14 @@ with col1:
49
  choice = st.sidebar.selectbox("Output File Type:", menu)
50
  model_choice = st.sidebar.radio("Select Model:", ('gpt-3.5-turbo', 'gpt-3.5-turbo-0301'))
51
 
52
- # Define a context dictionary to maintain the state between exec calls
 
 
 
 
 
 
 
53
  context = {}
54
 
55
  def create_file(filename, prompt, response, should_save=True):
@@ -112,10 +119,9 @@ def create_file(filename, prompt, response, should_save=True):
112
  href = f'<a href="data:file/markdown;base64,{encoded_file}" download="{filename}">Download File πŸ“„</a>'
113
  st.markdown(href, unsafe_allow_html=True)
114
 
115
-
116
- # Read it aloud
117
  def readitaloud(result):
118
- documentHTML5='''
119
  <!DOCTYPE html>
120
  <html>
121
  <head>
@@ -144,12 +150,15 @@ def readitaloud(result):
144
  components.html(documentHTML5, width=800, height=300)
145
  #return result
146
 
147
- def generate_filename(prompt, file_type):
148
- central = pytz.timezone('US/Central')
149
- safe_date_time = datetime.now(central).strftime("%m%d_%H%M")
150
- replaced_prompt = prompt.replace(" ", "_").replace("\n", "_")
151
- safe_prompt = "".join(x for x in replaced_prompt if x.isalnum() or x == "_")[:90]
152
- return f"{safe_date_time}_{safe_prompt}.{file_type}"
 
 
 
153
 
154
  # Chat and Chat with files
155
  def chat_with_model(prompt, document_section, model_choice='gpt-3.5-turbo'):
 
49
  choice = st.sidebar.selectbox("Output File Type:", menu)
50
  model_choice = st.sidebar.radio("Select Model:", ('gpt-3.5-turbo', 'gpt-3.5-turbo-0301'))
51
 
52
+ def generate_filename(prompt, file_type):
53
+ central = pytz.timezone('US/Central')
54
+ safe_date_time = datetime.now(central).strftime("%m%d_%H%M")
55
+ replaced_prompt = prompt.replace(" ", "_").replace("\n", "_")
56
+ safe_prompt = "".join(x for x in replaced_prompt if x.isalnum() or x == "_")[:90]
57
+ return f"{safe_date_time}_{safe_prompt}.{file_type}"
58
+
59
+ # Give create file a context dictionary to maintain the state between exec calls
60
  context = {}
61
 
62
  def create_file(filename, prompt, response, should_save=True):
 
119
  href = f'<a href="data:file/markdown;base64,{encoded_file}" download="{filename}">Download File πŸ“„</a>'
120
  st.markdown(href, unsafe_allow_html=True)
121
 
122
+ # Read it aloud
 
123
  def readitaloud(result):
124
+ documentHTML5 = '''
125
  <!DOCTYPE html>
126
  <html>
127
  <head>
 
150
  components.html(documentHTML5, width=800, height=300)
151
  #return result
152
 
153
+ # Example usage:
154
+ #prompt = "This is a sample prompt with emojis! 😊"
155
+ #response = "This is a sample response with emojis! πŸš€"
156
+ #filename = generate_filename(prompt, "html")
157
+ #create_file(filename, prompt, response)
158
+
159
+ # Example usage for reading aloud:
160
+ #response_for_reading_aloud = "This is a response for reading aloud."
161
+ #readitaloud(response_for_reading_aloud)
162
 
163
  # Chat and Chat with files
164
  def chat_with_model(prompt, document_section, model_choice='gpt-3.5-turbo'):