diff --git a/src/smarttools/ui_urwid.py b/src/smarttools/ui_urwid.py index 0408fd9..b289cc1 100644 --- a/src/smarttools/ui_urwid.py +++ b/src/smarttools/ui_urwid.py @@ -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."""