Skip to content

Commit 6f390c0

Browse files
waleedlatif1waleedlatif
andauthored
fix(evaluator): fix tag dropdown for evaluator block (#807)
* fix(evaluator): fix tag dropdown for evaluator block * lint --------- Co-authored-by: waleedlatif <waleedlatif@waleedlatifs-MacBook-Pro.local>
1 parent 27ef45f commit 6f390c0

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

apps/sim/components/ui/tag-dropdown.tsx

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,23 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
171171

172172
let blockTags: string[]
173173

174-
if (responseFormat) {
174+
// Special handling for evaluator blocks
175+
if (sourceBlock.type === 'evaluator') {
176+
// Get the evaluation metrics for the evaluator block
177+
const metricsValue = useSubBlockStore.getState().getValue(activeSourceBlockId, 'metrics')
178+
179+
if (metricsValue && Array.isArray(metricsValue) && metricsValue.length > 0) {
180+
// Use the metric names as the available outputs
181+
const validMetrics = metricsValue.filter((metric: any) => metric?.name)
182+
blockTags = validMetrics.map(
183+
(metric: any) => `${normalizedBlockName}.${metric.name.toLowerCase()}`
184+
)
185+
} else {
186+
// Fallback to default evaluator outputs if no metrics are defined
187+
const outputPaths = generateOutputPaths(blockConfig.outputs)
188+
blockTags = outputPaths.map((path) => `${normalizedBlockName}.${path}`)
189+
}
190+
} else if (responseFormat) {
175191
// Use custom schema properties if response format is specified
176192
const schemaFields = extractFieldsFromSchema(responseFormat)
177193
if (schemaFields.length > 0) {
@@ -430,7 +446,23 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
430446

431447
let blockTags: string[]
432448

433-
if (responseFormat) {
449+
// Special handling for evaluator blocks
450+
if (accessibleBlock.type === 'evaluator') {
451+
// Get the evaluation metrics for the evaluator block
452+
const metricsValue = useSubBlockStore.getState().getValue(accessibleBlockId, 'metrics')
453+
454+
if (metricsValue && Array.isArray(metricsValue) && metricsValue.length > 0) {
455+
// Use the metric names as the available outputs
456+
const validMetrics = metricsValue.filter((metric: any) => metric?.name)
457+
blockTags = validMetrics.map(
458+
(metric: any) => `${normalizedBlockName}.${metric.name.toLowerCase()}`
459+
)
460+
} else {
461+
// Fallback to default evaluator outputs if no metrics are defined
462+
const outputPaths = generateOutputPaths(blockConfig.outputs)
463+
blockTags = outputPaths.map((path) => `${normalizedBlockName}.${path}`)
464+
}
465+
} else if (responseFormat) {
434466
// Use custom schema properties if response format is specified
435467
const schemaFields = extractFieldsFromSchema(responseFormat)
436468
if (schemaFields.length > 0) {

0 commit comments

Comments
 (0)