rodrigomasini commited on
Commit
69b4885
·
verified ·
1 Parent(s): 9aa4381

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
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
- print(token)
 
 
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)