Fix broken system prompt causing thinking blocks in generated code
Browse files- Simplify system prompt to prevent AI model confusion
- Remove complex numbered rules that were causing thinking blocks to appear in code
- Add explicit instruction to only generate code, no explanations
- Keep essential requirements for answer variable and filename syntax
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
src.py
CHANGED
|
@@ -285,22 +285,17 @@ df["Timestamp"] = pd.to_datetime(df["Timestamp"])
|
|
| 285 |
# If returning text/numbers, store the result directly in 'answer'
|
| 286 |
```"""
|
| 287 |
|
| 288 |
-
system_prompt = """
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
9. For line plots, use linewidth=2.5 and markersize=8 for better visibility
|
| 300 |
-
10. Add proper axis labels with units (e.g., 'PM2.5 (µg/m³)')
|
| 301 |
-
11. For high-resolution plots, use bbox_inches='tight', dpi=400 in plt.savefig()
|
| 302 |
-
12. IMPORTANT: Use double curly braces {{}} in f-strings within the template to avoid syntax errors
|
| 303 |
-
"""
|
| 304 |
|
| 305 |
query = f"""{system_prompt}
|
| 306 |
|
|
|
|
| 285 |
# If returning text/numbers, store the result directly in 'answer'
|
| 286 |
```"""
|
| 287 |
|
| 288 |
+
system_prompt = """Generate Python code to answer the user's question about air quality data.
|
| 289 |
+
|
| 290 |
+
IMPORTANT: Only generate Python code - no explanations, no thinking, just clean code.
|
| 291 |
+
|
| 292 |
+
Requirements:
|
| 293 |
+
- Save final result in variable called 'answer'
|
| 294 |
+
- For plots: save with unique filename using uuid and store filename in 'answer'
|
| 295 |
+
- For text answers: store text directly in 'answer'
|
| 296 |
+
- Use proper syntax: f"filename_{{uuid.uuid4().hex[:8]}}.png"
|
| 297 |
+
- Add plt.tight_layout() before saving plots
|
| 298 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 299 |
|
| 300 |
query = f"""{system_prompt}
|
| 301 |
|