Nada commited on
Commit
b67bb23
·
1 Parent(s): 540d76a
Files changed (1) hide show
  1. chatbot.py +14 -0
chatbot.py CHANGED
@@ -579,6 +579,20 @@ Response:"""
579
  response = response.split("Response:")[-1].strip()
580
  response = re.sub(r'^(Hey|Hi|Hello|Hi there|Hey there),\s*', '', response)
581
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
582
  return response.strip()
583
 
584
  def generate_session_summary(
 
579
  response = response.split("Response:")[-1].strip()
580
  response = re.sub(r'^(Hey|Hi|Hello|Hi there|Hey there),\s*', '', response)
581
 
582
+ # Limit response length
583
+ max_words = 60
584
+ max_sentences = 4
585
+
586
+ # Split into sentences
587
+ sentences = re.split(r'(?<=[.!?]) +', response)
588
+ if len(sentences) > max_sentences:
589
+ response = ' '.join(sentences[:max_sentences])
590
+
591
+ # Split into words
592
+ words = response.split()
593
+ if len(words) > max_words:
594
+ response = ' '.join(words[:max_words]) + '...'
595
+
596
  return response.strip()
597
 
598
  def generate_session_summary(