Skip to content

Commit e9550c6

Browse files
committed
Wand
1 parent 1d48289 commit e9550c6

3 files changed

Lines changed: 100 additions & 92 deletions

File tree

apps/sim/blocks/blocks/agent.ts

Lines changed: 2 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { createLogger } from '@sim/logger'
22
import { AgentIcon } from '@/components/icons'
33
import type { BlockConfig } from '@/blocks/types'
44
import { AuthMode } from '@/blocks/types'
5-
import { getApiKeyCondition, getModelOptions } from '@/blocks/utils'
5+
import { getApiKeyCondition, getModelOptions, RESPONSE_FORMAT_WAND_CONFIG } from '@/blocks/utils'
66
import {
77
getBaseModelProviders,
88
getMaxTemperature,
@@ -552,97 +552,7 @@ Return ONLY the JSON array.`,
552552
value: MODELS_WITH_DEEP_RESEARCH,
553553
not: true,
554554
},
555-
wandConfig: {
556-
enabled: true,
557-
maintainHistory: true,
558-
prompt: `You are an expert programmer specializing in creating JSON schemas according to a specific format.
559-
Generate ONLY the JSON schema based on the user's request.
560-
The output MUST be a single, valid JSON object, starting with { and ending with }.
561-
The JSON object MUST have the following top-level properties: 'name' (string), 'description' (string), 'strict' (boolean, usually true), and 'schema' (object).
562-
The 'schema' object must define the structure and MUST contain 'type': 'object', 'properties': {...}, 'additionalProperties': false, and 'required': [...].
563-
Inside 'properties', use standard JSON Schema properties (type, description, enum, items for arrays, etc.).
564-
565-
Current schema: {context}
566-
567-
Do not include any explanations, markdown formatting, or other text outside the JSON object.
568-
569-
Valid Schema Examples:
570-
571-
Example 1:
572-
{
573-
"name": "reddit_post",
574-
"description": "Fetches the reddit posts in the given subreddit",
575-
"strict": true,
576-
"schema": {
577-
"type": "object",
578-
"properties": {
579-
"title": {
580-
"type": "string",
581-
"description": "The title of the post"
582-
},
583-
"content": {
584-
"type": "string",
585-
"description": "The content of the post"
586-
}
587-
},
588-
"additionalProperties": false,
589-
"required": [ "title", "content" ]
590-
}
591-
}
592-
593-
Example 2:
594-
{
595-
"name": "get_weather",
596-
"description": "Fetches the current weather for a specific location.",
597-
"strict": true,
598-
"schema": {
599-
"type": "object",
600-
"properties": {
601-
"location": {
602-
"type": "string",
603-
"description": "The city and state, e.g., San Francisco, CA"
604-
},
605-
"unit": {
606-
"type": "string",
607-
"description": "Temperature unit",
608-
"enum": ["celsius", "fahrenheit"]
609-
}
610-
},
611-
"additionalProperties": false,
612-
"required": ["location", "unit"]
613-
}
614-
}
615-
616-
Example 3 (Array Input):
617-
{
618-
"name": "process_items",
619-
"description": "Processes a list of items with specific IDs.",
620-
"strict": true,
621-
"schema": {
622-
"type": "object",
623-
"properties": {
624-
"item_ids": {
625-
"type": "array",
626-
"description": "A list of unique item identifiers to process.",
627-
"items": {
628-
"type": "string",
629-
"description": "An item ID"
630-
}
631-
},
632-
"processing_mode": {
633-
"type": "string",
634-
"description": "The mode for processing",
635-
"enum": ["fast", "thorough"]
636-
}
637-
},
638-
"additionalProperties": false,
639-
"required": ["item_ids", "processing_mode"]
640-
}
641-
}
642-
`,
643-
placeholder: 'Describe the JSON schema structure you need...',
644-
generationType: 'json-schema',
645-
},
555+
wandConfig: RESPONSE_FORMAT_WAND_CONFIG,
646556
},
647557
{
648558
id: 'previousInteractionId',

apps/sim/blocks/blocks/mothership.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { BlockConfig } from '@/blocks/types'
2+
import { RESPONSE_FORMAT_WAND_CONFIG } from '@/blocks/utils'
23
import { Blimp } from '@/components/emcn'
34
import type { ToolResponse } from '@/tools/types'
45

@@ -42,6 +43,7 @@ export const MothershipBlock: BlockConfig<MothershipResponse> = {
4243
placeholder: 'Enter JSON schema...',
4344
language: 'json',
4445
mode: 'advanced',
46+
wandConfig: RESPONSE_FORMAT_WAND_CONFIG,
4547
},
4648
{
4749
id: 'memoryType',

apps/sim/blocks/utils.ts

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,3 +364,99 @@ export function normalizeFileInput(
364364

365365
return files
366366
}
367+
368+
/**
369+
* Shared wand configuration for the Response Format code subblock.
370+
* Used by Agent and Mothership blocks.
371+
*/
372+
export const RESPONSE_FORMAT_WAND_CONFIG = {
373+
enabled: true,
374+
maintainHistory: true,
375+
prompt: `You are an expert programmer specializing in creating JSON schemas according to a specific format.
376+
Generate ONLY the JSON schema based on the user's request.
377+
The output MUST be a single, valid JSON object, starting with { and ending with }.
378+
The JSON object MUST have the following top-level properties: 'name' (string), 'description' (string), 'strict' (boolean, usually true), and 'schema' (object).
379+
The 'schema' object must define the structure and MUST contain 'type': 'object', 'properties': {...}, 'additionalProperties': false, and 'required': [...].
380+
Inside 'properties', use standard JSON Schema properties (type, description, enum, items for arrays, etc.).
381+
382+
Current schema: {context}
383+
384+
Do not include any explanations, markdown formatting, or other text outside the JSON object.
385+
386+
Valid Schema Examples:
387+
388+
Example 1:
389+
{
390+
"name": "reddit_post",
391+
"description": "Fetches the reddit posts in the given subreddit",
392+
"strict": true,
393+
"schema": {
394+
"type": "object",
395+
"properties": {
396+
"title": {
397+
"type": "string",
398+
"description": "The title of the post"
399+
},
400+
"content": {
401+
"type": "string",
402+
"description": "The content of the post"
403+
}
404+
},
405+
"additionalProperties": false,
406+
"required": [ "title", "content" ]
407+
}
408+
}
409+
410+
Example 2:
411+
{
412+
"name": "get_weather",
413+
"description": "Fetches the current weather for a specific location.",
414+
"strict": true,
415+
"schema": {
416+
"type": "object",
417+
"properties": {
418+
"location": {
419+
"type": "string",
420+
"description": "The city and state, e.g., San Francisco, CA"
421+
},
422+
"unit": {
423+
"type": "string",
424+
"description": "Temperature unit",
425+
"enum": ["celsius", "fahrenheit"]
426+
}
427+
},
428+
"additionalProperties": false,
429+
"required": ["location", "unit"]
430+
}
431+
}
432+
433+
Example 3 (Array Input):
434+
{
435+
"name": "process_items",
436+
"description": "Processes a list of items with specific IDs.",
437+
"strict": true,
438+
"schema": {
439+
"type": "object",
440+
"properties": {
441+
"item_ids": {
442+
"type": "array",
443+
"description": "A list of unique item identifiers to process.",
444+
"items": {
445+
"type": "string",
446+
"description": "An item ID"
447+
}
448+
},
449+
"processing_mode": {
450+
"type": "string",
451+
"description": "The mode for processing",
452+
"enum": ["fast", "thorough"]
453+
}
454+
},
455+
"additionalProperties": false,
456+
"required": ["item_ids", "processing_mode"]
457+
}
458+
}
459+
`,
460+
placeholder: 'Describe the JSON schema structure you need...',
461+
generationType: 'json-schema' as const,
462+
}

0 commit comments

Comments
 (0)