Compare commits
No commits in common. "7e9bd0d5333182d1f88a1b9da6352accf30a546f" and "541d49b7f902d259cc069aac8d702d6003788983" have entirely different histories.
7e9bd0d533
...
541d49b7f9
|
|
@ -67,15 +67,12 @@ 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 with substituted variables
|
# Execute the code
|
||||||
exec(code, {"__builtins__": __builtins__}, local_vars)
|
exec(step.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,14 +1829,7 @@ 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
|
||||||
# Show variables in triple-quote format so the AI follows the pattern
|
default_ai_prompt = f"""Modify or generate Python code according to my instruction below.
|
||||||
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]
|
||||||
|
|
||||||
|
|
@ -1845,10 +1838,9 @@ CURRENT CODE:
|
||||||
{{code}}
|
{{code}}
|
||||||
```
|
```
|
||||||
|
|
||||||
AVAILABLE VARIABLES: {vars_formatted}
|
AVAILABLE VARIABLES: {', '.join(vars_available)}
|
||||||
|
|
||||||
IMPORTANT: Return ONLY executable inline code. Do NOT wrap in a function.
|
Return ONLY the Python code, no explanations or markdown fencing."""
|
||||||
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