Skip to content

Commit 5d60c89

Browse files
chore: Bump jackson-annotations and lc4j.beta (#757)
Signed-off-by: Ricardo Zanini <[email protected]>
1 parent 7f7afd1 commit 5d60c89

File tree

5 files changed

+51
-13
lines changed

5 files changed

+51
-13
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,24 @@ public S output(Function<AgenticScope, Object> output) {
8282

8383
@SuppressWarnings("unchecked")
8484
public S errorHandler(Function<ErrorContext, ErrorRecoveryResult> errorHandler) {
85+
// TODO: implement
8586
return (S) this;
8687
}
8788

8889
@Override
8990
public Workflow getDefinition() {
9091
return this.workflowBuilder.build();
9192
}
93+
94+
@SuppressWarnings("unchecked")
95+
public S name(String name) {
96+
this.workflowBuilder.document(d -> d.name(name));
97+
return (S) this;
98+
}
99+
100+
@SuppressWarnings("unchecked")
101+
public S description(String description) {
102+
this.workflowBuilder.document(d -> d.summary(description));
103+
return (S) this;
104+
}
92105
}

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import dev.langchain4j.agentic.workflow.ParallelAgentService;
2020
import io.serverlessworkflow.impl.ExecutorServiceHolder;
2121
import java.util.List;
22+
import java.util.concurrent.Executor;
2223
import java.util.concurrent.ExecutorService;
2324

2425
public class ParallelAgentServiceImpl<T> extends AbstractAgentService<T, ParallelAgentService<T>>
@@ -32,12 +33,6 @@ public static <T> ParallelAgentService<T> builder(Class<T> agentServiceClass) {
3233
return new ParallelAgentServiceImpl<>(agentServiceClass);
3334
}
3435

35-
@Override
36-
public ParallelAgentService<T> executorService(ExecutorService executorService) {
37-
this.workflowExecBuilder.withExecutorFactory(new ExecutorServiceHolder(executorService));
38-
return this;
39-
}
40-
4136
@Override
4237
public ParallelAgentService<T> subAgents(Object... agents) {
4338
this.workflowBuilder.tasks(t -> t.parallel(agents));
@@ -48,4 +43,16 @@ public ParallelAgentService<T> subAgents(Object... agents) {
4843
public ParallelAgentService<T> subAgents(List<AgentExecutor> agentExecutors) {
4944
return this.subAgents(agentExecutors.toArray());
5045
}
46+
47+
@Override
48+
public ParallelAgentService<T> executor(Executor executor) {
49+
if (!(executor instanceof ExecutorService)) {
50+
throw new IllegalArgumentException(
51+
"ExecutorService is required for the ParallelAgentService");
52+
}
53+
// TODO: create an adapter or change or internal holder to accept a plain `Executor`.
54+
this.workflowExecBuilder.withExecutorFactory(
55+
new ExecutorServiceHolder((ExecutorService) executor));
56+
return this;
57+
}
5158
}

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,15 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
8484
// outputName
8585
if (method.getDeclaringClass() == AgentSpecification.class) {
8686
return switch (method.getName()) {
87+
case "name" -> this.workflow.getDocument().getName();
88+
case "description" -> this.workflow.getDocument().getSummary();
8789
case "outputName" -> outputName();
8890
default ->
8991
throw new UnsupportedOperationException(
9092
"Unknown method on AgentInstance class : " + method.getName());
9193
};
9294
}
93-
// withCognisphere
95+
// withAgenticScope
9496
if (method.getDeclaringClass() == AgenticScopeOwner.class) {
9597
// Ingest the workflow input as a AgenticScope object
9698
// Later, retrieve it and start the workflow with it as input.
@@ -99,11 +101,11 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
99101
case "registry" -> registry;
100102
default ->
101103
throw new UnsupportedOperationException(
102-
"Unknown method on CognisphereOwner class : " + method.getName());
104+
"Unknown method on AgenticScopeOwner class : " + method.getName());
103105
};
104106
}
105107
// getAgenticScope
106-
// evictCognisphere
108+
// evictAgenticScope
107109
if (method.getDeclaringClass() == AgenticScopeAccess.class) {
108110
return switch (method.getName()) {
109111
case "getAgenticScope" -> registry().get(args[0]);
@@ -132,7 +134,7 @@ private Object executeWorkflow(AgenticScope agenticScope, Method method, Object[
132134
.orElseThrow(
133135
() ->
134136
new IllegalArgumentException(
135-
"Workflow hasn't returned a Cognisphere object."));
137+
"Workflow hasn't returned a AgenticScope object."));
136138
Object result = output.readState(outputName());
137139

138140
return method.getReturnType().equals(ResultWithAgenticScope.class)

fluent/agentic/src/test/java/io/serverlessworkflow/fluent/agentic/WorkflowTests.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public void testAgent() throws ExecutionException, InterruptedException {
4242

4343
when(storySeedAgent.invoke(eq("A Great Story"))).thenReturn("storySeedAgent");
4444
when(storySeedAgent.outputName()).thenReturn("premise");
45+
when(storySeedAgent.name()).thenReturn("storySeedAgent");
4546

4647
Workflow workflow =
4748
AgentWorkflowBuilder.workflow("storyFlow")
@@ -72,12 +73,15 @@ public void testAgents() throws ExecutionException, InterruptedException {
7273

7374
when(storySeedAgent.invoke(eq("A Great Story"))).thenReturn("storySeedAgent");
7475
when(storySeedAgent.outputName()).thenReturn("premise");
76+
when(storySeedAgent.name()).thenReturn("storySeedAgent");
7577

7678
when(plotAgent.invoke(eq("storySeedAgent"))).thenReturn("plotAgent");
7779
when(plotAgent.outputName()).thenReturn("plot");
80+
when(plotAgent.name()).thenReturn("plotAgent");
7881

7982
when(sceneAgent.invoke(eq("plotAgent"))).thenReturn("sceneAgent");
8083
when(sceneAgent.outputName()).thenReturn("story");
84+
when(sceneAgent.name()).thenReturn("sceneAgent");
8185

8286
Workflow workflow =
8387
AgentWorkflowBuilder.workflow("storyFlow")
@@ -112,12 +116,15 @@ public void testSequence() throws ExecutionException, InterruptedException {
112116

113117
when(storySeedAgent.invoke(eq("A Great Story"))).thenReturn("storySeedAgent");
114118
when(storySeedAgent.outputName()).thenReturn("premise");
119+
when(storySeedAgent.name()).thenReturn("storySeedAgent");
115120

116121
when(plotAgent.invoke(eq("storySeedAgent"))).thenReturn("plotAgent");
117122
when(plotAgent.outputName()).thenReturn("plot");
123+
when(plotAgent.name()).thenReturn("plotAgent");
118124

119125
when(sceneAgent.invoke(eq("plotAgent"))).thenReturn("sceneAgent");
120126
when(sceneAgent.outputName()).thenReturn("story");
127+
when(sceneAgent.name()).thenReturn("sceneAgent");
121128

122129
Workflow workflow =
123130
AgentWorkflowBuilder.workflow("storyFlow")
@@ -149,12 +156,15 @@ public void testParallel() throws ExecutionException, InterruptedException {
149156

150157
when(setting.invoke(eq("sci-fi"))).thenReturn("Fake conflict response");
151158
when(setting.outputName()).thenReturn("setting");
159+
when(setting.name()).thenReturn("setting");
152160

153161
when(hero.invoke(eq("sci-fi"))).thenReturn("Fake hero response");
154162
when(hero.outputName()).thenReturn("hero");
163+
when(hero.name()).thenReturn("hero");
155164

156165
when(conflict.invoke(eq("sci-fi"))).thenReturn("Fake setting response");
157166
when(conflict.outputName()).thenReturn("conflict");
167+
when(conflict.name()).thenReturn("conflict");
158168

159169
Workflow workflow =
160170
AgentWorkflowBuilder.workflow("parallelFlow")
@@ -193,12 +203,15 @@ public void testSeqAndThenParallel() throws ExecutionException, InterruptedExcep
193203

194204
when(factAgent.invoke(eq("alien"))).thenReturn("Some Fact about aliens");
195205
when(factAgent.outputName()).thenReturn("fact");
206+
when(factAgent.name()).thenReturn("fact");
196207

197208
when(cultureAgent.invoke(eq("Some Fact about aliens"))).thenReturn(cultureTraits);
198209
when(cultureAgent.outputName()).thenReturn("culture");
210+
when(cultureAgent.name()).thenReturn("culture");
199211

200212
when(technologyAgent.invoke(eq("Some Fact about aliens"))).thenReturn(technologyTraits);
201213
when(technologyAgent.outputName()).thenReturn("technology");
214+
when(technologyAgent.name()).thenReturn("technology");
202215
Workflow workflow =
203216
AgentWorkflowBuilder.workflow("alienCultureFlow")
204217
.tasks(
@@ -237,11 +250,13 @@ public void humanInTheLoop() throws ExecutionException, InterruptedException {
237250
eq("Discuss project updates")))
238251
.thenReturn("Drafted meeting invitation for John Doe");
239252
when(meetingInvitationDraft.outputName()).thenReturn("draft");
253+
when(meetingInvitationDraft.name()).thenReturn("draft");
240254

241255
final MeetingInvitationStyle meetingInvitationStyle = mock(MeetingInvitationStyle.class);
242256
when(meetingInvitationStyle.invoke(eq("Drafted meeting invitation for John Doe"), eq("formal")))
243257
.thenReturn("Styled meeting invitation for John Doe");
244258
when(meetingInvitationStyle.outputName()).thenReturn("styled");
259+
when(meetingInvitationStyle.name()).thenReturn("styled");
245260

246261
AtomicReference<String> request = new AtomicReference<>();
247262

pom.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@
7777

7878
<!-- Dependencies versions, please keep in alphabetical order -->
7979
<version.ch.qos.logback>1.5.18</version.ch.qos.logback>
80-
<version.com.fasterxml.jackson>2.19.2</version.com.fasterxml.jackson>
80+
<version.com.fasterxml.jackson>2.20.0</version.com.fasterxml.jackson>
81+
<version.com.fasterxml.jackson.annotations>2.20</version.com.fasterxml.jackson.annotations>
8182
<version.com.networknt>1.5.8</version.com.networknt>
8283
<version.com.squareup.okhttp3.mockwebserver>5.1.0</version.com.squareup.okhttp3.mockwebserver>
8384
<version.io.cloudevents>4.0.1</version.io.cloudevents>
@@ -90,7 +91,7 @@
9091
<version.org.hibernate.validator>9.0.1.Final</version.org.hibernate.validator>
9192
<version.org.glassfish.expressly>6.0.0</version.org.glassfish.expressly>
9293
<!-- Experimental modules from langchain4j -->
93-
<version.dev.langchain4j.beta>1.3.0-beta9</version.dev.langchain4j.beta>
94+
<version.dev.langchain4j.beta>1.4.0-beta10</version.dev.langchain4j.beta>
9495
<!-- Base langchain4j version -->
9596
<version.dev.langchain4j>1.4.0</version.dev.langchain4j>
9697

@@ -136,7 +137,7 @@
136137
<dependency>
137138
<groupId>com.fasterxml.jackson.core</groupId>
138139
<artifactId>jackson-annotations</artifactId>
139-
<version>${version.com.fasterxml.jackson}</version>
140+
<version>${version.com.fasterxml.jackson.annotations}</version>
140141
</dependency>
141142
<dependency>
142143
<groupId>io.cloudevents</groupId>

0 commit comments

Comments
 (0)