Upload app.py
Browse files
app.py
CHANGED
|
@@ -146,11 +146,17 @@ def respond(message, chat_history, affection, scene_params, limiter_state):
|
|
| 146 |
- JSONオブジェクト以外は絶対に出力しないでください。
|
| 147 |
- "true", "false", "yes", "no" など単語だけを出力しないでください。' # (省略)
|
| 148 |
"""
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
|
| 155 |
if new_scene_name and new_scene_name != "none" and new_scene_name != final_scene_params.get("theme"):
|
| 156 |
if not check_limiter(limiter_state):
|
|
|
|
| 146 |
- JSONオブジェクト以外は絶対に出力しないでください。
|
| 147 |
- "true", "false", "yes", "no" など単語だけを出力しないでください。' # (省略)
|
| 148 |
"""
|
| 149 |
+
new_scene_name_json = call_llm(detect_system_prompt, detect_prompt, is_json_output=True)
|
| 150 |
+
new_scene_name = None
|
| 151 |
+
if new_scene_name_json:
|
| 152 |
+
try:
|
| 153 |
+
parsed = json.loads(new_scene_name_json)
|
| 154 |
+
if isinstance(parsed, dict):
|
| 155 |
+
new_scene_name = parsed.get("scene")
|
| 156 |
+
else:
|
| 157 |
+
logger.warning(f"想定外のJSON形式が返されました: {parsed}")
|
| 158 |
+
except Exception as e:
|
| 159 |
+
logger.error(f"JSONパースに失敗しました: {e}\n元の出力: {new_scene_name_json}")
|
| 160 |
|
| 161 |
if new_scene_name and new_scene_name != "none" and new_scene_name != final_scene_params.get("theme"):
|
| 162 |
if not check_limiter(limiter_state):
|