安装¶
AgentScope Java 支持多种模型、RAG 后端和扩展功能,各自需要不同的第三方 SDK。把所有依赖打包到一起会让项目变得臃肿,所以我们提供了两种引入方式:
All-in-one:一个依赖搞定,默认带 DashScope SDK 和 MCP SDK,快速上手
Core + 扩展:最小化核心包,按需加扩展模块,适合对依赖有严格要求的场景
大多数情况下用 all-in-one 就够了,需要精细控制依赖时再换成 core + 扩展。
要求:JDK 17+
依赖选择¶
方式 |
适用场景 |
特点 |
|---|---|---|
all-in-one |
快速开始、大多数用户 |
单一依赖,默认带 DashScope SDK |
core + 扩展 |
精细控制依赖 |
按需引入,依赖最小化 |
All-in-One(推荐)¶
Maven:
<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope</artifactId>
<version>1.0.7</version>
</dependency>
Gradle:
implementation 'io.agentscope:agentscope:1.0.7'
默认包含的依赖¶
All-in-one 包默认带以下依赖,不用额外配置:
DashScope SDK(通义千问系列模型)
MCP SDK(模型上下文协议)
Reactor Core、Jackson、SLF4J(基础框架)
额外功能的依赖¶
用其他模型或功能时,需要手动加对应依赖:
功能 |
依赖 |
Maven 坐标 |
|---|---|---|
OpenAI 模型 |
|
|
Google Gemini 模型 |
|
|
Anthropic 模型 |
|
|
Mem0 长期记忆 |
|
|
ReME 长期记忆 |
|
|
百炼 RAG |
|
|
Qdrant RAG |
|
|
PgVector RAG |
|
|
Dify RAG |
|
|
RAGFlow RAG |
|
|
HayStack RAG |
|
|
Elasticsearch RAG |
|
|
MySQL Session |
|
|
Redis Session |
|
|
PDF 处理 |
|
|
Word 处理 |
|
|
Nacos注册中心 |
|
示例:用 OpenAI 模型¶
<!-- 在 agentscope 基础上加 -->
<dependency>
<groupId>com.openai</groupId>
<artifactId>openai-java</artifactId>
</dependency>
示例:用 Qdrant RAG + PDF 处理¶
<!-- 在 agentscope 基础上加 -->
<dependency>
<groupId>io.qdrant</groupId>
<artifactId>client</artifactId>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
</dependency>
Studio 集成¶
接入 AgentScope Studio 做可视化调试,需要加这些依赖:
依赖 |
Maven 坐标 |
|---|---|
|
|
|
|
|
|
|
|
|
完整配置:
<!-- 在 agentscope 基础上加 -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</dependency>
<dependency>
<groupId>io.socket</groupId>
<artifactId>socket.io-client</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-api</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-exporter-otlp</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-reactor-3.1</artifactId>
</dependency>
Core + 扩展¶
需要精细控制依赖时,用 agentscope-core 配合扩展模块:
Maven:
<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope-core</artifactId>
<version>1.0.7</version>
</dependency>
Gradle:
implementation 'io.agentscope:agentscope-core:1.0.7'
扩展模块¶
长期记忆¶
模块 |
功能 |
Maven 坐标 |
|---|---|---|
Mem0 长期记忆 |
|
|
ReME 长期记忆 |
|
|
AutoContext 记忆 |
|
RAG¶
模块 |
功能 |
Maven 坐标 |
|---|---|---|
百炼 RAG |
|
|
简单 RAG (Qdrant, Milvus, PgVector, 内存存储, Elasticsearch) |
|
|
Dify RAG |
|
|
RAGFlow RAG |
|
|
HayStack RAG |
|
Session 存储¶
模块 |
功能 |
Maven 坐标 |
|---|---|---|
MySQL Session |
|
|
Redis Session |
|
多智能体协作¶
模块 |
功能 |
Maven 坐标 |
|---|---|---|
A2A 客户端 |
|
|
A2A 服务端 |
|
调度¶
模块 |
功能 |
Maven 坐标 |
|---|---|---|
调度通用模块 |
|
|
XXL-Job 调度 |
|
用户界面¶
模块 |
功能 |
Maven 坐标 |
|---|---|---|
Studio 集成 |
|
|
AG-UI 协议 |
|
扩展模块会自动带上所需的第三方依赖,不用手动加。
示例:Core + Mem0 扩展¶
<!-- 在 agentscope-core 基础上加 -->
<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope-extensions-mem0</artifactId>
<version>1.0.7</version>
</dependency>
框架集成¶
Spring Boot¶
<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope-spring-boot-starter</artifactId>
<version>1.0.7</version>
</dependency>
其他 Starter:
Starter |
功能 |
Maven 坐标 |
|---|---|---|
agentscope-a2a-spring-boot-starter |
A2A 集成 |
|
agentscope-agui-spring-boot-starter |
AG-UI 集成 |
|
Quarkus¶
<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope-quarkus-extension</artifactId>
<version>1.0.7</version>
</dependency>
Micronaut¶
<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope-micronaut-extension</artifactId>
<version>1.0.7</version>
</dependency>