关于 Solon Ai
Solon AI 是一个 Java AI 应用开发框架,整合 LLM 调用、RAG 知识库、MCP 协议与 Agent 编排。适合需要在 Java 生态中构建 AI 应用的开发者,兼容 Java 8 至 Java 25,可嵌入 SpringBoot、Vert.x、Quarkus 等框架。
主要功能
- 01ChatModel 统一接口,支持多种模型方言
- 02RAG 全链路:加载、切分、向量化与重排序
- 03MCP 服务端与客户端支持
- 04ReAct Agent 与 Team Agent 协作
- 05YAML 定义的 AI Flow 流程编排
适用场景
- 01在 Java 后端服务中集成 LLM 对话与工具调用
- 02构建基于文档的问答与 RAG 知识库应用
- 03开发多 Agent 协作的业务流程自动化
MCP 相关
该框架同时提供 MCP 服务端和客户端能力:服务端可通过注解暴露工具、资源和提示词,客户端可连接外部 MCP 服务。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。
工具
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
Solon-AI
Java 大模型(工具、技能)与 RAG、MCP、Agent(ReAct、Team)应用开发框架
克制、高效、开放
与 LangChain、LangGraph 和 LlamaIndex 属于同类型的开发框架
https://solon.noear.org/article/learn-solon-ai
语言:英文 | 中文
简介
Solon AI 是 Solon 项目的核心子项目之一。这是一个全场景 Java AI 开发框架,旨在深度融合大模型、RAG 知识库、MCP 协议和 Agent 协同编排。
- 全场景支持:与 Solon 生态完美适配,可无缝集成到 SpringBoot、Vert.X、Quarkus 等框架中。
- 多模型方言:通过 ChatModel 统一接口使用方言适配不同模型的差异(OpenAI、Gemini、Claude、Ollama、DeepSeek、Dashscope 等)。
- 图驱动编排:支持将 Agent 推理转化为可观测、可治理的计算流程图。
solon-ai 的嵌入示例(包括第三方框架):
- https://gitee.com/solonlab/solon-ai-mcp-embedded-examples
- https://gitcode.com/solonlab/solon-ai-mcp-embedded-examples
- https://github.com/solonlab/solon-ai-mcp-embedded-examples
可以开发哪些类型的应用?
- 通用自主 Agent(例如,Manus、OpenOperator)
- 智能助手与 RAG 知识库(例如,Dify、Coze)
- 多 Agent 协同编排(例如,AutoGPT、MetaGPT)
- 业务驱动的受控工作流(例如,AI 增强的钉钉/Lark 审批、SAP 智能模块)
- 智能文档处理与 ETL(例如,Instabase、Unstructured.io)
- 实时数据洞察与仪表板(例如,Text-to-SQL 应用)
- 自动化测试与质量保障(例如,GitHub Copilot Workspace)
- 低代码/可视化 AI 工作流平台(例如,LangFlow、Flowise)
- 更多……
Agent 合成项目示例(可直接用于生产或定制)
核心模块体验
- ChatModel(通用大模型调用接口)
支持同步和响应式调用,内置方言适配,并集成 Tool、Skill、ChatSession 等。
ChatModel chatModel = ChatModel.of("http://127.0.0.1:11434/api/chat")
.provider("ollama") //Need to specify vendor, used to identify interface style (also called dialect)
.model("qwen2.5:1.5b")
.defaultTalentAdd(new McpGatewayTalent())
.build();
// Synchronize the call and print the response message
AssistantMessage result = ChatchatModel.prompt("The weather in Hangzhou today?")
.options(op->op.toolAdd(new WeatherTools())) //Adding tools
.call()
.getMessage();
System.out.println(result);
// Stream call
chatModel.prompt("hello").stream(); //Flux<ChatEvent>, full semantic events
- Talents(Solon AI Talents)
Talent talent = new TalentDesc("order_expert")
.description("Order Assistant")
// Dynamic admission: Activated only when "order" is mentioned
.isSupported(prompt -> prompt.getUserMessageContent().contains("order"))
// Dynamic instructions: Inject different Sops depending on whether the user is a VIP or not
.instruction(prompt -> {
if ("VIP".equals(prompt.getMeta("user_level"))) {
return "This is a VIP customer, please call fast_track_tool first.";
}
return "Process the order inquiry according to the normal process.";
})
.toolAdd(new OrderTools());
chatModel.prompt("Where is my order from yesterday?")
.options(o->o.talentAdd(talent))
.call();
- RAG(知识库)
提供从 DocumentLoader、DocumentSplitter、EmbeddingModel 到 RerankingModel 的全链路支持。
//Building a Knowledge Warehouse
EmbeddingModel embeddingModel = EmbeddingModel.of(apiUrl).apiKey(apiKey).provider(provider).model(model).batchSize(10).build();
RerankingModel rerankingModel = RerankingModel.of(apiUrl).apiKey(apiKey).provider(provider).model(model).build();
InMemoryRepository repository = new InMemoryRepository(TestUtils.getEmbeddingModel()); //3.初始化知识库
repository.insert(new PdfLoader(pdfUri).load());
//retrieval
List<Document> docs = repository.search(query);
//You can rearrange it if you want
docs = rerankingModel.rerank(query, docs);
//Cue enhancement is
ChatMessage message = ChatMessage.ofUserAugment(query, docs);
//Calling the llm
chatModel.prompt(message)
.call();
- MCP(Model Context Protocol)
深度集成 MCP 协议(MCP_2025_06_18),支持跨平台共享工具、资源和提示词。
//server
@McpServerEndpoint(channel = McpChannel.STREAMABLE, mcpEndpoint = "/mcp")
public class MyMcpServer {
@ToolMapping(description = "Checking the weather")
public String getWeather(@Param(description = "city") String location) {
return "It's sunny, 25 degrees";
}
}
//client
McpClientProvider clientProvider = McpClientProvider.builder()
.channel(McpChannel.STREAMABLE)
.url("http://localhost:8080/mcp")
.build();
- Agent(基于计算流程图的 Agent 体验)
Solon AI Agent 将推理逻辑转化为由图驱动的协作流程,支持 ReAct 反思推理和多 Agent Team 协作。
//Reflective intelligent agent:
ReActAgent agent = ReActAgent.of(chatModel) // 或者用 SimpleAgent.of(chatModel)
.name("weather_expert")
.description("Check the weather and provide advice")
.defaultToolAdd(weatherTool) // Inject MCP or local tools
.build();
agent.prompt("What to wear in Beijing today?").call(); // Autocomplete: Think -> Call tool -> Observe -> Summarize
// Constructing a team agent: Automatically arranging member roles through protocols
TeamAgent team = TeamAgent.of(chatModel)
.name("marketing_team")
.protocol(TeamProtocols.HIERARCHICAL) // Hierarchical collaboration (6 preset protocols)
.agentAdd(copywriterAgent) // Copywriter expert
.agentAdd(illustratorAgent) // Illustrator expert
.build();
team.prompt("Plan a promotion scheme for deep-sea mineral water").call(); // Supervisor automatically decomposes tasks and assigns them to corresponding experts .defaultToolAdd(weatherTool) // Inject MCP or local tools
- Ai Flow(流程编排体验)
模拟 Dify 的低代码流程应用,并使用 YAML 编排 RAG、提示词增强、模型调用等环节。
id: demo1
layout:
- type: "start"
- task: "@VarInput"
meta:
message: "Solon 是谁开发的?"
- task: "@EmbeddingModel"
meta:
embeddingConfig: # "@type": "org.noear.solon.ai.embedding.EmbeddingConfig"
provider: "ollama"
model: "bge-m3"
apiUrl: "http://127.0.0.1:11434/api/embed"
- task: "@InMemoryRepository"
meta:
documentSources:
- "https://solon.noear.org/article/about?format=md"
splitPipeline:
- "org.noear.solon.ai.rag.splitter.RegexTextSplitter"
- "org.noear.solon.ai.rag.splitter.TokenSizeTextSplitter"
- task: "@ChatModel"
meta:
systemPrompt: "你是个知识库"
stream: false
chatConfig: # "@type": "org.noear.solon.ai.chat.ChatConfig"
provider: "ollama"
model: "qwen2.5:1.5b"
apiUrl: "http://127.0.0.1:11434/api/chat"
- task: "@ConsoleOutput"
# FlowEngine flowEngine = FlowEngine.newInstance();
# ...
# flowEngine.eval("demo1");
Solon 项目代码仓库
| 代码仓库 | 描述 |
|---|---|
| /opensolon/solon | Solon,主代码仓库 |
| /opensolon/solon-examples | Solon,官方网站配套示例代码仓库 |
| /opensolon/solon-ai | Solon AI,代码仓库 |
| /opensolon/solon-flow | Solon Flow,代码仓库 |
| /opensolon/solon-expression | Solon Expression,代码仓库 |
| /opensolon/solon-cloud | Solon Cloud,代码仓库 |
| /opensolon/solon-admin | Solon Admin,代码仓库 |
| /opensolon/solon-integration | Solon Integration,代码仓库 |
| /opensolon/solon-java17 | Solon Java17,代码仓库(基于 java17) |
| /opensolon/solon-java25 | Solon Java25,代码仓库(基于 java25) |
| /opensolon/soloncode | SolonCode(「Claude Code」的 Java8 实现版本),代码仓库 |
| /opensolon/solonclaw | SolonClaw(「OpenClaw」的 Java8 实现版本),代码仓库 |
| /opensolon/solon-maven-plugin | Solon Maven,插件代码仓库 |
| /opensolon/solon-gradle-plugin | Solon Gradle,插件代码仓库 |
| /opensolon/solon-idea-plugin | Solon Idea,插件代码仓库 |
| /opensolon/solon-vscode-plugin | Solon VsCode,插件代码仓库 |
常见问题
什么是 Solon AI?
Solon AI 是一个面向全场景的 Java AI 开发框架,深度集成了 LLM 大模型、RAG 知识库、MCP 协议以及 Agent 协作编排。它旨在使用 Java 构建可用于生产环境的 AI 应用。
Solon AI 与 LangChain 等 Python 框架有何不同?
Solon AI 专为 Java 开发者打造,与 Java 生态系统无缝集成:
主要区别:
- 原生 Java:完美适配 Solon、SpringBoot、Vert.X、Quarkus 生态系统
- 支持 JDK 8-25:兼容广泛的 Java 版本
- 多模型方言:通过统一接口自动适配模型差异
- 图驱动编排:将 Agent 推理转化为可观测的计算流图
Solon AI 提供哪些组件?
- ChatModel:通用大模型调用接口,支持工具、技能和 ChatSession
- Skills:动态准入和指令注入
- RAG:提供全链路支持(DocumentLoader、DocumentSplitter、EmbeddingModel、RerankingModel)
- MCP:深度集成 Model Context Protocol(MCP_2025_06_18)
- Agent:支持 ReAct 反思推理与 Team 协作
- Ai Flow:基于 YAML 的流程编排(类似 Dify 的低代码体验)
支持哪些大模型提供商?
通过方言适配支持:
- OpenAI、Gemini、Claude
- Ollama(本地模型)
- DeepSeek、Dashscope(阿里巴巴)
- 自定义端点
如何开始使用?
添加 Maven 依赖:
<dependency>
<groupId>org.noear</groupId>
<artifactId>solon-ai</artifactId>
</dependency>
基本用法:
ChatModel chatModel = ChatModel.of("http://127.0.0.1:11434/api/chat")
.provider("ollama")
.model("qwen2.5:1.5b")
.build();
AssistantMessage result = chatModel.prompt("Hello").call().getMessage();
如何添加工具?
chatModel.prompt("What's the weather?")
.options(op -> op.toolAdd(new WeatherTools()))
.call();
如何使用 RAG?
EmbeddingModel embeddingModel = EmbeddingModel.of(apiUrl)
.apiKey(apiKey).provider(provider).model(model).build();
InMemoryRepository repository = new InMemoryRepository(embeddingModel);
repository.insert(new PdfLoader(pdfUri).load());
List<Document> docs = repository.search(query);
ChatMessage message = ChatMessage.ofUserAugment(query, docs);
chatModel.prompt(message).call();
什么是 MCP 集成?
Solon AI 同时提供 MCP 服务端和客户端:
服务端:
@McpServerEndpoint(channel = McpChannel.STREAMABLE, mcpEndpoint = "/mcp")
public class MyMcpServer {
@ToolMapping(description = "Checking the weather")
public String getWeather(@Param(description = "city") String location) {
return "It's sunny, 25 degrees";
}
}
客户端:
McpClientProvider client = McpClientProvider.builder()
.channel(McpChannel.STREAMABLE)
.url("http://localhost:8080/mcp")
.build();
有哪些 Agent 模式?
- ReActAgent:通过“思考 → 调用 → 观察 → 总结”循环进行反思的 Agent
- TeamAgent:支持 6 种预设协议(HIERARCHICAL 等)的多 Agent 协作
在哪里可以获得帮助?
- 文档:solon.noear.org/article/learn-solon-ai
- 示例:solonlab/solon-ai-mcp-embedded-examples
- SolonCode:“Claude Code”的 Java 版本 - github.com/opensolon/soloncode
- SolonClaw:“OpenClaw”的 Java 版本 - github.com/opensolon/solonclaw
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。