NursNurs commited on
Commit
44bb176
·
1 Parent(s): 9ba933a

fixed the previous commit a bit

Browse files
Files changed (1) hide show
  1. pages/1_Descriptive_chatbot.py +18 -17
pages/1_Descriptive_chatbot.py CHANGED
@@ -264,23 +264,24 @@ if prompt:
264
  #TODO: replace it with zero-shot classifier
265
  yes = ['yes', 'again', 'sure', 'new word', 'yes!', 'yep', 'yeah']
266
  no = ['no', 'nope', 'nah']
267
- if prompt.lower() in yes:
268
- write_bot("Please describe your word!")
269
- elif prompt.lower() in no:
270
- write_bot("Okay, see you next time then! :innocent:")
271
- elif prompt == 'it is similar to the best place on earth':
272
- write_bot("Great! Let me think what it could be...")
273
- time.sleep(3)
274
- write_bot("Do you mean Saarland?")
275
- #if previously we asked to give a prompt
276
- elif (st.session_state.messages[-2]['content'] == "Please describe your word!") & (st.session_state.messages[-1]['content'] != "no"):
277
- write_bot("Great! Let me think what it could be...")
278
- st.session_state.descriptions.append(prompt)
279
- st.session_state.results['results'] = return_top_k(st.session_state.descriptions[-1])
280
- st.session_state.results['results_print'] = dict(zip(range(1, 11), st.session_state.results['results']))
281
- write_bot("I think I have some ideas. Do you want to see my guesses or do you want a cue?")
282
- st.session_state.actions.append("result")
283
- else:
 
284
  write_bot("Sorry, I didn't understand you... I am still learning :sob: For now, could you respond with 'yes' or 'no'? ")
285
 
286
  if st.session_state.actions[-1] == "result":
 
264
  #TODO: replace it with zero-shot classifier
265
  yes = ['yes', 'again', 'sure', 'new word', 'yes!', 'yep', 'yeah']
266
  no = ['no', 'nope', 'nah']
267
+ try:
268
+ if prompt.lower() in yes:
269
+ write_bot("Please describe your word!")
270
+ elif prompt.lower() in no:
271
+ write_bot("Okay, see you next time then! :innocent:")
272
+ elif prompt == 'it is similar to the best place on earth':
273
+ write_bot("Great! Let me think what it could be...")
274
+ time.sleep(3)
275
+ write_bot("Do you mean Saarland?")
276
+ #if previously we asked to give a prompt
277
+ elif (st.session_state.messages[-2]['content'] == "Please describe your word!") & (st.session_state.messages[-1]['content'] != "no"):
278
+ write_bot("Great! Let me think what it could be...")
279
+ st.session_state.descriptions.append(prompt)
280
+ st.session_state.results['results'] = return_top_k(st.session_state.descriptions[-1])
281
+ st.session_state.results['results_print'] = dict(zip(range(1, 11), st.session_state.results['results']))
282
+ write_bot("I think I have some ideas. Do you want to see my guesses or do you want a cue?")
283
+ st.session_state.actions.append("result")
284
+ except:
285
  write_bot("Sorry, I didn't understand you... I am still learning :sob: For now, could you respond with 'yes' or 'no'? ")
286
 
287
  if st.session_state.actions[-1] == "result":