Spaces:
Running
Running
Update backend/main.py
Browse files- backend/main.py +6 -6
backend/main.py
CHANGED
|
@@ -118,22 +118,22 @@ def evaluate_player():
|
|
| 118 |
def generate_hint():
|
| 119 |
"""
|
| 120 |
Generates a context-aware hint.
|
| 121 |
-
Expected JSON: { "
|
| 122 |
"""
|
| 123 |
data = request.json or {}
|
| 124 |
-
|
| 125 |
-
|
| 126 |
|
| 127 |
try:
|
| 128 |
hint = hint_agent.generate_hint(
|
|
|
|
| 129 |
level_context=data.get('level_context', {}),
|
| 130 |
-
|
| 131 |
-
error_message=data.get('error')
|
| 132 |
)
|
| 133 |
return jsonify({"hint": hint})
|
| 134 |
except Exception as e:
|
| 135 |
print(f"CRITICAL ERROR /api/hint/generate: {e}")
|
| 136 |
-
return jsonify({"hint": "Try checking your
|
| 137 |
|
| 138 |
if __name__ == '__main__':
|
| 139 |
port = int(os.environ.get('PORT', 5000))
|
|
|
|
| 118 |
def generate_hint():
|
| 119 |
"""
|
| 120 |
Generates a context-aware hint.
|
| 121 |
+
Expected JSON: { "mode": "maze|blockly", "level_context": {...}, "user_state": {...} }
|
| 122 |
"""
|
| 123 |
data = request.json or {}
|
| 124 |
+
mode = data.get('mode', 'blockly')
|
| 125 |
+
user_state = data.get('user_state', {})
|
| 126 |
|
| 127 |
try:
|
| 128 |
hint = hint_agent.generate_hint(
|
| 129 |
+
mode=mode,
|
| 130 |
level_context=data.get('level_context', {}),
|
| 131 |
+
user_state=user_state
|
|
|
|
| 132 |
)
|
| 133 |
return jsonify({"hint": hint})
|
| 134 |
except Exception as e:
|
| 135 |
print(f"CRITICAL ERROR /api/hint/generate: {e}")
|
| 136 |
+
return jsonify({"hint": "Try checking your logic step-by-step."})
|
| 137 |
|
| 138 |
if __name__ == '__main__':
|
| 139 |
port = int(os.environ.get('PORT', 5000))
|