Update app.py
Browse files
app.py
CHANGED
@@ -62,10 +62,9 @@ def respond(message, history):
|
|
62 |
|
63 |
stream = client.chat_completion(
|
64 |
messages,
|
65 |
-
max_tokens=
|
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 |
-
|
78 |
-
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
|
86 |
-
|
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 |
|