Files
ai-agent/web/app/dashboard/ai-workflows/_components/variable-selector.tsx
T
mlogclub d1f39ae57e feat: Enhance AI Workflow with Variable Contracts and Input Mapping
- Added ConfigSchema, InputSchema, OutputSchema, and DefaultInputs to AIWorkflowNodeSpecResponse.
- Implemented BuildAIWorkflowNodeSpecs to include variable contracts for start and send_reply nodes.
- Introduced applyAutoInputMappings to automatically map inputs based on node connections.
- Enhanced validation to check for required input mappings in workflows.
- Updated workflow editor to support variable selection for node inputs.
- Translated node names and labels to Chinese for better localization.
- Added tests for variable mapping and validation logic.
2026-06-22 18:33:39 +08:00

36 lines
988 B
TypeScript

"use client"
import { OptionCombobox } from "@/components/option-combobox"
import type { WorkflowVariableRef, WorkflowVariableSelector } from "./workflow-utils"
export function VariableSelector({
value,
variables,
onChange,
}: {
value?: WorkflowVariableSelector
variables: WorkflowVariableRef[]
onChange: (value: WorkflowVariableSelector) => void
}) {
const options = variables.map((item) => ({
value: `${item.nodeId}.${item.field}`,
label: `${item.nodeName}.${item.field} · ${item.type}`,
}))
const selectedValue = value?.nodeId && value.field ? `${value.nodeId}.${value.field}` : ""
return (
<OptionCombobox
value={selectedValue}
options={options}
placeholder="选择变量"
searchPlaceholder="搜索变量"
emptyText="没有可用上游变量"
onChange={(nextValue) => {
const [nodeId, ...fieldParts] = nextValue.split(".")
onChange({ nodeId, field: fieldParts.join(".") })
}}
/>
)
}