Upload app.py
Browse files
app.py
CHANGED
|
@@ -140,7 +140,17 @@ def generate_scene_instruction_with_groq(affection, stage_name, scene, previous_
|
|
| 140 |
{"role": "user", "content": prompt_template}],
|
| 141 |
model="llama3-8b-8192", temperature=0.8, response_format={"type": "json_object"},
|
| 142 |
)
|
| 143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
return params
|
| 145 |
except Exception as e:
|
| 146 |
print(f"指示書生成エラー(Groq): {e}")
|
|
@@ -224,8 +234,10 @@ def respond(message, chat_history, affection, history, scene_params):
|
|
| 224 |
new_params_base = generate_scene_instruction_with_groq(new_affection, stage_name, new_scene_name, message)
|
| 225 |
if new_params_base:
|
| 226 |
final_scene_params = {**DEFAULT_SCENE_PARAMS, **new_params_base}
|
| 227 |
-
|
| 228 |
-
|
|
|
|
|
|
|
| 229 |
else:
|
| 230 |
final_scene_params["theme"] = new_scene_name
|
| 231 |
bot_message = generate_dialogue_with_gemini(history, message, new_affection, stage_name, final_scene_params)
|
|
|
|
| 140 |
{"role": "user", "content": prompt_template}],
|
| 141 |
model="llama3-8b-8192", temperature=0.8, response_format={"type": "json_object"},
|
| 142 |
)
|
| 143 |
+
response_content = chat_completion.choices[0].message.content
|
| 144 |
+
print(f"Groqからの応答: {response_content}") # デバッグ出力
|
| 145 |
+
params = json.loads(response_content)
|
| 146 |
+
|
| 147 |
+
# 安全のため、initial_dialogue_instructionを簡略化
|
| 148 |
+
if "initial_dialogue_instruction" in params:
|
| 149 |
+
original = params["initial_dialogue_instruction"]
|
| 150 |
+
simplified = f"{scene}に来た感想を述べる"
|
| 151 |
+
print(f"指示を簡略化: {original} -> {simplified}")
|
| 152 |
+
params["initial_dialogue_instruction"] = simplified
|
| 153 |
+
|
| 154 |
return params
|
| 155 |
except Exception as e:
|
| 156 |
print(f"指示書生成エラー(Groq): {e}")
|
|
|
|
| 234 |
new_params_base = generate_scene_instruction_with_groq(new_affection, stage_name, new_scene_name, message)
|
| 235 |
if new_params_base:
|
| 236 |
final_scene_params = {**DEFAULT_SCENE_PARAMS, **new_params_base}
|
| 237 |
+
# 安全のため、シンプルな指示を使用
|
| 238 |
+
simple_instruction = f"{new_scene_name}に来た感想を述べる"
|
| 239 |
+
print(f"シンプルな指示を使用: {simple_instruction}")
|
| 240 |
+
bot_message = generate_dialogue_with_gemini(history, message, new_affection, stage_name, final_scene_params, instruction=simple_instruction)
|
| 241 |
else:
|
| 242 |
final_scene_params["theme"] = new_scene_name
|
| 243 |
bot_message = generate_dialogue_with_gemini(history, message, new_affection, stage_name, final_scene_params)
|