freddyaboulton HF Staff commited on
Commit
bf67dce
·
verified ·
1 Parent(s): ec31fe5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -203,8 +203,10 @@ def _generate(message: dict, history: list[dict], system_prompt: str = "", max_n
203
  @spaces.GPU(time_limit=120)
204
  def generate(data: WebRTCData, history: list[dict], system_prompt: str = "", max_new_tokens: int = 512, image=None):
205
  files = []
 
206
  if data.audio is not None and data.audio[1].size > 0:
207
- files.append(save_audio_to_cache(data.audio[1], data.audio[0], format="mp3", cache_dir=get_upload_folder()))
 
208
  if image is not None:
209
  files.append(image)
210
  message = {
@@ -212,6 +214,10 @@ def generate(data: WebRTCData, history: list[dict], system_prompt: str = "", max
212
  "files": files,
213
  }
214
  print("message", message)
 
 
 
 
215
  history.append({"role": "user", "content": data.textbox})
216
  print("history", history)
217
  yield AdditionalOutputs(history)
 
203
  @spaces.GPU(time_limit=120)
204
  def generate(data: WebRTCData, history: list[dict], system_prompt: str = "", max_new_tokens: int = 512, image=None):
205
  files = []
206
+ audio_file = None
207
  if data.audio is not None and data.audio[1].size > 0:
208
+ audio_file = save_audio_to_cache(data.audio[1], data.audio[0], format="mp3", cache_dir=get_upload_folder())
209
+ files.append(audio_file)
210
  if image is not None:
211
  files.append(image)
212
  message = {
 
214
  "files": files,
215
  }
216
  print("message", message)
217
+ if image is not None:
218
+ history.append({"role": "user", "content": (image,)})
219
+ if audio_file is not None:
220
+ history.append({"role": "user", "content": (audio_file,)})
221
  history.append({"role": "user", "content": data.textbox})
222
  print("history", history)
223
  yield AdditionalOutputs(history)