Skip to content

Add outputAs|inputFrom(WorkflowModel workflowInput) method to DSL #1196

@mcruzdev

Description

@mcruzdev

What would you like to be added:

To have a better experience on handling workflow data.

Actually we need to have this one:

agent("scoreSubmission",
    (uniqueId, proposal) -> reviewer.scoreSubmission(proposal), Proposal.class)
    .outputAs(buildSubmissionOutput(), Long.class),
    // ...
    private static JavaContextFunction<Long, ScoreSubmissionOutput> buildSubmissionOutput() {
        return (score, workflowContext) ->
                new ScoreSubmissionOutput(score, workflowContext.instanceData().input().as(Proposal.class).orElseThrow());
    }

For every time we need to get the workflowContext.instanceData().input() we need to write a lot. It would be great if we have something more easy, like:

.outputAs((WorfklowModel inputModel, T lastState), Class<T> lastStateClass);

.inputFrom((WorfklowModel inputModel, T lastState), Class<T> lastStateClass);

.outputAs((WorfklowModel inputModel), Class<T> outputClass);

.inputFrom((WorfklowModel inputModel), Class<T> outputClass);

Why is this needed:

To make give a better experience when developing workflow with DSL

Metadata

Metadata

Assignees

Labels

javaPull requests that update java codespec:1.0.0

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions