MoiMoi-01 commited on
Commit
4c352f8
·
verified ·
1 Parent(s): 6e54df2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -43,10 +43,10 @@ def respond(message, history, system_message, max_tokens, temperature, top_p):
43
  messages.append({"role": "user", "content": message})
44
 
45
  response = ""
46
- for message in client.chat_completion(messages, max_tokens=max_tokens, stream=True, temperature=temperature, top_p=top_p):
47
- token = message.choices[0].delta.content
48
- response += token
49
- yield response, None, None # Text first
50
 
51
  # Generate Speech from Text (CPU Mode)
52
  tts_audio_path = "tts_output.wav"
@@ -56,13 +56,13 @@ def respond(message, history, system_message, max_tokens, temperature, top_p):
56
  rvc_audio_path = "rvc_output.wav"
57
  rvc_converted_path = convert_voice(tts_audio_path, rvc_audio_path)
58
 
59
- yield response, tts_audio_path, rvc_converted_path # Send text, TTS, and RVC output
60
 
61
  # Gradio UI
62
  with gr.Blocks() as demo:
63
  gr.Markdown("## DeepSeek R1 7B Chatbot with ZeldaBotW Voice (CPU Mode)")
64
 
65
- chatbot = gr.Chatbot()
66
  msg = gr.Textbox(label="User Input")
67
 
68
  system_msg = gr.Textbox(value="You are a friendly Chatbot.", label="System Message")
 
43
  messages.append({"role": "user", "content": message})
44
 
45
  response = ""
46
+
47
+ # Get LLM Response
48
+ for message in client.chat_completion(messages, max_tokens=max_tokens, stream=False, temperature=temperature, top_p=top_p):
49
+ response += message.choices[0].message.content
50
 
51
  # Generate Speech from Text (CPU Mode)
52
  tts_audio_path = "tts_output.wav"
 
56
  rvc_audio_path = "rvc_output.wav"
57
  rvc_converted_path = convert_voice(tts_audio_path, rvc_audio_path)
58
 
59
+ return response, tts_audio_path, rvc_converted_path # Now correctly returns all outputs
60
 
61
  # Gradio UI
62
  with gr.Blocks() as demo:
63
  gr.Markdown("## DeepSeek R1 7B Chatbot with ZeldaBotW Voice (CPU Mode)")
64
 
65
+ chatbot = gr.Chatbot(type="messages") # ✅ Fix deprecated type warning
66
  msg = gr.Textbox(label="User Input")
67
 
68
  system_msg = gr.Textbox(value="You are a friendly Chatbot.", label="System Message")