Skip to content

Commit 9ed8d6b

Browse files
committed
Merge branch 'main' into issue-892
2 parents 406bdd3 + b043e89 commit 9ed8d6b

File tree

27 files changed

+867
-963
lines changed

27 files changed

+867
-963
lines changed

api/src/test/java/io/serverlessworkflow/api/ApiTest.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@
2323
import io.serverlessworkflow.api.types.CallHTTP;
2424
import io.serverlessworkflow.api.types.CallTask;
2525
import io.serverlessworkflow.api.types.HTTPArguments;
26-
import io.serverlessworkflow.api.types.OAuth2AuthenticationData;
2726
import io.serverlessworkflow.api.types.OAuth2AuthenticationData.OAuth2AuthenticationDataGrant;
2827
import io.serverlessworkflow.api.types.OAuth2AuthenticationPolicy;
29-
import io.serverlessworkflow.api.types.OAuth2AuthenticationPolicyConfiguration;
3028
import io.serverlessworkflow.api.types.OAuth2AuthenticationPropertiesEndpoints;
29+
import io.serverlessworkflow.api.types.OAuth2ConnectAuthenticationProperties;
3130
import io.serverlessworkflow.api.types.Task;
3231
import io.serverlessworkflow.api.types.Workflow;
3332
import java.io.IOException;
@@ -99,20 +98,18 @@ void testOauth2Auth() throws IOException {
9998
.getAuthenticationPolicy()
10099
.getOAuth2AuthenticationPolicy();
101100
assertThat(oauthPolicy).isNotNull();
102-
OAuth2AuthenticationPolicyConfiguration oauth2Props =
101+
OAuth2ConnectAuthenticationProperties oauth2Props =
103102
oauthPolicy.getOauth2().getOAuth2ConnectAuthenticationProperties();
104103
assertThat(oauth2Props).isNotNull();
105-
OAuth2AuthenticationPropertiesEndpoints endpoints =
106-
oauth2Props.getOAuth2ConnectAuthenticationProperties().getEndpoints();
104+
OAuth2AuthenticationPropertiesEndpoints endpoints = oauth2Props.getEndpoints();
107105
assertThat(endpoints.getToken()).isEqualTo("/auth/token");
108106
assertThat(endpoints.getIntrospection()).isEqualTo("/auth/introspect");
109107

110-
OAuth2AuthenticationData oauth2Data = oauth2Props.getOAuth2AuthenticationData();
111-
assertThat(oauth2Data.getAuthority().getLiteralUri())
108+
assertThat(oauth2Props.getAuthority().getLiteralUri())
112109
.isEqualTo(URI.create("http://keycloak/realms/fake-authority"));
113-
assertThat(oauth2Data.getGrant()).isEqualTo(OAuth2AuthenticationDataGrant.CLIENT_CREDENTIALS);
114-
assertThat(oauth2Data.getClient().getId()).isEqualTo("workflow-runtime-id");
115-
assertThat(oauth2Data.getClient().getSecret()).isEqualTo("workflow-runtime-secret");
110+
assertThat(oauth2Props.getGrant()).isEqualTo(OAuth2AuthenticationDataGrant.CLIENT_CREDENTIALS);
111+
assertThat(oauth2Props.getClient().getId()).isEqualTo("workflow-runtime-id");
112+
assertThat(oauth2Props.getClient().getSecret()).isEqualTo("workflow-runtime-secret");
116113
}
117114

118115
@Test

experimental/agentic/src/main/java/io/serverlessworkflow/impl/model/agentic/AgenticModel.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,14 @@ public Optional<Map<String, Object>> asMap() {
4646
}
4747

4848
@Override
49-
public <T> Optional<T> as(Class<T> clazz) {
50-
if (AgenticScope.class.isAssignableFrom(clazz)) {
51-
return Optional.of(clazz.cast(this.agenticScope));
52-
} else if (Map.class.isAssignableFrom(clazz)) {
53-
return asMap().map(clazz::cast);
54-
} else {
55-
return super.as(clazz);
56-
}
49+
public Object asJavaObject() {
50+
return agenticScope;
5751
}
5852

5953
@Override
60-
public Object asJavaObject() {
61-
return agenticScope;
54+
protected <T> Optional<T> convert(Class<T> clazz) {
55+
return AgenticScope.class.isAssignableFrom(clazz)
56+
? Optional.of(clazz.cast(this.agenticScope))
57+
: super.convert(clazz);
6258
}
6359
}

experimental/fluent/agentic-langchain4j/src/test/java/io/serverlessworkflow/fluent/agentic/langchain4j/Agents.java

Lines changed: 0 additions & 195 deletions
Original file line numberDiff line numberDiff line change
@@ -15,140 +15,12 @@
1515
*/
1616
package io.serverlessworkflow.fluent.agentic.langchain4j;
1717

18-
import dev.langchain4j.agent.tool.Tool;
1918
import dev.langchain4j.agentic.Agent;
20-
import dev.langchain4j.agentic.scope.AgenticScopeAccess;
21-
import dev.langchain4j.service.MemoryId;
2219
import dev.langchain4j.service.UserMessage;
2320
import dev.langchain4j.service.V;
24-
import java.util.List;
2521

2622
public class Agents {
2723

28-
public interface ExpertRouterAgent {
29-
30-
@Agent
31-
String ask(@V("request") String request);
32-
}
33-
34-
public interface ExpertRouterAgentWithMemory extends AgenticScopeAccess {
35-
36-
@Agent
37-
String ask(@MemoryId String memoryId, @V("request") String request);
38-
}
39-
40-
public interface CategoryRouter {
41-
42-
@UserMessage(
43-
"""
44-
Analyze the following user request and categorize it as 'legal', 'medical' or 'technical'.
45-
In case the request doesn't belong to any of those categories categorize it as 'unknown'.
46-
Reply with only one of those words and nothing else.
47-
The user request is: '{{request}}'.
48-
""")
49-
@Agent("Categorize a user request")
50-
RequestCategory classify(@V("request") String request);
51-
}
52-
53-
public enum RequestCategory {
54-
LEGAL,
55-
MEDICAL,
56-
TECHNICAL,
57-
UNKNOWN
58-
}
59-
60-
public interface RouterAgent {
61-
62-
@UserMessage(
63-
"""
64-
Analyze the following user request and categorize it as 'legal', 'medical' or 'technical',
65-
then forward the request as it is to the corresponding expert provided as a tool.
66-
Finally return the answer that you received from the expert without any modification.
67-
68-
The user request is: '{{it}}'.
69-
""")
70-
@Agent
71-
String askToExpert(String request);
72-
}
73-
74-
public interface MedicalExpert {
75-
76-
@UserMessage(
77-
"""
78-
You are a medical expert.
79-
Analyze the following user request under a medical point of view and provide the best possible answer.
80-
The user request is {{request}}.
81-
""")
82-
@Tool("A medical expert")
83-
@Agent("A medical expert")
84-
String medical(@V("request") String request);
85-
}
86-
87-
public interface MedicalExpertWithMemory {
88-
89-
@UserMessage(
90-
"""
91-
You are a medical expert.
92-
Analyze the following user request under a medical point of view and provide the best possible answer.
93-
The user request is {{request}}.
94-
""")
95-
@Tool("A medical expert")
96-
@Agent("A medical expert")
97-
String medical(@MemoryId String memoryId, @V("request") String request);
98-
}
99-
100-
public interface LegalExpert {
101-
102-
@UserMessage(
103-
"""
104-
You are a legal expert.
105-
Analyze the following user request under a legal point of view and provide the best possible answer.
106-
The user request is {{request}}.
107-
""")
108-
@Tool("A legal expert")
109-
@Agent("A legal expert")
110-
String legal(@V("request") String request);
111-
}
112-
113-
public interface LegalExpertWithMemory {
114-
115-
@UserMessage(
116-
"""
117-
You are a legal expert.
118-
Analyze the following user request under a legal point of view and provide the best possible answer.
119-
The user request is {{request}}.
120-
""")
121-
@Tool("A legal expert")
122-
@Agent("A legal expert")
123-
String legal(@MemoryId String memoryId, @V("request") String request);
124-
}
125-
126-
public interface TechnicalExpert {
127-
128-
@UserMessage(
129-
"""
130-
You are a technical expert.
131-
Analyze the following user request under a technical point of view and provide the best possible answer.
132-
The user request is {{request}}.
133-
""")
134-
@Tool("A technical expert")
135-
@Agent("A technical expert")
136-
String technical(@V("request") String request);
137-
}
138-
139-
public interface TechnicalExpertWithMemory {
140-
141-
@UserMessage(
142-
"""
143-
You are a technical expert.
144-
Analyze the following user request under a technical point of view and provide the best possible answer.
145-
The user request is {{request}}.
146-
""")
147-
@Tool("A technical expert")
148-
@Agent("A technical expert")
149-
String technical(@MemoryId String memoryId, @V("request") String request);
150-
}
151-
15224
public interface CreativeWriter {
15325

15426
@UserMessage(
@@ -187,71 +59,4 @@ public interface StyleEditor {
18759
@Agent("Edit a story to better fit a given style")
18860
String editStory(@V("story") String story, @V("style") String style);
18961
}
190-
191-
public interface StyleScorer {
192-
193-
@UserMessage(
194-
"""
195-
You are a critical reviewer.
196-
Give a review score between 0.0 and 1.0 for the following story based on how well it aligns with the style '{{style}}'.
197-
Return only the score and nothing else.
198-
199-
The story is: "{{story}}"
200-
""")
201-
@Agent("Score a story based on how well it aligns with a given style")
202-
double scoreStyle(@V("story") String story, @V("style") String style);
203-
}
204-
205-
public interface StyleReviewLoop {
206-
207-
@Agent("Review the given story to ensure it aligns with the specified style")
208-
String scoreAndReview(@V("story") String story, @V("style") String style);
209-
}
210-
211-
public interface StyledWriter extends AgenticScopeAccess {
212-
213-
@Agent
214-
String writeStoryWithStyle(@V("topic") String topic, @V("style") String style);
215-
}
216-
217-
public interface FoodExpert {
218-
219-
@UserMessage(
220-
"""
221-
You are a great evening planner.
222-
Propose a list of 3 meals matching the given mood.
223-
The mood is {{mood}}.
224-
For each meal, just give the name of the meal.
225-
Provide a list with the 3 items and nothing else.
226-
""")
227-
@Agent
228-
List<String> findMeal(@V("mood") String mood);
229-
}
230-
231-
public interface MovieExpert {
232-
233-
@UserMessage(
234-
"""
235-
You are a great evening planner.
236-
Propose a list of 3 movies matching the given mood.
237-
The mood is {mood}.
238-
Provide a list with the 3 items and nothing else.
239-
""")
240-
@Agent
241-
List<String> findMovie(@V("mood") String mood);
242-
}
243-
244-
public record EveningPlan(String movie, String meal) {}
245-
246-
public interface EveningPlannerAgent {
247-
248-
@Agent
249-
List<EveningPlan> plan(@V("mood") String mood);
250-
}
251-
252-
public interface HoroscopeAgent {
253-
254-
@Agent
255-
String invoke(@V("name") String name);
256-
}
25762
}

0 commit comments

Comments
 (0)