You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3742f1b
Browse filesBrowse the repository at this point in the historyBrowse files
fix(wand): stop markdown code fences landing in generated code
Strip fences from wand output for raw-value generation types, reset the
conversation history when a Function block switches language, and give the
Python prompt the worked example the JavaScript one already had.
'\n\nIMPORTANT: Return ONLY the raw cron expression (e.g., "0 9 * * 1-5"). Do NOT wrap it in markdown code blocks, backticks, or quotes. Do NOT include any explanation or text before or after the expression.'
329
329
}
330
330
331
+
// Both the JavaScript and Python function-body prompts share this type, so
332
+
// the reinforcement stays language-neutral.
333
+
if(generationType==='javascript-function-body'){
334
+
finalSystemPrompt+=
335
+
'\n\nIMPORTANT: Return ONLY the raw function body. Do NOT wrap it in markdown code blocks (no ```javascript, no ```python, no ```). Do NOT include any explanation before or after the code.'
336
+
}
337
+
331
338
if(generationType==='json-object'){
332
339
finalSystemPrompt+=
333
340
'\n\nIMPORTANT: Return ONLY the raw JSON object. Do NOT wrap it in markdown code blocks (no ```json or ```). Do NOT include any explanation or text before or after the JSON. The response must start with { and end with }.'
Copy file name to clipboardExpand all lines: apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/code/code.tsx
+28-2Lines changed: 28 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -67,9 +67,32 @@ IMPORTANT FORMATTING RULES:
67
67
1. Reference Environment Variables: Use the exact syntax {{VARIABLE_NAME}}. Do NOT wrap it in quotes.
68
68
2. Reference Input Parameters/Workflow Variables: Use the exact syntax <variable_name>. Do NOT wrap it in quotes.
69
69
3. Function Body ONLY: Do NOT include the function signature (e.g., 'def my_func(...)') or surrounding braces. Return the final value with 'return'.
70
-
4. Imports: You may add imports as needed (standard library or pip-installed packages) without comments.
70
+
4. Imports: The Python standard library is always available. Third-party packages are available ONLY when the block has a sandbox selected — the sandbox's package list is appended below when one is. Never import a package that is not on that list.
71
71
5. No Markdown: Do NOT include backticks, code fences, or any markdown.
72
-
6. Clarity: Write clean, readable Python code.`
72
+
6. Clarity: Write clean, readable Python code.
73
+
7. No Explanations: Output the raw Python code only — no prose before or after it.
74
+
75
+
Example Scenario:
76
+
User Prompt: "Fetch user data from an API. Use the User ID passed in as 'userId' and an API Key stored as the 'SERVICE_API_KEY' environment variable."
77
+
78
+
Generated Code:
79
+
import json
80
+
import urllib.error
81
+
import urllib.request
82
+
83
+
user_id = <userId> # Correct: accessing an input parameter without quotes
84
+
api_key = {{SERVICE_API_KEY}} # Correct: accessing an environment variable without quotes
0 commit comments