fix: Show available variables in triple-quote format in AI prompt

The AI follows the pattern better when the available variables are
shown in the exact format they should be used:
  """{input}""", """{response}""", etc.

This helps the AI generate code that properly uses triple quotes
for variable substitution.

🤖 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 04:58:37 -04:00
parent bcda4150a7
commit d09a0088ef
1 changed files with 6 additions and 5 deletions

View File

@ -1829,12 +1829,13 @@ class SmartToolsUI:
ai_provider_select_btn = Button3DCompact("", on_press=show_ai_provider_dropdown)
# Default prompt template for AI code generation/adjustment
# Show variables in triple-quote format so the AI follows the pattern
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. To use an available variable:
- Wrap the variable name in curly braces: {{variable}}
- Use triple quotes since the substituted content may contain quotes/newlines
- Example: my_var = \"\"\"{{response}}\"\"\"
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.
Example: my_var = \"\"\"{{response}}\"\"\"
INSTRUCTION: [Describe what you want]
@ -1843,7 +1844,7 @@ CURRENT CODE:
{{code}}
```
AVAILABLE VARIABLES: {', '.join(vars_available)}
AVAILABLE VARIABLES: {vars_formatted}
IMPORTANT: Return ONLY executable inline code. Do NOT wrap in a function.
No explanations, no markdown fencing, just the code."""