This commit is contained in:
Siddharth Ganesan
2026-03-02 15:12:59 -08:00
parent 1d48289c53
commit e9550c624d
3 changed files with 100 additions and 92 deletions

View File

@@ -2,7 +2,7 @@ import { createLogger } from '@sim/logger'
import { AgentIcon } from '@/components/icons'
import type { BlockConfig } from '@/blocks/types'
import { AuthMode } from '@/blocks/types'
import { getApiKeyCondition, getModelOptions } from '@/blocks/utils'
import { getApiKeyCondition, getModelOptions, RESPONSE_FORMAT_WAND_CONFIG } from '@/blocks/utils'
import {
getBaseModelProviders,
getMaxTemperature,
@@ -552,97 +552,7 @@ Return ONLY the JSON array.`,
value: MODELS_WITH_DEEP_RESEARCH,
not: true,
},
wandConfig: {
enabled: true,
maintainHistory: true,
prompt: `You are an expert programmer specializing in creating JSON schemas according to a specific format.
Generate ONLY the JSON schema based on the user's request.
The output MUST be a single, valid JSON object, starting with { and ending with }.
The JSON object MUST have the following top-level properties: 'name' (string), 'description' (string), 'strict' (boolean, usually true), and 'schema' (object).
The 'schema' object must define the structure and MUST contain 'type': 'object', 'properties': {...}, 'additionalProperties': false, and 'required': [...].
Inside 'properties', use standard JSON Schema properties (type, description, enum, items for arrays, etc.).
Current schema: {context}
Do not include any explanations, markdown formatting, or other text outside the JSON object.
Valid Schema Examples:
Example 1:
{
"name": "reddit_post",
"description": "Fetches the reddit posts in the given subreddit",
"strict": true,
"schema": {
"type": "object",
"properties": {
"title": {
"type": "string",
"description": "The title of the post"
},
"content": {
"type": "string",
"description": "The content of the post"
}
},
"additionalProperties": false,
"required": [ "title", "content" ]
}
}
Example 2:
{
"name": "get_weather",
"description": "Fetches the current weather for a specific location.",
"strict": true,
"schema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g., San Francisco, CA"
},
"unit": {
"type": "string",
"description": "Temperature unit",
"enum": ["celsius", "fahrenheit"]
}
},
"additionalProperties": false,
"required": ["location", "unit"]
}
}
Example 3 (Array Input):
{
"name": "process_items",
"description": "Processes a list of items with specific IDs.",
"strict": true,
"schema": {
"type": "object",
"properties": {
"item_ids": {
"type": "array",
"description": "A list of unique item identifiers to process.",
"items": {
"type": "string",
"description": "An item ID"
}
},
"processing_mode": {
"type": "string",
"description": "The mode for processing",
"enum": ["fast", "thorough"]
}
},
"additionalProperties": false,
"required": ["item_ids", "processing_mode"]
}
}
`,
placeholder: 'Describe the JSON schema structure you need...',
generationType: 'json-schema',
},
wandConfig: RESPONSE_FORMAT_WAND_CONFIG,
},
{
id: 'previousInteractionId',

View File

@@ -1,4 +1,5 @@
import type { BlockConfig } from '@/blocks/types'
import { RESPONSE_FORMAT_WAND_CONFIG } from '@/blocks/utils'
import { Blimp } from '@/components/emcn'
import type { ToolResponse } from '@/tools/types'
@@ -42,6 +43,7 @@ export const MothershipBlock: BlockConfig<MothershipResponse> = {
placeholder: 'Enter JSON schema...',
language: 'json',
mode: 'advanced',
wandConfig: RESPONSE_FORMAT_WAND_CONFIG,
},
{
id: 'memoryType',

View File

@@ -364,3 +364,99 @@ export function normalizeFileInput(
return files
}
/**
* Shared wand configuration for the Response Format code subblock.
* Used by Agent and Mothership blocks.
*/
export const RESPONSE_FORMAT_WAND_CONFIG = {
enabled: true,
maintainHistory: true,
prompt: `You are an expert programmer specializing in creating JSON schemas according to a specific format.
Generate ONLY the JSON schema based on the user's request.
The output MUST be a single, valid JSON object, starting with { and ending with }.
The JSON object MUST have the following top-level properties: 'name' (string), 'description' (string), 'strict' (boolean, usually true), and 'schema' (object).
The 'schema' object must define the structure and MUST contain 'type': 'object', 'properties': {...}, 'additionalProperties': false, and 'required': [...].
Inside 'properties', use standard JSON Schema properties (type, description, enum, items for arrays, etc.).
Current schema: {context}
Do not include any explanations, markdown formatting, or other text outside the JSON object.
Valid Schema Examples:
Example 1:
{
"name": "reddit_post",
"description": "Fetches the reddit posts in the given subreddit",
"strict": true,
"schema": {
"type": "object",
"properties": {
"title": {
"type": "string",
"description": "The title of the post"
},
"content": {
"type": "string",
"description": "The content of the post"
}
},
"additionalProperties": false,
"required": [ "title", "content" ]
}
}
Example 2:
{
"name": "get_weather",
"description": "Fetches the current weather for a specific location.",
"strict": true,
"schema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g., San Francisco, CA"
},
"unit": {
"type": "string",
"description": "Temperature unit",
"enum": ["celsius", "fahrenheit"]
}
},
"additionalProperties": false,
"required": ["location", "unit"]
}
}
Example 3 (Array Input):
{
"name": "process_items",
"description": "Processes a list of items with specific IDs.",
"strict": true,
"schema": {
"type": "object",
"properties": {
"item_ids": {
"type": "array",
"description": "A list of unique item identifiers to process.",
"items": {
"type": "string",
"description": "An item ID"
}
},
"processing_mode": {
"type": "string",
"description": "The mode for processing",
"enum": ["fast", "thorough"]
}
},
"additionalProperties": false,
"required": ["item_ids", "processing_mode"]
}
}
`,
placeholder: 'Describe the JSON schema structure you need...',
generationType: 'json-schema' as const,
}