Compare commits
6 Commits
541d49b7f9
...
7e9bd0d533
| Author | SHA1 | Date |
|---|---|---|
|
|
7e9bd0d533 | |
|
|
35835f8254 | |
|
|
d09a0088ef | |
|
|
bcda4150a7 | |
|
|
0c966a8adb | |
|
|
9c6b682c73 |
|
|
@ -67,12 +67,15 @@ def execute_code_step(step: CodeStep, variables: dict) -> tuple[dict, bool]:
|
||||||
Returns:
|
Returns:
|
||||||
Tuple of (output_vars_dict, success)
|
Tuple of (output_vars_dict, success)
|
||||||
"""
|
"""
|
||||||
|
# Substitute variables in code (like {outputfile} -> actual value)
|
||||||
|
code = substitute_variables(step.code, variables)
|
||||||
|
|
||||||
# Create execution environment with variables
|
# Create execution environment with variables
|
||||||
local_vars = dict(variables)
|
local_vars = dict(variables)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Execute the code
|
# Execute the code with substituted variables
|
||||||
exec(step.code, {"__builtins__": __builtins__}, local_vars)
|
exec(code, {"__builtins__": __builtins__}, local_vars)
|
||||||
|
|
||||||
# Support comma-separated output vars (e.g., "a, b, c")
|
# Support comma-separated output vars (e.g., "a, b, c")
|
||||||
output_vars = [v.strip() for v in step.output_var.split(',')]
|
output_vars = [v.strip() for v in step.output_var.split(',')]
|
||||||
|
|
|
||||||
|
|
@ -1829,7 +1829,14 @@ class SmartToolsUI:
|
||||||
ai_provider_select_btn = Button3DCompact("▼", on_press=show_ai_provider_dropdown)
|
ai_provider_select_btn = Button3DCompact("▼", on_press=show_ai_provider_dropdown)
|
||||||
|
|
||||||
# Default prompt template for AI code generation/adjustment
|
# Default prompt template for AI code generation/adjustment
|
||||||
default_ai_prompt = f"""Modify or generate Python code according to my instruction below.
|
# 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. 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 = \"\"\"{{variable}}\"\"\"
|
||||||
|
|
||||||
INSTRUCTION: [Describe what you want]
|
INSTRUCTION: [Describe what you want]
|
||||||
|
|
||||||
|
|
@ -1838,9 +1845,10 @@ CURRENT CODE:
|
||||||
{{code}}
|
{{code}}
|
||||||
```
|
```
|
||||||
|
|
||||||
AVAILABLE VARIABLES: {', '.join(vars_available)}
|
AVAILABLE VARIABLES: {vars_formatted}
|
||||||
|
|
||||||
Return ONLY the Python code, no explanations or markdown fencing."""
|
IMPORTANT: Return ONLY executable inline code. Do NOT wrap in a function.
|
||||||
|
No explanations, no markdown fencing, just the code."""
|
||||||
|
|
||||||
# Multiline editable prompt for AI with DOS-style scrollbar
|
# Multiline editable prompt for AI with DOS-style scrollbar
|
||||||
ai_prompt_edit = TabPassEdit(edit_text=default_ai_prompt, multiline=True)
|
ai_prompt_edit = TabPassEdit(edit_text=default_ai_prompt, multiline=True)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue