freddyaboulton HF staff commited on
Commit
cd39652
1 Parent(s): abcd3d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -12
app.py CHANGED
@@ -107,22 +107,15 @@ with gr.Blocks() as demo:
107
  webrtc.stream(MoshiHandler("https://freddyaboulton-moshi-server.hf.space"),
108
  inputs=[webrtc, chatbot], outputs=[webrtc], time_limit=90)
109
 
110
- def on_text(state, response):
111
- print("response", response)
112
- return state + response
113
-
114
  def add_text(chat_history, response):
115
  if len(chat_history) == 0:
116
- chat_history.append({"role": "assistant", "content": response})
117
- else:
118
- chat_history[-1]["content"] = response
119
  return chat_history
120
 
121
- webrtc.on_additional_outputs(on_text,
122
- inputs=[response], outputs=response,
123
- queue=True,
124
  show_progress="hidden")
125
- response.change(add_text, inputs=[chatbot, response], outputs=chatbot,
126
- queue=True, show_progress="hidden")
127
 
128
  demo.launch()
 
107
  webrtc.stream(MoshiHandler("https://freddyaboulton-moshi-server.hf.space"),
108
  inputs=[webrtc, chatbot], outputs=[webrtc], time_limit=90)
109
 
 
 
 
 
110
  def add_text(chat_history, response):
111
  if len(chat_history) == 0:
112
+ chat_history.append({"role": "assistant", "content": ""})
113
+ chat_history[-1]["content"] += response
 
114
  return chat_history
115
 
116
+ webrtc.on_additional_outputs(add_text,
117
+ inputs=[chatbot], outputs=chatbot,
118
+ queue=False,
119
  show_progress="hidden")
 
 
120
 
121
  demo.launch()