fix: Add clearer example showing variable assignment pattern

The AI prompt now explicitly shows:
1. Assign Available Variables to standard Python variables first
2. Then use those variables in the code
3. Multi-line example with file writing pattern

This prevents the AI from trying to use {variable} directly in
expressions without proper assignment.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
rob 2025-12-07 05:15:12 -04:00
parent d09a0088ef
commit 35835f8254
1 changed files with 6 additions and 2 deletions

View File

@ -1833,9 +1833,13 @@ class SmartToolsUI:
vars_formatted = ', '.join(f'\"\"\"{{{v}}}\"\"\"' for v in vars_available)
default_ai_prompt = f"""Write inline Python code (NOT a function definition) according to my instruction.
The code runs directly with variable substitution. Any available variable used must be wrapped in triple quotes and curly braces like this: \"\"\"{{variable}}\"\"\". The triple quotes are needed since the substituted content may contain quotes/newlines.
The code runs directly with variable substitution. Assign any "Available Variables" used to a new standard variable first, then use that variable in the code. Use triple quotes and curly braces since the substituted content may contain quotes/newlines.
Example: my_var = \"\"\"{{response}}\"\"\"
Example:
my_var = \"\"\"{{response}}\"\"\"
filename = \"\"\"{{outputfile}}\"\"\"
with open(filename, 'w') as f:
f.write(my_var)
INSTRUCTION: [Describe what you want]