Upload app.py
Browse files
app.py
CHANGED
|
@@ -344,7 +344,11 @@ def update_affection(message, affection):
|
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 348 |
new_affection = update_affection(message, affection)
|
| 349 |
stage_name = get_relationship_stage(new_affection)
|
| 350 |
current_theme = scene_params.get("theme", "default")
|
|
@@ -503,18 +507,17 @@ with gr.Blocks(css=custom_css, theme=custom_theme) as demo:
|
|
| 503 |
msg_input.submit(
|
| 504 |
respond,
|
| 505 |
[msg_input, chatbot, affection_state, history_state, scene_state],
|
| 506 |
-
[msg_input, chatbot, affection_gauge, stage_display, affection_state, history_state, scene_state, background_display]
|
| 507 |
-
api_name="respond" # API名を指定して非同期処理を適切に処理
|
| 508 |
)
|
| 509 |
-
#
|
| 510 |
-
|
| 511 |
return get_relationship_stage(affection)
|
| 512 |
|
| 513 |
demo.load(load_stage, affection_state, stage_display)
|
| 514 |
|
| 515 |
if __name__ == "__main__":
|
| 516 |
-
#
|
| 517 |
demo.launch(
|
| 518 |
-
|
| 519 |
-
|
| 520 |
)
|
|
|
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
+
def respond(message, chat_history, affection, history, scene_params):
|
| 348 |
+
"""
|
| 349 |
+
チャットの応答を生成する関数
|
| 350 |
+
非同期関数として定義していたが、Gradio 5.0との互換性のために通常の関数に戻す
|
| 351 |
+
"""
|
| 352 |
new_affection = update_affection(message, affection)
|
| 353 |
stage_name = get_relationship_stage(new_affection)
|
| 354 |
current_theme = scene_params.get("theme", "default")
|
|
|
|
| 507 |
msg_input.submit(
|
| 508 |
respond,
|
| 509 |
[msg_input, chatbot, affection_state, history_state, scene_state],
|
| 510 |
+
[msg_input, chatbot, affection_gauge, stage_display, affection_state, history_state, scene_state, background_display]
|
|
|
|
| 511 |
)
|
| 512 |
+
# 通常の関数として定義
|
| 513 |
+
def load_stage(affection):
|
| 514 |
return get_relationship_stage(affection)
|
| 515 |
|
| 516 |
demo.load(load_stage, affection_state, stage_display)
|
| 517 |
|
| 518 |
if __name__ == "__main__":
|
| 519 |
+
# Gradio 5.0に対応した起動方法
|
| 520 |
demo.launch(
|
| 521 |
+
show_error=True, # エラーを表示
|
| 522 |
+
quiet=False # 詳細なログを出力
|
| 523 |
)
|