demetz commited on
Commit
d766c18
·
verified ·
1 Parent(s): 7aca342

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -10
app.py CHANGED
@@ -62,10 +62,9 @@ def respond(message, history):
62
 
63
  stream = client.chat_completion(
64
  messages,
65
- max_tokens=200-300,
66
  temperature=1.2,
67
  stream=True,
68
- stop=["."]
69
  )
70
 
71
  for message in stream:
@@ -74,16 +73,16 @@ def respond(message, history):
74
  response += token
75
  yield response
76
 
77
- # if len(response) > char_limit:
78
- # response = response[:char_limit]
79
 
80
- # for punc in [".", "!", "?"]:
81
- # i = response.rfind(punc)
82
- # if i != -1:
83
- # response = response[:i+1]
84
- # break
85
 
86
- # yield response
87
 
88
  chatbot = gr.ChatInterface(respond, type="messages")
89
 
 
62
 
63
  stream = client.chat_completion(
64
  messages,
65
+ max_tokens=300,
66
  temperature=1.2,
67
  stream=True,
 
68
  )
69
 
70
  for message in stream:
 
73
  response += token
74
  yield response
75
 
76
+ if len(response) > char_limit:
77
+ response = response[:char_limit]
78
 
79
+ for punc in [".", "!", "?"]:
80
+ i = response.rfind(punc)
81
+ if i != -1:
82
+ response = response[:i+1]
83
+ break
84
 
85
+ yield response
86
 
87
  chatbot = gr.ChatInterface(respond, type="messages")
88