import os import json SCENARIOS = { 'sword': 'prompts/system_sword.txt', 'potion': 'prompts/system_potion.txt', 'key': 'prompts/system_key.txt' } def load_system_prompt(item_id): base_path = 'prompts/system_base.txt' item_path = SCENARIOS.get(item_id) base_prompt = "" if os.path.exists(base_path): with open(base_path, 'r') as f: base_prompt = f.read() item_prompt = "" if item_path and os.path.exists(item_path): with open(item_path, 'r') as f: item_prompt = f.read() return f"{base_prompt}\n\n{item_prompt}" def log_trace(entry): os.makedirs('data', exist_ok=True) with open('data/trace.jsonl', 'a') as f: f.write(json.dumps(entry) + '\n')