MCPcopy Create free account
hub / github.com/astercloud/aster / SimpleFunction

Function SimpleFunction

pkg/workflow/step.go:249–266  ·  view source on GitHub ↗

===== Helper Functions =====

(name string, fn func(input any) (any, error))

Source from the content-addressed store, hash-verified

247// ===== Helper Functions =====
248
249func SimpleFunction(name string, fn func(input any) (any, error)) *FunctionStep {
250 return NewFunctionStep(name, func(ctx context.Context, stepInput *StepInput) (*StepOutput, error) {
251 input := stepInput.Input
252 if input == nil && stepInput.PreviousStepContent != nil {
253 input = stepInput.PreviousStepContent
254 }
255
256 output, err := fn(input)
257 if err != nil {
258 return nil, err
259 }
260
261 return &StepOutput{
262 Content: output,
263 Metadata: make(map[string]any),
264 }, nil
265 })
266}
267
268func TransformFunction(name string, transform func(input any) any) *FunctionStep {
269 return SimpleFunction(name, func(input any) (any, error) {

Callers 1

TransformFunctionFunction · 0.85

Calls 1

NewFunctionStepFunction · 0.85

Tested by

no test coverage detected