mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
Modify executor to treat evaluator as an 'output' block instead of a 'router' block, looping logic still needs to be updated but forward path works
This commit is contained in:
@@ -8,6 +8,15 @@ interface Field {
|
||||
description?: string
|
||||
}
|
||||
|
||||
interface Metric {
|
||||
name: string
|
||||
description: string
|
||||
range: {
|
||||
min: number
|
||||
max: number
|
||||
}
|
||||
}
|
||||
|
||||
interface TagDropdownProps {
|
||||
visible: boolean
|
||||
onSelect: (newValue: string) => void
|
||||
@@ -68,7 +77,23 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
|
||||
const blockName = sourceBlock.name || sourceBlock.type
|
||||
const normalizedBlockName = blockName.replace(/\s+/g, '').toLowerCase()
|
||||
|
||||
// Check for response format first
|
||||
// First check for evaluator metrics
|
||||
if (sourceBlock.type === 'evaluator') {
|
||||
try {
|
||||
const metricsValue = sourceBlock.subBlocks?.metrics?.value as unknown as Metric[]
|
||||
if (Array.isArray(metricsValue)) {
|
||||
return {
|
||||
tags: metricsValue.map(
|
||||
(metric) => `${normalizedBlockName}.response.${metric.name.toLowerCase()}`
|
||||
),
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error parsing metrics:', e)
|
||||
}
|
||||
}
|
||||
|
||||
// Then check for response format
|
||||
try {
|
||||
const responseFormatValue = sourceBlock.subBlocks?.responseFormat?.value
|
||||
if (typeof responseFormatValue === 'string' && responseFormatValue) {
|
||||
@@ -87,7 +112,6 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
|
||||
|
||||
// Fall back to default outputs if no response format
|
||||
const outputPaths = getOutputPaths(sourceBlock.outputs)
|
||||
|
||||
return {
|
||||
tags: outputPaths.map((path) => `${normalizedBlockName}.${path}`),
|
||||
}
|
||||
@@ -117,6 +141,21 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
|
||||
console.error('Error parsing response format:', e)
|
||||
}
|
||||
|
||||
if (sourceBlock.type === 'evaluator') {
|
||||
try {
|
||||
const metricsValue = sourceBlock.subBlocks?.metrics?.value as unknown as Metric[]
|
||||
if (Array.isArray(metricsValue)) {
|
||||
return {
|
||||
tags: metricsValue.map(
|
||||
(metric) => `${normalizedBlockName}.response.${metric.name.toLowerCase()}`
|
||||
),
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error parsing metrics:', e)
|
||||
}
|
||||
}
|
||||
|
||||
// Fall back to default outputs if no response format
|
||||
const outputPaths = getOutputPaths(sourceBlock.outputs)
|
||||
return outputPaths.map((path) => `${normalizedBlockName}.${path}`)
|
||||
|
||||
Reference in New Issue
Block a user