From 35835f825416091f277d24a1b7017316dcfa4332 Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 7 Dec 2025 05:15:12 -0400 Subject: [PATCH] fix: Add clearer example showing variable assignment pattern MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/smarttools/ui_urwid.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/smarttools/ui_urwid.py b/src/smarttools/ui_urwid.py index b289cc1..3ef00c7 100644 --- a/src/smarttools/ui_urwid.py +++ b/src/smarttools/ui_urwid.py @@ -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]