Skip to content

Commit 1cffa21

Browse files
committed
initial commit with quarkus modules
Signed-off-by: salaboy <Salaboy@gmail.com>
1 parent a2877aa commit 1cffa21

File tree

94 files changed

+7342
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+7342
-0
lines changed

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,7 @@
715715
<!-- We are following test containers artifact convention on purpose, don't rename -->
716716
<module>testcontainers-dapr</module>
717717
<module>durabletask-client</module>
718+
<module>quarkus</module>
718719
</modules>
719720

720721
<profiles>

quarkus/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# quarkus-agentic-dapr
2+
Quarkus Agentic Dapr Workflows integration

quarkus/deployment/pom.xml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>io.dapr.quarkus</groupId>
8+
<artifactId>dapr-quarkus-agentic-parent</artifactId>
9+
<version>1.18.0-SNAPSHOT</version>
10+
<relativePath>../pom.xml</relativePath>
11+
</parent>
12+
13+
<artifactId>quarkus-agentic-dapr-deployment</artifactId>
14+
<name>Quarkus Agentic Dapr - Deployment</name>
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>io.quarkiverse.dapr</groupId>
19+
<artifactId>quarkus-dapr-deployment</artifactId>
20+
<version>${quarkus-dapr.version}</version>
21+
</dependency>
22+
<dependency>
23+
<groupId>io.quarkiverse.langchain4j</groupId>
24+
<artifactId>quarkus-langchain4j-agentic-deployment</artifactId>
25+
<version>${quarkus-langchain4j.version}</version>
26+
</dependency>
27+
<dependency>
28+
<groupId>io.quarkus</groupId>
29+
<artifactId>quarkus-arc-deployment</artifactId>
30+
</dependency>
31+
<dependency>
32+
<groupId>io.quarkus.gizmo</groupId>
33+
<artifactId>gizmo</artifactId>
34+
</dependency>
35+
<dependency>
36+
<groupId>io.quarkiverse.dapr</groupId>
37+
<artifactId>quarkus-agentic-dapr</artifactId>
38+
<version>${project.version}</version>
39+
</dependency>
40+
</dependencies>
41+
42+
<build>
43+
<plugins>
44+
<plugin>
45+
<groupId>org.apache.maven.plugins</groupId>
46+
<artifactId>maven-compiler-plugin</artifactId>
47+
<version>3.13.0</version>
48+
<configuration>
49+
<annotationProcessorPaths>
50+
<path>
51+
<groupId>io.quarkus</groupId>
52+
<artifactId>quarkus-extension-processor</artifactId>
53+
<version>${quarkus.version}</version>
54+
</path>
55+
</annotationProcessorPaths>
56+
</configuration>
57+
</plugin>
58+
</plugins>
59+
</build>
60+
</project>

quarkus/deployment/src/main/java/io/quarkiverse/dapr/langchain4j/deployment/DaprAgenticProcessor.java

Lines changed: 592 additions & 0 deletions
Large diffs are not rendered by default.

quarkus/examples/pom.xml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>io.dapr.quarkus</groupId>
8+
<artifactId>dapr-quarkus-agentic-parent</artifactId>
9+
<version>1.18.0-SNAPSHOT</version>
10+
<relativePath>../pom.xml</relativePath>
11+
</parent>
12+
13+
<artifactId>quarkus-agentic-dapr-examples</artifactId>
14+
<name>Quarkus Agentic Dapr - Examples</name>
15+
16+
<dependencies>
17+
<!-- Our Dapr Agentic extension (brings quarkus-dapr + quarkus-langchain4j-agentic transitively) -->
18+
<dependency>
19+
<groupId>io.quarkiverse.dapr</groupId>
20+
<artifactId>quarkus-agentic-dapr</artifactId>
21+
<version>${project.version}</version>
22+
</dependency>
23+
24+
<dependency>
25+
<groupId>io.quarkiverse.dapr</groupId>
26+
<artifactId>quarkus-agentic-dapr-agents-registry</artifactId>
27+
<version>${project.version}</version>
28+
</dependency>
29+
30+
<!-- LLM provider -->
31+
<dependency>
32+
<groupId>io.quarkiverse.langchain4j</groupId>
33+
<artifactId>quarkus-langchain4j-openai</artifactId>
34+
<version>${quarkus-langchain4j.version}</version>
35+
</dependency>
36+
37+
<!-- REST endpoint -->
38+
<dependency>
39+
<groupId>io.quarkus</groupId>
40+
<artifactId>quarkus-rest</artifactId>
41+
</dependency>
42+
43+
<!-- Test dependencies -->
44+
<dependency>
45+
<groupId>io.quarkus</groupId>
46+
<artifactId>quarkus-junit5</artifactId>
47+
<scope>test</scope>
48+
</dependency>
49+
<dependency>
50+
<groupId>io.rest-assured</groupId>
51+
<artifactId>rest-assured</artifactId>
52+
<scope>test</scope>
53+
</dependency>
54+
<dependency>
55+
<groupId>org.awaitility</groupId>
56+
<artifactId>awaitility</artifactId>
57+
<scope>test</scope>
58+
</dependency>
59+
</dependencies>
60+
61+
<build>
62+
<plugins>
63+
<plugin>
64+
<groupId>io.quarkus</groupId>
65+
<artifactId>quarkus-maven-plugin</artifactId>
66+
<version>${quarkus.version}</version>
67+
<executions>
68+
<execution>
69+
<goals>
70+
<goal>build</goal>
71+
</goals>
72+
</execution>
73+
</executions>
74+
</plugin>
75+
<plugin>
76+
<artifactId>maven-compiler-plugin</artifactId>
77+
<version>3.13.0</version>
78+
<configuration>
79+
<compilerArgs>
80+
<arg>-parameters</arg>
81+
</compilerArgs>
82+
</configuration>
83+
</plugin>
84+
<plugin>
85+
<artifactId>maven-surefire-plugin</artifactId>
86+
<version>3.5.2</version>
87+
<configuration>
88+
<systemPropertyVariables>
89+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
90+
</systemPropertyVariables>
91+
</configuration>
92+
</plugin>
93+
</plugins>
94+
</build>
95+
</project>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package io.quarkiverse.dapr.examples;
2+
3+
import dev.langchain4j.agentic.Agent;
4+
import dev.langchain4j.service.UserMessage;
5+
import dev.langchain4j.service.V;
6+
import io.quarkiverse.langchain4j.ToolBox;
7+
8+
/**
9+
* Sub-agent that generates a creative story draft based on a given topic.
10+
*/
11+
public interface CreativeWriter {
12+
13+
@UserMessage("""
14+
You are a creative writer.
15+
Generate a draft of a story no more than 3 sentences around the given topic.
16+
Return only the story and nothing else.
17+
The topic is {{topic}}.
18+
""")
19+
@Agent(name = "creative-writer-agent", description = "Generate a story based on the given topic", outputKey = "story")
20+
String generateStory(@V("topic") String topic);
21+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package io.quarkiverse.dapr.examples;
2+
3+
import dev.langchain4j.agentic.declarative.Output;
4+
import dev.langchain4j.agentic.declarative.ParallelAgent;
5+
import dev.langchain4j.service.V;
6+
7+
/**
8+
* Composite agent that orchestrates {@link StoryCreator} and {@link ResearchWriter}
9+
* in parallel, backed by a Dapr Workflow.
10+
* <p>
11+
* Both sub-agents execute concurrently via a {@code ParallelOrchestrationWorkflow}.
12+
* {@link StoryCreator} is itself a {@code @SequenceAgent} that chains
13+
* {@link CreativeWriter} and {@link StyleEditor} — demonstrating nested composite agents.
14+
* Meanwhile {@link ResearchWriter} gathers facts about the country.
15+
*/
16+
public interface ParallelCreator {
17+
18+
@ParallelAgent(name = "parallel-creator-agent",
19+
outputKey = "storyAndCountryResearch",
20+
subAgents = { StoryCreator.class, ResearchWriter.class })
21+
ParallelStatus create(@V("topic") String topic, @V("country") String country, @V("style") String style);
22+
23+
@Output
24+
static ParallelStatus output(String story, String summary) {
25+
if(story == null || summary == null){
26+
return new ParallelStatus("ERROR", story, summary);
27+
}
28+
return new ParallelStatus("OK", story, summary);
29+
}
30+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package io.quarkiverse.dapr.examples;
2+
3+
import jakarta.inject.Inject;
4+
import jakarta.ws.rs.DefaultValue;
5+
import jakarta.ws.rs.GET;
6+
import jakarta.ws.rs.Path;
7+
import jakarta.ws.rs.Produces;
8+
import jakarta.ws.rs.QueryParam;
9+
import jakarta.ws.rs.core.MediaType;
10+
11+
/**
12+
* REST endpoint that triggers the parallel creation workflow.
13+
* <p>
14+
* Runs {@link StoryCreator} (a nested {@code @SequenceAgent}) and {@link ResearchWriter}
15+
* in parallel via a {@code ParallelOrchestrationWorkflow} Dapr Workflow.
16+
* <p>
17+
* Example usage:
18+
* <pre>
19+
* curl "http://localhost:8080/parallel?topic=dragons&amp;country=France&amp;style=comedy"
20+
* </pre>
21+
*/
22+
@Path("/parallel")
23+
public class ParallelResource {
24+
25+
@Inject
26+
ParallelCreator parallelCreator;
27+
28+
@GET
29+
@Produces(MediaType.APPLICATION_JSON)
30+
public ParallelStatus create(
31+
@QueryParam("topic") @DefaultValue("dragons and wizards") String topic,
32+
@QueryParam("country") @DefaultValue("France") String country,
33+
@QueryParam("style") @DefaultValue("fantasy") String style) {
34+
return parallelCreator.create(topic, country, style);
35+
}
36+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package io.quarkiverse.dapr.examples;
2+
3+
public record ParallelStatus(String status, String story, String summary) {
4+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package io.quarkiverse.dapr.examples;
2+
3+
import jakarta.inject.Inject;
4+
import jakarta.ws.rs.DefaultValue;
5+
import jakarta.ws.rs.GET;
6+
import jakarta.ws.rs.Path;
7+
import jakarta.ws.rs.Produces;
8+
import jakarta.ws.rs.QueryParam;
9+
import jakarta.ws.rs.core.MediaType;
10+
11+
/**
12+
* REST endpoint that triggers a research workflow with tool calls routed through
13+
* Dapr Workflow Activities.
14+
* <p>
15+
* Each request:
16+
* <ol>
17+
* <li>Starts a {@code SequentialOrchestrationWorkflow} (orchestration level).</li>
18+
* <li>For the {@link ResearchWriter} sub-agent, starts an {@code AgentRunWorkflow}
19+
* (per-agent level).</li>
20+
* <li>Each LLM tool call ({@code getPopulation} / {@code getCapital}) is executed
21+
* inside a {@code ToolCallActivity} (tool-call level).</li>
22+
* </ol>
23+
* <p>
24+
* Example usage:
25+
* <pre>
26+
* curl "http://localhost:8080/research?country=France"
27+
* curl "http://localhost:8080/research?country=Germany"
28+
* </pre>
29+
*/
30+
@Path("/research")
31+
public class ResearchResource {
32+
33+
@Inject
34+
ResearchWriter researchWriter;
35+
36+
@GET
37+
@Produces(MediaType.TEXT_PLAIN)
38+
public String research(
39+
@QueryParam("country") @DefaultValue("France") String country) {
40+
return researchWriter.research(country);
41+
}
42+
}

0 commit comments

Comments
 (0)