Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -167,10 +167,12 @@ def chatbot_conversation(audio_file_path, history):
|
|
167 |
response_format={"type": "text"}
|
168 |
):
|
169 |
token = message.choices[0].delta.content
|
170 |
-
|
|
|
|
|
171 |
response += token
|
172 |
# Yield partial text updates, no audio yet, history unchanged yet
|
173 |
-
yield(response, None, history)
|
174 |
except Exception as e:
|
175 |
print(f"[ERROR] Error during streaming response: {e}")
|
176 |
yield ("I could not understand you. Please try again.", None, history)
|
|
|
167 |
response_format={"type": "text"}
|
168 |
):
|
169 |
token = message.choices[0].delta.content
|
170 |
+
if token:
|
171 |
+
token = token.replace("<|im_start|>", "").replace("<|im_end|>", "")
|
172 |
+
print(token, end="")
|
173 |
response += token
|
174 |
# Yield partial text updates, no audio yet, history unchanged yet
|
175 |
+
yield (response, None, history)
|
176 |
except Exception as e:
|
177 |
print(f"[ERROR] Error during streaming response: {e}")
|
178 |
yield ("I could not understand you. Please try again.", None, history)
|