Skip to content

Commit 12400d5

Browse files
committed
add evaluator metrics too
1 parent 0bb09e7 commit 12400d5

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

apps/sim/executor/utils/block-data.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,24 @@ function getInputFormatFields(block: SerializedBlock): OutputSchema {
5555
return schema
5656
}
5757

58+
function getEvaluatorMetricsSchema(block: SerializedBlock): OutputSchema | undefined {
59+
if (block.metadata?.id !== 'evaluator') return undefined
60+
61+
const metrics = block.config?.params?.metrics
62+
if (!Array.isArray(metrics) || metrics.length === 0) return undefined
63+
64+
const validMetrics = metrics.filter(
65+
(m: { name?: string }) => m?.name && typeof m.name === 'string'
66+
)
67+
if (validMetrics.length === 0) return undefined
68+
69+
const schema: OutputSchema = { ...(block.outputs as OutputSchema) }
70+
for (const metric of validMetrics) {
71+
schema[metric.name.toLowerCase()] = { type: 'number' }
72+
}
73+
return schema
74+
}
75+
5876
function getResponseFormatSchema(block: SerializedBlock): OutputSchema | undefined {
5977
const responseFormatValue = block.config?.params?.responseFormat
6078
if (!responseFormatValue) return undefined
@@ -94,6 +112,11 @@ export function getBlockSchema(
94112
}
95113
}
96114

115+
const evaluatorSchema = getEvaluatorMetricsSchema(block)
116+
if (evaluatorSchema) {
117+
return evaluatorSchema
118+
}
119+
97120
const responseFormatSchema = getResponseFormatSchema(block)
98121
if (responseFormatSchema) {
99122
return responseFormatSchema

0 commit comments

Comments
 (0)