Skip to content

Commit 53e698b

Browse files
committed
Fix outputName; Minor TODOs;
Signed-off-by: Ricardo Zanini <ricardozanini@gmail.com>
1 parent e96319f commit 53e698b

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

fluent/agentic-langchain4j/src/main/java/io/serverlessworkflow/fluent/agentic/langchain4j/AbstractAgentService.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323

2424
public abstract class AbstractAgentService<T, S> implements WorkflowDefinitionBuilder {
2525

26+
// Workflow OutputAs
2627
private static final Function<Cognisphere, Object> DEFAULT_OUTPUT_FUNCTION = cognisphere -> null;
28+
// Workflow InputFrom
2729
private static final Consumer<Cognisphere> DEFAULT_INIT_FUNCTION = cognisphere -> {};
2830

2931
protected final AgentWorkflowBuilder workflowBuilder;
@@ -52,8 +54,8 @@ public S beforeCall(Consumer<Cognisphere> beforeCall) {
5254

5355
@SuppressWarnings("unchecked")
5456
public S outputName(String outputName) {
55-
// TODO: This can be solved using a combination with our output object
56-
this.workflowBuilder.document(d -> d.name(outputName));
57+
Function<Cognisphere, Object> outputFunction = cog -> cog.readState(outputName);
58+
this.workflowBuilder.outputAs(outputFunction);
5759
return (S) this;
5860
}
5961

fluent/agentic-langchain4j/src/main/java/io/serverlessworkflow/fluent/agentic/langchain4j/ParallelAgentServiceImpl.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
public class ParallelAgentServiceImpl<T> extends AbstractAgentService<T, ParallelAgentService<T>>
2424
implements ParallelAgentService<T> {
2525

26+
private ExecutorService executor;
27+
2628
private ParallelAgentServiceImpl(Class<T> agentServiceClass) {
2729
super(agentServiceClass);
2830
}
@@ -33,8 +35,8 @@ public static <T> ParallelAgentService<T> builder(Class<T> agentServiceClass) {
3335

3436
@Override
3537
public ParallelAgentService<T> executorService(ExecutorService executorService) {
36-
// TODO: add to the internal WorkflowApplication the executorService to run agents in parallel
37-
return null;
38+
this.executor = executorService;
39+
return this;
3840
}
3941

4042
@Override

fluent/agentic-langchain4j/src/test/java/io/serverlessworkflow/fluent/agentic/langchain4j/SequentialAgentServiceImplTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import dev.langchain4j.agentic.cognisphere.Cognisphere;
2424
import io.serverlessworkflow.api.types.Workflow;
2525
import io.serverlessworkflow.api.types.func.CallJava;
26+
import io.serverlessworkflow.api.types.func.OutputAsFunction;
2627
import io.serverlessworkflow.fluent.agentic.AgentsUtils;
2728
import java.util.function.Function;
2829
import org.junit.jupiter.api.Test;
@@ -70,8 +71,8 @@ void shouldSetOutputName_inDocumentMetadata() {
7071

7172
// then
7273
assertNotNull(wf.getDocument().getName(), "Workflow name should not be null");
73-
assertEquals(
74-
outputName, wf.getDocument().getName(), "Workflow name should match the outputName");
74+
assertNotNull(wf.getOutput().getAs(), "Workflow outputAs should not be null");
75+
assertInstanceOf(OutputAsFunction.class, wf.getOutput().getAs());
7576
}
7677

7778
@Test

0 commit comments

Comments
 (0)