mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
fix(starter): change starter block output format from .type.input to .input, tested
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
import { StartIcon } from '@/components/icons'
|
||||
import { ToolResponse } from '@/tools/types'
|
||||
import { BlockConfig } from '../types'
|
||||
|
||||
export const StarterBlock: BlockConfig = {
|
||||
interface StarterBlockOutput extends ToolResponse {
|
||||
output: {
|
||||
input: any
|
||||
}
|
||||
}
|
||||
|
||||
export const StarterBlock: BlockConfig<StarterBlockOutput> = {
|
||||
type: 'starter',
|
||||
name: 'Starter',
|
||||
description: 'Start workflow',
|
||||
|
||||
@@ -57,18 +57,24 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
|
||||
// Get source block and compute tags
|
||||
const { tags } = useMemo(() => {
|
||||
// Helper function to get output paths
|
||||
const getOutputPaths = (obj: any, prefix = ''): string[] => {
|
||||
const getOutputPaths = (obj: any, prefix = '', isStarterBlock = false): string[] => {
|
||||
if (typeof obj !== 'object' || obj === null) {
|
||||
return prefix ? [prefix] : []
|
||||
}
|
||||
|
||||
// Special handling for starter block.
|
||||
// TODO: In the future, we will support response formats and required input types. For now, we just take the input altogether.
|
||||
if (isStarterBlock && prefix === 'response') {
|
||||
return ['response.input']
|
||||
}
|
||||
|
||||
if ('type' in obj && typeof obj.type === 'string') {
|
||||
return [prefix]
|
||||
}
|
||||
|
||||
return Object.entries(obj).flatMap(([key, value]) => {
|
||||
const newPrefix = prefix ? `${prefix}.${key}` : key
|
||||
return getOutputPaths(value, newPrefix)
|
||||
return getOutputPaths(value, newPrefix, isStarterBlock)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -118,7 +124,7 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
|
||||
}
|
||||
|
||||
// Fall back to default outputs if no response format
|
||||
const outputPaths = getOutputPaths(sourceBlock.outputs)
|
||||
const outputPaths = getOutputPaths(sourceBlock.outputs, '', sourceBlock.type === 'starter')
|
||||
return {
|
||||
tags: outputPaths.map((path) => `${normalizedBlockName}.${path}`),
|
||||
}
|
||||
@@ -167,7 +173,7 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
|
||||
}
|
||||
|
||||
// Fall back to default outputs if no response format
|
||||
const outputPaths = getOutputPaths(sourceBlock.outputs)
|
||||
const outputPaths = getOutputPaths(sourceBlock.outputs, '', sourceBlock.type === 'starter')
|
||||
return outputPaths.map((path) => `${normalizedBlockName}.${path}`)
|
||||
})
|
||||
|
||||
|
||||
+1
-3
@@ -217,9 +217,7 @@ export class Executor {
|
||||
// Initialize the starter block with the workflow input
|
||||
const starterOutput = {
|
||||
response: {
|
||||
type: {
|
||||
input: this.workflowInput,
|
||||
},
|
||||
input: this.workflowInput,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user