File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff 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+
5876function 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
You can’t perform that action at this time.
0 commit comments