faaizashiq commited on
Commit
6b6bb06
·
verified ·
1 Parent(s): 60b1e7f

Update backend/agents/puzzle_agent.py

Browse files
Files changed (1) hide show
  1. backend/agents/puzzle_agent.py +5 -2
backend/agents/puzzle_agent.py CHANGED
@@ -97,6 +97,7 @@ class PuzzleAgent:
97
  self.model = genai.GenerativeModel("gemini-1.5-flash-latest")
98
 
99
  # Load the 500-scenario dataset
 
100
  base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
101
  path = os.path.join(base_dir, "maze_scenarios_500.json")
102
  self.scenarios: List[Dict] = []
@@ -286,8 +287,10 @@ class PuzzleAgent:
286
  progression_str = ""
287
  for i, (scen, cg) in enumerate(zip(scenarios, compiled_grids)):
288
  t = scen.get("theme", "space").capitalize()
 
 
289
  s = " → ".join(cg["ordered_steps"]) or "reach the exit"
290
- progression_str += f"Level {i+1}: Theme = {t}, Steps = {s}\n"
291
 
292
  prompt = f"""
293
  You are the Mission Architect for CodeCracker, a STEM education app for kids.
@@ -302,7 +305,7 @@ LEARNING GOAL: {concept['description']}
302
  STRICT RULES:
303
  1. The story MUST explain the DAA concept clearly to a student (age 10-16).
304
  2. Reference the exact mission steps for that level in its goal_description.
305
- 3. CRITICAL: Provide a UNIQUE programming/logic problem in the `story` field for EACH level.
306
  4. The `title` of each level should match its assigned Theme (e.g., "Bank Heist", "Space Station").
307
  5. CRITICAL: Generate a COMPLETELY UNIQUE `hint` for EVERY level. The hint MUST be different for Level 1, Level 2, etc., and must directly reference the specific theme/logic of that exact level! Do NOT repeat hints!
308
 
 
97
  self.model = genai.GenerativeModel("gemini-1.5-flash-latest")
98
 
99
  # Load the 500-scenario dataset
100
+ # Look for the dataset inside the backend folder (safer for HuggingFace deployment)
101
  base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
102
  path = os.path.join(base_dir, "maze_scenarios_500.json")
103
  self.scenarios: List[Dict] = []
 
287
  progression_str = ""
288
  for i, (scen, cg) in enumerate(zip(scenarios, compiled_grids)):
289
  t = scen.get("theme", "space").capitalize()
290
+ title = scen.get("title", f"Level {i+1}")
291
+ base_story = scen.get("story", "Solve the maze.")
292
  s = " → ".join(cg["ordered_steps"]) or "reach the exit"
293
+ progression_str += f"Level {i+1}:\n- Theme: {t}\n- Basic Concept: {title} - {base_story}\n- Steps: {s}\n\n"
294
 
295
  prompt = f"""
296
  You are the Mission Architect for CodeCracker, a STEM education app for kids.
 
305
  STRICT RULES:
306
  1. The story MUST explain the DAA concept clearly to a student (age 10-16).
307
  2. Reference the exact mission steps for that level in its goal_description.
308
+ 3. CRITICAL: Read the "Basic Concept" provided for each level in the progression, and expand it into a UNIQUE, fully-fleshed out programming/logic problem in the `story` field for EACH level. Do NOT just repeat the basic concept.
309
  4. The `title` of each level should match its assigned Theme (e.g., "Bank Heist", "Space Station").
310
  5. CRITICAL: Generate a COMPLETELY UNIQUE `hint` for EVERY level. The hint MUST be different for Level 1, Level 2, etc., and must directly reference the specific theme/logic of that exact level! Do NOT repeat hints!
311