gorkemgoknar commited on
Commit
95b3196
1 Parent(s): e0a3048

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -11
app.py CHANGED
@@ -508,19 +508,23 @@ def get_sentence(history, chatbot_role,llm_model,system_prompt=""):
508
  yield (sentence, history)
509
 
510
  # return that final sentence token
511
- last_sentence = nltk.sent_tokenize(history[-1][1].replace("\n", " ").strip())[-1]
512
- sentence_hash = hash(last_sentence)
513
- if sentence_hash not in sentence_hash_list:
514
- if stored_sentence is not None and stored_sentence_hash is not None:
515
- last_sentence = stored_sentence + last_sentence
516
- stored_sentence = stored_sentence_hash = None
517
- print("Last Sentence with stored:",last_sentence)
 
 
 
 
 
518
 
519
- sentence_hash_list.append(sentence_hash)
520
- sentence_list.append(last_sentence)
521
- print("Last Sentence: ", last_sentence)
522
 
523
- yield (last_sentence, history)
524
 
525
  from scipy.io.wavfile import write
526
  from pydub import AudioSegment
 
508
  yield (sentence, history)
509
 
510
  # return that final sentence token
511
+ try:
512
+ last_sentence = nltk.sent_tokenize(history[-1][1].replace("\n", " ").strip())[-1]
513
+ sentence_hash = hash(last_sentence)
514
+ if sentence_hash not in sentence_hash_list:
515
+ if stored_sentence is not None and stored_sentence_hash is not None:
516
+ last_sentence = stored_sentence + last_sentence
517
+ stored_sentence = stored_sentence_hash = None
518
+ print("Last Sentence with stored:",last_sentence)
519
+
520
+ sentence_hash_list.append(sentence_hash)
521
+ sentence_list.append(last_sentence)
522
+ print("Last Sentence: ", last_sentence)
523
 
524
+ yield (last_sentence, history)
525
+ except:
526
+ print("ERROR on last sentence history is :", history)
527
 
 
528
 
529
  from scipy.io.wavfile import write
530
  from pydub import AudioSegment