Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -36,10 +36,6 @@ def set_state(state, openai_key, voice, auto_play, speed):
|
|
| 36 |
def add_history(history, text_msg):
|
| 37 |
""" Chat履歴"history"に追加を行う関数 """
|
| 38 |
|
| 39 |
-
print(text_msg)
|
| 40 |
-
print(history)
|
| 41 |
-
|
| 42 |
-
|
| 43 |
# ユーザテキストをチャットに追加
|
| 44 |
history = history + [(text_msg, None)]
|
| 45 |
|
|
@@ -263,9 +259,6 @@ def bot(state, mode, history):
|
|
| 263 |
# 最新のユーザからのメッセージ
|
| 264 |
user_msg = history[-1][0]
|
| 265 |
|
| 266 |
-
print(history)
|
| 267 |
-
print(user_msg)
|
| 268 |
-
|
| 269 |
if mode in (0, 1): # 日本語会話モードの場合
|
| 270 |
|
| 271 |
# メッセージ作成
|
|
@@ -378,8 +371,6 @@ def finally_proc(state, history, err_msg):
|
|
| 378 |
|
| 379 |
if err_msg == "":
|
| 380 |
|
| 381 |
-
print(history[-1][1][0])
|
| 382 |
-
|
| 383 |
# 出力オーディオをセット
|
| 384 |
audio = gr.update(value=history[-1][1][0], autoplay=state["auto_play"])
|
| 385 |
|
|
@@ -447,6 +438,13 @@ with gr.Blocks() as demo:
|
|
| 447 |
bot, [state, mode, chatbot], [chatbot, sys_msg]).then(
|
| 448 |
finally_proc, [state, chatbot, sys_msg], [text_msg, voice_msg, out_voice], queue=False)
|
| 449 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 450 |
# 録音終了時の処理
|
| 451 |
# voice_msg.stop_recording(init, [state, mode, text_msg, voice_msg],[state, text_msg, sys_msg], queue=False).then(
|
| 452 |
# raise_exception, sys_msg, None).success(
|
|
|
|
| 36 |
def add_history(history, text_msg):
|
| 37 |
""" Chat履歴"history"に追加を行う関数 """
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
# ユーザテキストをチャットに追加
|
| 40 |
history = history + [(text_msg, None)]
|
| 41 |
|
|
|
|
| 259 |
# 最新のユーザからのメッセージ
|
| 260 |
user_msg = history[-1][0]
|
| 261 |
|
|
|
|
|
|
|
|
|
|
| 262 |
if mode in (0, 1): # 日本語会話モードの場合
|
| 263 |
|
| 264 |
# メッセージ作成
|
|
|
|
| 371 |
|
| 372 |
if err_msg == "":
|
| 373 |
|
|
|
|
|
|
|
| 374 |
# 出力オーディオをセット
|
| 375 |
audio = gr.update(value=history[-1][1][0], autoplay=state["auto_play"])
|
| 376 |
|
|
|
|
| 438 |
bot, [state, mode, chatbot], [chatbot, sys_msg]).then(
|
| 439 |
finally_proc, [state, chatbot, sys_msg], [text_msg, voice_msg, out_voice], queue=False)
|
| 440 |
|
| 441 |
+
# メッセージ送信時の処理
|
| 442 |
+
text_msg.submit(init, [state, mode, text_msg, voice_msg],[state, text_msg, sys_msg], queue=False).then(
|
| 443 |
+
raise_exception, sys_msg, None).success(
|
| 444 |
+
add_history, [chatbot, text_msg], [chatbot, text_msg, voice_msg], queue=False).then(
|
| 445 |
+
bot, [state, mode, chatbot], [chatbot, sys_msg]).then(
|
| 446 |
+
finally_proc, [state, chatbot, sys_msg], [text_msg, voice_msg, out_voice], queue=False)
|
| 447 |
+
|
| 448 |
# 録音終了時の処理
|
| 449 |
# voice_msg.stop_recording(init, [state, mode, text_msg, voice_msg],[state, text_msg, sys_msg], queue=False).then(
|
| 450 |
# raise_exception, sys_msg, None).success(
|