Files
ChatGPT-Discord-Bot/docs/QUICK_REFERENCE_MODEL_INSTRUCTIONS.md
cauvang32 9c180bdd89 Refactor OpenAI utilities and remove Python executor
- Removed the `analyze_data_file` function from tool definitions to streamline functionality.
- Enhanced the `execute_python_code` function description to clarify auto-installation of packages and file handling.
- Deleted the `python_executor.py` module to simplify the codebase and improve maintainability.
- Introduced a new `token_counter.py` module for efficient token counting for OpenAI API requests, including support for Discord image links and cost estimation.
2025-10-02 21:49:48 +07:00

3.2 KiB

Quick Reference - Model Knows Code Interpreter Now! 🎉

What Was Done

Updated system prompts and tool descriptions so the AI model understands:

  1. Packages auto-install when imported
  2. All file types (80+) are captured
  3. Files persist for 48 hours
  4. How to use code interpreter properly

📝 Files Changed

File Change Status
src/config/config.py Updated NORMAL_CHAT_PROMPT with code interpreter instructions
src/utils/openai_utils.py Updated execute_python_code tool description
src/config/code_interpreter_prompts.py Created comprehensive prompt library NEW
docs/MODEL_INSTRUCTIONS_CODE_INTERPRETER.md Created model usage guide NEW
docs/AI_MODEL_INSTRUCTIONS_UPDATE.md Created update summary NEW

🎯 Key Messages to Model

Package Auto-Install

✅ Just import packages - they auto-install!
❌ Don't check if packages are installed
❌ Don't use install_packages parameter

File Creation

✅ Create files (CSV, PNG, JSON, TXT, etc.)
✅ All 80+ formats are captured
✅ Files are sent to user automatically
❌ Don't print long output

File Loading

✅ Use load_file('file_id')
❌ Don't use pd.read_csv('/path')

💡 Model Behavior Change

BEFORE:

# Model writes:
try:
    import seaborn
except ImportError:
    print("Please install seaborn")
    
# Or:
print(df.to_string())  # Long output

AFTER:

# Model writes:
import seaborn as sns  # Auto-installs!

# And:
df.to_csv('data.csv')  # Creates file for user

🔧 System Prompt Integration

Location 1: Main Chat Prompt

src/config/config.pyNORMAL_CHAT_PROMPT

  • Loaded automatically for every conversation
  • Includes code interpreter section
  • Lists approved packages
  • Shows best practices

Location 2: Tool Description

src/utils/openai_utils.pyexecute_python_code

  • Shown when model considers using tool
  • Emphasizes AUTO-INSTALL
  • Includes usage examples
  • Marks deprecated parameters

Location 3: Additional Prompts (Optional)

src/config/code_interpreter_prompts.py

  • Can be imported for extra context
  • Comprehensive instructions
  • Available when needed

📊 Testing Scenarios

Test 1: Package Import

User: "Create a heatmap with seaborn"
Expected: Model imports seaborn, auto-installs, creates heatmap

Test 2: File Creation

User: "Export data as CSV and JSON"
Expected: Model creates both files, user receives both

Test 3: Multiple Outputs

User: "Analyze data and create report"
Expected: CSV + PNG + TXT files generated


🎉 Summary

The AI model now knows:

  • 📦 Packages auto-install (62+ libraries)
  • 📁 All file types are captured (80+ formats)
  • Files persist for 48 hours
  • 🔧 How to properly use code interpreter

Result: Better code, happier users, fewer errors! 🚀


🚀 Ready to Use

All changes compiled successfully. The bot is ready to use the code interpreter with full knowledge of its capabilities!

Next: Test with real users and monitor behavior.