mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-16 12:47:19 +08:00
fix(go-agent): add VariableAssigner input form (#16902)
## Summary - Add the runtime input form for VariableAssigner components - Allow the component input-form endpoint to resolve VariableAssigner nodes ## Testing - `bash build.sh --test ./internal/agent/component/...`
This commit is contained in:
@@ -129,6 +129,16 @@ func NewVariableAssignerComponent(params map[string]any) (Component, error) {
|
||||
// Name returns the registered component name.
|
||||
func (v *VariableAssignerComponent) Name() string { return v.name }
|
||||
|
||||
// GetInputForm returns the runtime input form consumed by the Agent UI.
|
||||
func (v *VariableAssignerComponent) GetInputForm() map[string]any {
|
||||
return map[string]any{
|
||||
"items": map[string]any{
|
||||
"type": "line",
|
||||
"name": "Items",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Invoke walks the param.variables list, evaluates each tuple against
|
||||
// the canvas state, and writes the result back unless the operator
|
||||
// returned an "ERROR:..." sentinel. The list of refs that were
|
||||
|
||||
@@ -245,3 +245,20 @@ func TestVariableAssigner_Registered(t *testing.T) {
|
||||
t.Errorf("Name()=%q, want VariableAssigner", c.Name())
|
||||
}
|
||||
}
|
||||
|
||||
func TestVariableAssignerGetInputForm(t *testing.T) {
|
||||
c, err := New("VariableAssigner", map[string]any{
|
||||
"variables": []map[string]any{},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("New(VariableAssigner): %v", err)
|
||||
}
|
||||
getter, ok := c.(interface{ GetInputForm() map[string]any })
|
||||
if !ok {
|
||||
t.Fatal("VariableAssigner component does not expose GetInputForm")
|
||||
}
|
||||
items, ok := getter.GetInputForm()["items"].(map[string]any)
|
||||
if !ok || items["type"] != "line" || items["name"] != "Items" {
|
||||
t.Errorf("GetInputForm()[items] = %#v", items)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user