NursNurs commited on
Commit
068dc8d
1 Parent(s): 535ebbf

Added a Play again button

Browse files
Files changed (1) hide show
  1. app.py +9 -12
app.py CHANGED
@@ -19,9 +19,6 @@ def get_models():
19
 
20
  st.write("The assistant is loaded and ready to use!")
21
  return model, tokenizer
22
-
23
- # st.session_state.model['model'] = model
24
- # st.session_state.model['tokenizer'] = tokenizer
25
 
26
  model, tokenizer = get_models()
27
 
@@ -54,7 +51,7 @@ def return_top_k(sentence, k=10):
54
  probabilities = [round(float(prob), 2) for prob in decoded_probabilities]
55
 
56
  for pred in predictions:
57
- if len(pred) < 2:
58
  predictions.pop(predictions.index(pred))
59
 
60
  return predictions[:10]
@@ -78,13 +75,6 @@ if 'is_helpful' not in st.session_state:
78
  if 'descriptions' not in st.session_state:
79
  st.session_state.descriptions = []
80
 
81
- # if 'model' not in st.session_state:
82
- # st.session_state.model = {'model': False, 'tokenizer': False}
83
-
84
- # if st.session_state.model['model'] == False:
85
- # get_models()
86
- # st.write("The assistant is loaded and ready to use!")
87
-
88
  st.title("You name it!")
89
 
90
  with st.chat_message('user', avatar='simon.jpg'):
@@ -180,12 +170,19 @@ if st.session_state.actions[-1] == 'cue':
180
 
181
  elif b4:
182
  write_bot("Yay! I am happy I could be of help!")
 
 
 
183
  guessed = True
 
184
  break
185
 
186
  elif b5:
187
  write_bot("I am sorry I couldn't help you this time. See you soon!")
188
  st.session_state.actions.append('cue')
 
 
 
189
  break
190
 
191
  #display user message in chat message container
@@ -195,7 +192,7 @@ if prompt:
195
  st.markdown(prompt)
196
  #add to history
197
  st.session_state.messages.append({'role': 'user', 'content': prompt})
198
- yes = ['yes', 'again', 'Yes', 'sure', 'new word', 'yes!']
199
  if prompt in yes:
200
  write_bot("Please describe your word!")
201
  elif prompt == 'It is similar to the best place on earth':
 
19
 
20
  st.write("The assistant is loaded and ready to use!")
21
  return model, tokenizer
 
 
 
22
 
23
  model, tokenizer = get_models()
24
 
 
51
  probabilities = [round(float(prob), 2) for prob in decoded_probabilities]
52
 
53
  for pred in predictions:
54
+ if (len(pred) < 2) | (pred in sentence.split()):
55
  predictions.pop(predictions.index(pred))
56
 
57
  return predictions[:10]
 
75
  if 'descriptions' not in st.session_state:
76
  st.session_state.descriptions = []
77
 
 
 
 
 
 
 
 
78
  st.title("You name it!")
79
 
80
  with st.chat_message('user', avatar='simon.jpg'):
 
170
 
171
  elif b4:
172
  write_bot("Yay! I am happy I could be of help!")
173
+ new = st.button('Play again', key=63)
174
+ if new:
175
+ write_bot("Please describe your word!")
176
  guessed = True
177
+
178
  break
179
 
180
  elif b5:
181
  write_bot("I am sorry I couldn't help you this time. See you soon!")
182
  st.session_state.actions.append('cue')
183
+ new = st.button('Play again', key=64)
184
+ if new:
185
+ write_bot("Please describe your word!")
186
  break
187
 
188
  #display user message in chat message container
 
192
  st.markdown(prompt)
193
  #add to history
194
  st.session_state.messages.append({'role': 'user', 'content': prompt})
195
+ yes = ['yes', 'again', 'Yes', 'sure', 'new word', 'yes!', 'yep', 'yeah']
196
  if prompt in yes:
197
  write_bot("Please describe your word!")
198
  elif prompt == 'It is similar to the best place on earth':