Skip to content

Commit 5f86be6

Browse files
authored
feat(#145): Add Quarkus integration with extension and starter (#185)
1 parent 987dca1 commit 5f86be6

26 files changed

Lines changed: 2722 additions & 1 deletion

File tree

agentscope-examples/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<module>quickstart</module>
3636
<module>werewolf</module>
3737
<module>advanced</module>
38+
<module>quarkus-example</module>
3839
</modules>
3940

4041
<properties>
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# AgentScope Quarkus Example
2+
3+
This is an example application demonstrating how to use AgentScope with Quarkus.
4+
5+
## 🚀 Running the Application
6+
7+
### Prerequisites
8+
9+
- Java 17 or later
10+
- Maven 3.8+
11+
- A valid API key from one of the supported providers (DashScope, OpenAI, Gemini, or Anthropic)
12+
13+
### Configuration
14+
15+
Set your API key as an environment variable:
16+
17+
```bash
18+
export DASHSCOPE_API_KEY=your-api-key-here
19+
```
20+
21+
Or configure it in `src/main/resources/application.properties`.
22+
23+
### Running in Dev Mode
24+
25+
```bash
26+
mvn quarkus:dev
27+
```
28+
29+
The application will start on http://localhost:8080
30+
31+
### Testing the Endpoints
32+
33+
```bash
34+
# Health check
35+
curl http://localhost:8080/agent/health
36+
37+
# Chat with the agent
38+
curl -X POST http://localhost:8080/agent/chat \
39+
-H "Content-Type: application/json" \
40+
-d '{"message":"Hello, who are you?"}'
41+
```
42+
43+
## 🧪 Running Tests
44+
45+
**Note:** Tests are skipped by default because they require a valid API key and make real API calls.
46+
47+
To run tests locally with your API key:
48+
49+
```bash
50+
# Set your API key
51+
export DASHSCOPE_API_KEY=your-real-api-key
52+
53+
# Run tests
54+
mvn test -DskipExampleTests=false
55+
```
56+
57+
## 🐳 Docker
58+
59+
### Build JVM Image
60+
61+
```bash
62+
mvn package
63+
docker build -f src/main/docker/Dockerfile.jvm -t agentscope-quarkus .
64+
docker run -i --rm -p 8080:8080 -e DASHSCOPE_API_KEY=your-key agentscope-quarkus
65+
```
66+
67+
### Build Native Image
68+
69+
```bash
70+
mvn package -Pnative
71+
docker build -f src/main/docker/Dockerfile.native -t agentscope-quarkus-native .
72+
docker run -i --rm -p 8080:8080 -e DASHSCOPE_API_KEY=your-key agentscope-quarkus-native
73+
```
74+
75+
## 📚 More Information
76+
77+
- [AgentScope Documentation](https://github.com/agentscope-ai/agentscope-java)
78+
- [Quarkus Documentation](https://quarkus.io/)
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright 2024-2025 the original author or authors.
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
<project xmlns="http://maven.apache.org/POM/4.0.0"
18+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20+
<modelVersion>4.0.0</modelVersion>
21+
<parent>
22+
<groupId>io.agentscope</groupId>
23+
<artifactId>agentscope-examples</artifactId>
24+
<version>${revision}</version>
25+
</parent>
26+
27+
<artifactId>quarkus-example</artifactId>
28+
<name>AgentScope Java - Quarkus Example</name>
29+
<description>Example application demonstrating AgentScope with Quarkus</description>
30+
31+
<properties>
32+
<quarkus.version>3.17.5</quarkus.version>
33+
<!-- Skip tests by default for example projects (requires API keys) -->
34+
<skipExampleTests>true</skipExampleTests>
35+
</properties>
36+
37+
<dependencyManagement>
38+
<dependencies>
39+
<dependency>
40+
<groupId>io.quarkus</groupId>
41+
<artifactId>quarkus-bom</artifactId>
42+
<version>${quarkus.version}</version>
43+
<type>pom</type>
44+
<scope>import</scope>
45+
</dependency>
46+
</dependencies>
47+
</dependencyManagement>
48+
49+
<dependencies>
50+
<!-- AgentScope Quarkus Extension (includes auto-configuration) -->
51+
<dependency>
52+
<groupId>io.agentscope</groupId>
53+
<artifactId>agentscope-quarkus-extension</artifactId>
54+
<version>${revision}</version>
55+
</dependency>
56+
57+
<!-- Quarkus REST -->
58+
<dependency>
59+
<groupId>io.quarkus</groupId>
60+
<artifactId>quarkus-rest</artifactId>
61+
</dependency>
62+
63+
<!-- Quarkus REST Jackson -->
64+
<dependency>
65+
<groupId>io.quarkus</groupId>
66+
<artifactId>quarkus-rest-jackson</artifactId>
67+
</dependency>
68+
69+
<!-- Test dependencies -->
70+
<dependency>
71+
<groupId>io.quarkus</groupId>
72+
<artifactId>quarkus-junit5</artifactId>
73+
<scope>test</scope>
74+
</dependency>
75+
<dependency>
76+
<groupId>io.rest-assured</groupId>
77+
<artifactId>rest-assured</artifactId>
78+
<scope>test</scope>
79+
</dependency>
80+
</dependencies>
81+
82+
<build>
83+
<plugins>
84+
<plugin>
85+
<groupId>io.quarkus</groupId>
86+
<artifactId>quarkus-maven-plugin</artifactId>
87+
<version>${quarkus.version}</version>
88+
<executions>
89+
<execution>
90+
<goals>
91+
<goal>build</goal>
92+
</goals>
93+
</execution>
94+
</executions>
95+
</plugin>
96+
<plugin>
97+
<groupId>org.apache.maven.plugins</groupId>
98+
<artifactId>maven-surefire-plugin</artifactId>
99+
<configuration>
100+
<!-- Skip tests in CI if no API key is available -->
101+
<skipTests>${skipExampleTests}</skipTests>
102+
</configuration>
103+
</plugin>
104+
</plugins>
105+
</build>
106+
107+
<profiles>
108+
<profile>
109+
<id>native</id>
110+
<properties>
111+
<quarkus.native.enabled>true</quarkus.native.enabled>
112+
</properties>
113+
</profile>
114+
</profiles>
115+
</project>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#
2+
# Copyright 2024-2025 the original author or authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
####
18+
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
19+
#
20+
# Build the image with:
21+
#
22+
# docker build -f src/main/docker/Dockerfile.jvm -t agentscope-quarkus .
23+
#
24+
# Then run the container using:
25+
#
26+
# docker run -i --rm -p 8080:8080 -e DASHSCOPE_API_KEY=your-key agentscope-quarkus
27+
#
28+
###
29+
FROM registry.access.redhat.com/ubi8/openjdk-17:1.20
30+
31+
ENV LANGUAGE='en_US:en'
32+
33+
# We make four distinct layers so if there are application changes the library layers can be re-used
34+
COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/
35+
COPY --chown=185 target/quarkus-app/*.jar /deployments/
36+
COPY --chown=185 target/quarkus-app/app/ /deployments/app/
37+
COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/
38+
39+
EXPOSE 8080
40+
USER 185
41+
ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
42+
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
43+
44+
ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ]
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#
2+
# Copyright 2024-2025 the original author or authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
####
18+
# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode.
19+
# It uses a micro base image, tuned for Quarkus native executables.
20+
# It reduces the size of the resulting container image.
21+
#
22+
# Build the image with:
23+
#
24+
# docker build -f src/main/docker/Dockerfile.native -t agentscope-quarkus-native .
25+
#
26+
# Then run the container using:
27+
#
28+
# docker run -i --rm -p 8080:8080 -e DASHSCOPE_API_KEY=your-key agentscope-quarkus-native
29+
#
30+
###
31+
FROM quay.io/quarkus/quarkus-micro-image:2.0
32+
WORKDIR /work/
33+
RUN chown 1001 /work \
34+
&& chmod "g+rwX" /work \
35+
&& chown 1001:root /work
36+
COPY --chown=1001:root target/*-runner /work/application
37+
38+
EXPOSE 8080
39+
USER 1001
40+
41+
ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]

0 commit comments

Comments
 (0)