GeezerVison is showing github.com — fix(wand): add json-array generation type for array-contract fields · simstudioai/sim@d5ede2e
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/sim/app/api/wand/route.ts +7Lines changed: 7 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -339,6 +339,13 @@ export const POST = withRouteHandler(async (req: NextRequest) => { | 339 | 339 | '\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 }.' | 340 | 340 | } | 341 | 341 |
| | 342 | + // Separate from json-object: that reinforcement demands braces, which would | | 343 | + // fight a field whose contract is an array. | | 344 | + if (generationType === 'json-array') { | | 345 | + finalSystemPrompt += | | 346 | + '\n\nIMPORTANT: Return ONLY the raw JSON array. 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 ].' | | 347 | + } | | 348 | + | 342 | 349 | const messages: ChatMessage[] = [{ role: 'system', content: finalSystemPrompt }] | 343 | 350 |
| 344 | 351 | messages.push(...history.filter((msg) => msg.role !== 'system')) | |
Collapse file Copy file name to clipboardExpand all lines: apps/sim/blocks/blocks/snowflake.ts +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -431,7 +431,7 @@ export const SnowflakeBlock: BlockConfig<SnowflakeStatementResponse> = { | 431 | 431 | prompt: | 432 | 432 | 'Generate a non-empty JSON array of flat row objects. Every row must have the same keys. Use Load Data instead for bulk ingestion from staged files. Return ONLY the JSON array - no explanations, no extra text.', | 433 | 433 | placeholder: 'Describe the records to write...', | 434 | | - generationType: 'json-object', | | 434 | + generationType: 'json-array', | 435 | 435 | }, | 436 | 436 | }, | 437 | 437 | { | @@ -446,7 +446,7 @@ export const SnowflakeBlock: BlockConfig<SnowflakeStatementResponse> = { | 446 | 446 | prompt: | 447 | 447 | 'Generate a JSON array containing the row column names that uniquely match target records, for example ["tenant_id","id"]. Return ONLY the JSON array - no explanations, no extra text.', | 448 | 448 | placeholder: 'Describe the columns that identify a row...', | 449 | | - generationType: 'json-object', | | 449 | + generationType: 'json-array', | 450 | 450 | }, | 451 | 451 | }, | 452 | 452 | { | @@ -781,7 +781,7 @@ export const SnowflakeBlock: BlockConfig<SnowflakeStatementResponse> = { | 781 | 781 | prompt: | 782 | 782 | 'Generate an ordered JSON array of Snowflake procedure bindings. Each item must contain a supported Snowflake binding type and a string value, for example {"type":"TEXT","value":"daily"}. Return ONLY the JSON array - no explanations, no extra text.', | 783 | 783 | placeholder: 'Describe the procedure arguments in order...', | 784 | | - generationType: 'json-object', | | 784 | + generationType: 'json-array', | 785 | 785 | }, | 786 | 786 | }, | 787 | 787 | { | |
Collapse file Copy file name to clipboardExpand all lines: apps/sim/blocks/types.ts +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -181,6 +181,7 @@ export type GenerationType = | 181 | 181 | | 'typescript-function-body' | 182 | 182 | | 'json-schema' | 183 | 183 | | 'json-object' | | 184 | + | 'json-array' | 184 | 185 | | 'table-schema' | 185 | 186 | | 'system-prompt' | 186 | 187 | | 'custom-tool-schema' | |
Collapse file Copy file name to clipboardExpand all lines: apps/sim/lib/wand/strip-code-fences.test.ts +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -92,6 +92,7 @@ describe('shouldStripCodeFences', () => { | 92 | 92 | expect(shouldStripCodeFences('javascript-function-body')).toBe(true) | 93 | 93 | expect(shouldStripCodeFences('custom-tool-schema')).toBe(true) | 94 | 94 | expect(shouldStripCodeFences('json-object')).toBe(true) | | 95 | + expect(shouldStripCodeFences('json-array')).toBe(true) | 95 | 96 | expect(shouldStripCodeFences('cron-expression')).toBe(true) | 96 | 97 | }) | 97 | 98 |
| |
Collapse file Copy file name to clipboardExpand all lines: apps/sim/lib/wand/strip-code-fences.ts +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -19,6 +19,7 @@ const STRIPS_CODE_FENCES: Record<GenerationType, boolean> = { | 19 | 19 | 'typescript-function-body': true, | 20 | 20 | 'json-schema': true, | 21 | 21 | 'json-object': true, | | 22 | + 'json-array': true, | 22 | 23 | 'table-schema': true, | 23 | 24 | 'system-prompt': false, | 24 | 25 | 'custom-tool-schema': true, | |
|