Pijush2023 commited on
Commit
9595f8d
·
verified ·
1 Parent(s): 71b8b4a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -377,7 +377,7 @@ def bot(history, choice, tts_choice, retrieval_mode, model_choice):
377
  selected_model = chat_model if model_choice == "GPT-4o" else phi_pipe
378
 
379
  response, addresses = generate_answer(history[-1][0], choice, retrieval_mode, selected_model)
380
- history[-1][1] = ""
381
 
382
  with concurrent.futures.ThreadPoolExecutor() as executor:
383
  if tts_choice == "Alpha":
@@ -385,16 +385,16 @@ def bot(history, choice, tts_choice, retrieval_mode, model_choice):
385
  elif tts_choice == "Beta":
386
  audio_stream = generate_audio_parler_tts(response)
387
 
388
- # Stream audio chunks in real-time
389
  for audio_chunk_path in audio_stream:
390
- history[-1][1] += response[:len(history[-1][1]) + 1] # Simulate text being generated
391
- yield history, audio_chunk_path
392
 
393
  history.append([response, None])
394
 
395
 
396
 
397
 
 
398
  phi_custom_template = """
399
  <|system|>
400
  You are a helpful assistant who provides clear, organized, crisp and conversational responses about an events,concerts,sports and all other activities of Birmingham,Alabama .<|end|>
 
377
  selected_model = chat_model if model_choice == "GPT-4o" else phi_pipe
378
 
379
  response, addresses = generate_answer(history[-1][0], choice, retrieval_mode, selected_model)
380
+ history[-1][1] = response # Set the full response in the history immediately
381
 
382
  with concurrent.futures.ThreadPoolExecutor() as executor:
383
  if tts_choice == "Alpha":
 
385
  elif tts_choice == "Beta":
386
  audio_stream = generate_audio_parler_tts(response)
387
 
388
+ # Stream audio chunks in real-time without interrupting text output
389
  for audio_chunk_path in audio_stream:
390
+ yield history, audio_chunk_path # Yield audio chunks as they are generated
 
391
 
392
  history.append([response, None])
393
 
394
 
395
 
396
 
397
+
398
  phi_custom_template = """
399
  <|system|>
400
  You are a helpful assistant who provides clear, organized, crisp and conversational responses about an events,concerts,sports and all other activities of Birmingham,Alabama .<|end|>