Update app.py
Browse files
app.py
CHANGED
@@ -191,20 +191,19 @@ def respond(message, history: list, system_message, max_tokens, temperature, top
|
|
191 |
messages_list.append({"role": "user", "content": message})
|
192 |
|
193 |
# Generate the assistant's answer by streaming responses.
|
194 |
-
response_text = ""
|
195 |
-
for partial_response in client.chat_completion(
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
):
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
# --- Gradio Chat Interface ---
|
209 |
demo = gr.ChatInterface(
|
210 |
fn=respond,
|
|
|
191 |
messages_list.append({"role": "user", "content": message})
|
192 |
|
193 |
# Generate the assistant's answer by streaming responses.
|
194 |
+
response_text = ""
|
195 |
+
for partial_response in client.chat_completion(
|
196 |
+
messages_list,
|
197 |
+
max_tokens=1024,
|
198 |
+
stream=True,
|
199 |
+
temperature=temperature,
|
200 |
+
top_p=top_p,
|
201 |
+
):
|
202 |
+
if partial_response.choices and partial_response.choices[0].delta:
|
203 |
+
token = partial_response.choices[0].delta.content
|
204 |
+
if token:
|
205 |
+
response_text += token
|
206 |
+
yield response_text
|
|
|
207 |
# --- Gradio Chat Interface ---
|
208 |
demo = gr.ChatInterface(
|
209 |
fn=respond,
|