MCPcopy Index your code
hub / github.com/simstudioai/sim / generateResponseFormat

Function generateResponseFormat

apps/sim/blocks/blocks/evaluator.ts:114–148  ·  view source on GitHub ↗
(metrics: Metric[])

Source from the content-addressed store, hash-verified

112
113// Simplified response format generator that matches the agent block schema structure
114const generateResponseFormat = (metrics: Metric[]) => {
115 // Filter out invalid/incomplete metrics first
116 const validMetrics = metrics.filter((m) => m?.name)
117
118 // Create properties for each metric
119 const properties: Record<string, any> = {}
120
121 // Add each metric as a property
122 validMetrics.forEach((metric) => {
123 // We've already filtered, but double-check just in case
124 if (metric?.name) {
125 properties[metric.name.toLowerCase()] = {
126 type: 'number',
127 description: `${metric.description || ''} (Score between ${metric.range?.min ?? 0}-${metric.range?.max ?? 'N/A'})`, // Safely access range
128 }
129 } else {
130 logger.warn('Skipping invalid metric during response format property generation:', metric)
131 }
132 })
133
134 // Return a proper JSON Schema format
135 return {
136 name: 'evaluation_response',
137 schema: {
138 type: 'object',
139 properties,
140 // Use only valid, lowercase metric names for the required array
141 required: validMetrics
142 .filter((metric) => metric?.name)
143 .map((metric) => metric.name.toLowerCase()),
144 additionalProperties: false,
145 },
146 strict: true,
147 }
148}
149
150export const EvaluatorBlock: BlockConfig<EvaluatorResponse> = {
151 type: 'evaluator',

Callers 1

evaluator.tsFile · 0.85

Calls 1

warnMethod · 0.65

Tested by

no test coverage detected