Nipun Claude commited on
Commit
0d96016
·
1 Parent(s): ec6290f

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]>

Files changed (1) hide show
  1. src.py +11 -16
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 = """You are a helpful assistant that generates Python code for data analysis.
289
-
290
- Rules:
291
- 1. Always save your final result in a variable called 'answer'
292
- 2. If creating a plot, save it with plt.savefig() and store the filename in 'answer'
293
- 3. If returning text/numbers, store the result directly in 'answer'
294
- 4. Use descriptive variable names and add comments
295
- 5. Handle potential errors gracefully
296
- 6. For plots, use unique filenames: f"plot_name_{{uuid.uuid4().hex[:8]}}.png" (note proper bracket syntax)
297
- 7. Make plots professional with proper titles, labels, and styling
298
- 8. Use plt.tight_layout() before saving plots
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