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.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package builders
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
workflowregistry "agent-desk/internal/ai/workflow/registry"
|
||||
)
|
||||
|
||||
func TestBuildAIWorkflowNodeSpecsIncludesVariableContracts(t *testing.T) {
|
||||
specs := BuildAIWorkflowNodeSpecs(workflowregistry.DefaultRegistry().List())
|
||||
|
||||
var startFound bool
|
||||
var sendReplyFound bool
|
||||
for _, spec := range specs {
|
||||
switch spec.Type {
|
||||
case workflowregistry.NodeTypeStart:
|
||||
startFound = true
|
||||
if !hasResponseVariable(spec.OutputSchema, "userMessage") {
|
||||
t.Fatalf("expected start output userMessage, got %#v", spec.OutputSchema)
|
||||
}
|
||||
case workflowregistry.NodeTypeSendReply:
|
||||
sendReplyFound = true
|
||||
if !hasResponseVariable(spec.InputSchema, "replyText") {
|
||||
t.Fatalf("expected send_reply input replyText, got %#v", spec.InputSchema)
|
||||
}
|
||||
}
|
||||
}
|
||||
if !startFound || !sendReplyFound {
|
||||
t.Fatalf("expected start and send_reply specs in response")
|
||||
}
|
||||
}
|
||||
|
||||
func hasResponseVariable(items []workflowregistry.VariableSpec, name string) bool {
|
||||
for _, item := range items {
|
||||
if item.Name == name {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
Reference in New Issue
Block a user