schlenker commited on
Commit
da4be0c
·
1 Parent(s): 971a4bf

clean up code

Browse files
Files changed (1) hide show
  1. app.py +36 -34
app.py CHANGED
@@ -108,40 +108,7 @@ def get_related_words(word, num=5):
108
 
109
  return ", ".join(beam_preds[:num])
110
 
111
- if 'messages' not in st.session_state:
112
- st.session_state.messages = []
113
-
114
- if 'results' not in st.session_state:
115
- st.session_state.results = {'results': False, 'results_print': False}
116
-
117
- if 'actions' not in st.session_state:
118
- st.session_state.actions = [""]
119
-
120
- if 'counters' not in st.session_state:
121
- st.session_state.counters = {"letter_count": 1, "word_count": 0}
122
-
123
- if 'is_helpful' not in st.session_state:
124
- st.session_state.is_helpful = {'ask':False}
125
-
126
- if 'descriptions' not in st.session_state:
127
- st.session_state.descriptions = []
128
-
129
- st.title("You name it! 🗣")
130
-
131
- with st.chat_message('user', avatar='simon.jpg'):
132
- st.write("Hey assistant!")
133
-
134
- bot = st.chat_message('assistant')
135
- bot.write("Hello human! Wanna practice naming some words?")
136
-
137
- #for showing history of messages
138
- for message in st.session_state.messages:
139
- if message['role'] == 'user':
140
- with st.chat_message(message['role'], avatar='simon.jpg'):
141
- st.markdown(message['content'])
142
- else:
143
- with st.chat_message(message['role']):
144
- st.markdown(message['content'])
145
 
146
  def get_text():
147
  input_text = st.chat_input()
@@ -239,6 +206,41 @@ def get_available_cues(target):
239
  # JS: moved the cue generation further down
240
  #def cue_generation():
241
  # if st.session_state.actions[-1] == 'cue':
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
 
243
  #display user message in chat message container
244
  prompt = get_text()
 
108
 
109
  return ", ".join(beam_preds[:num])
110
 
111
+ #if 'messages' not in st.session_state:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
 
113
  def get_text():
114
  input_text = st.chat_input()
 
206
  # JS: moved the cue generation further down
207
  #def cue_generation():
208
  # if st.session_state.actions[-1] == 'cue':
209
+
210
+ if 'messages' not in st.session_state:
211
+ st.session_state.messages = []
212
+
213
+ if 'results' not in st.session_state:
214
+ st.session_state.results = {'results': False, 'results_print': False}
215
+
216
+ if 'actions' not in st.session_state:
217
+ st.session_state.actions = [""]
218
+
219
+ if 'counters' not in st.session_state:
220
+ st.session_state.counters = {"letter_count": 1, "word_count": 0}
221
+
222
+ if 'is_helpful' not in st.session_state:
223
+ st.session_state.is_helpful = {'ask':False}
224
+
225
+ if 'descriptions' not in st.session_state:
226
+ st.session_state.descriptions = []
227
+
228
+ st.title("You name it! 🗣")
229
+
230
+ with st.chat_message('user', avatar='simon.jpg'):
231
+ st.write("Hey assistant!")
232
+
233
+ bot = st.chat_message('assistant')
234
+ bot.write("Hello human! Wanna practice naming some words?")
235
+
236
+ #for showing history of messages
237
+ for message in st.session_state.messages:
238
+ if message['role'] == 'user':
239
+ with st.chat_message(message['role'], avatar='simon.jpg'):
240
+ st.markdown(message['content'])
241
+ else:
242
+ with st.chat_message(message['role']):
243
+ st.markdown(message['content'])
244
 
245
  #display user message in chat message container
246
  prompt = get_text()