demetz commited on
Commit
d6e934b
·
verified ·
1 Parent(s): 12cf6fc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -39,6 +39,7 @@ client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
39
 
40
  def respond(message, history):
41
  response = ""
 
42
 
43
  top_chunks = get_top_chunks(message)
44
  context = "\n".join(top_chunks)
@@ -71,14 +72,15 @@ def respond(message, history):
71
  response += token
72
  yield response
73
 
74
- if len(response) > max_tokens:
75
- response = response[:max_tokens]
76
 
77
  for punc in [".", "!", "?"]:
78
  i = response.rfind(punc)
79
  if i != -1:
80
  response = response[:i+1]
81
-
 
82
  yield response
83
 
84
  chatbot = gr.ChatInterface(respond, type="messages")
 
39
 
40
  def respond(message, history):
41
  response = ""
42
+ char_limit= 500
43
 
44
  top_chunks = get_top_chunks(message)
45
  context = "\n".join(top_chunks)
 
72
  response += token
73
  yield response
74
 
75
+ if len(response) > char_limit:
76
+ response = response[:char_limit]
77
 
78
  for punc in [".", "!", "?"]:
79
  i = response.rfind(punc)
80
  if i != -1:
81
  response = response[:i+1]
82
+ break
83
+
84
  yield response
85
 
86
  chatbot = gr.ChatInterface(respond, type="messages")