Cover image

Java ai (智能体) 全场景应用开发框架( llm , Funktionsanruf , RAG , Einbettung , Umlehnung , Fluss , MCP -Server , MCP -Client )。同时兼容 Java8 ~ Java24。

3 years

Works with Finder

11

Github Watches

2

Github Forks

11

Github Stars


Solon-AI

Java AI(智能体) 全场景应用开发框架(支持已知 AI 开发的各种能力)
【基于 Solon 应用开发框架构建】

https://solon.noear.org/article/learn-solon-ai

Maven Apache 2 jdk-8 jdk-11 jdk-17 jdk-21 jdk-23
gitee star github star gitcode star


简介

面向全场景的 Java AI 应用开发框架(支持已知 AI 开发的各种能力)。是 Solon 项目的一部分。也可嵌入到 SpringBoot2、jFinal、Vert.x 等框架中使用。

其中 solon-mcp 的嵌入示例:

主要接口体验示例

  • ChatModel(通用接口,基于方言适配实现不同提供商与模型的扩展)
ChatModel chatModel = ChatModel.of("http://127.0.0.1:11434/api/chat")
                .provider("ollama") //需要指定供应商,用于识别接口风格(也称为方言)
                .model("qwen2.5:1.5b")
                .build();
//同步调用,并打印响应消息
System.out.println(chatModel.prompt("hello").call().getMessage());

//响应式调用
chatModel.prompt("hello").stream(); //Publisher<ChatResponse>
  • Function Calling(或者 Tool Calling)
//可以添加默认工具(即所有请求有产),或请求时工具
chatModel.prompt("今天杭州的天气情况?")
    .options(op->op.toolsAdd(new FunctionTools()))
    .call();
  • Vision(多媒体感知)
chatModel.prompt(ChatMessage.ofUser("这图里有方块吗?", Image.ofUrl(imageUrl)))
    .call();
  • RAG(EmbeddingModel,Repository,DocumentLoader,RerankingModel)
//构建知识库
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());

//检索
List<Document> docs = repository.search(query);

//如果有需要,可以重排一下
docs = rerankingModel.rerank(query, docs);

//提示语增强是
ChatMessage message = ChatMessage.augment(query, docs);

//调用大模型
chatModel.prompt(message) 
    .call();
  • Ai Flow(模拟实现 Dify 的流程应用)
id: demo1
layout:
  - title: "开始"
    type: start
  - title: "文件提取"
    meta.input: "file" # 可视界面的配置(通过元信息表示)
    meta.output: "fileTxt"
    task: @FileLoaderCom
  - title: "LLM"
    meta.model: "Qwen/Qwen2.5-72B-Instruct" # 可视界面的配置(通过元信息表示)
    meta.input: "fileTxt"
    meta.messages:
      - role: system
        content: "#角色\n你是一个数据专家,删除数据的格式整理和转换\n\n#上下文\n${fileTxt}\n\n#任务\n提取csv格式的字符串"
    task: @ChatModelCom
  - title: "参数提取器"
    meta.model: "Qwen/Qwen2.5-72B-Instruct" # 可视界面的配置(通过元信息表示)
    meta.output: "csvData"
    task: @ParamExtractionCom
  - title: "执行代码"
    meta.input: "csvData"
    task: |
      import com.demo.DataUtils;
      
      String json = DataUtils.csvToJson(node.meta().get("meta.input"));  //转为 json 数据
      String echatCode = DataUtils.jsonAsEchatCode(json); //转为 echat 图表代码
      context.result = echatCode; //做为结果返回
  - title: "结束"
    type: end

# FlowEngine flowEngine = FlowEngine.newInstance();
# ...
# flowEngine.eval("demo1");
  • MCP server(支持多端点)
//组件方式构建
@McpServerEndpoint(name="mcp-case1", sseEndpoint = "/case1/sse") 
public class McpServerTool {
    @ToolMapping(description = "查询天气预报")
    public String getWeather(@ToolParam(description = "城市位置") String location) {
        return "晴,14度";
    }
}

//原生 java 方式构建
McpServerEndpointProvider serverEndpoint = McpServerEndpointProvider.builder()
        .name("mcp-case2")
        .sseEndpoint("/case2/sse")
        .build();

serverEndpoint.addTool(new MethodToolProvider(new McpServerTool()));
serverEndpoint.postStart();
  • MCP client
McpClientToolProvider clientToolProvider = McpClientToolProvider.builder()
                .apiUrl("http://localhost:8080/case1/sse")
                .build();

String rst = clientToolProvider.callToolAsText("getWeather", Map.of("location", "杭州"));

Solon 项目相关代码仓库

代码仓库 描述
https://gitee.com/opensolon/solon Solon ,主代码仓库
https://gitee.com/opensolon/solon-examples Solon ,官网配套示例代码仓库
https://gitee.com/opensolon/solon-ai Solon Ai ,代码仓库
https://gitee.com/opensolon/solon-flow Solon Flow ,代码仓库
https://gitee.com/opensolon/solon-cloud Solon Cloud ,代码仓库
https://gitee.com/opensolon/solon-admin Solon Admin ,代码仓库
https://gitee.com/opensolon/solon-jakarta Solon Jakarta ,代码仓库(base java21)
https://gitee.com/opensolon/solon-integration Solon Integration ,代码仓库
https://gitee.com/opensolon/solon-gradle-plugin Solon Gradle ,插件代码仓库
https://gitee.com/opensolon/solon-idea-plugin Solon Idea ,插件代码仓库
https://gitee.com/opensolon/solon-vscode-plugin Solon VsCode ,插件代码仓库
https://gitee.com/dromara/solon-plugins Solon 第三方扩展插件代码仓库

相关推荐

  • av
  • Führen Sie mühelos LLM -Backends, APIs, Frontends und Dienste mit einem Befehl aus.

  • WangRongsheng
  • 🧑‍🚀 全世界最好的 llm 资料总结(数据处理、模型训练、模型部署、 O1 模型、 MCP 、小语言模型、视觉语言模型) | Zusammenfassung der weltbesten LLM -Ressourcen.

  • 1Panel-dev
  • 🔥 1Panel bietet eine intuitive Weboberfläche und einen MCP -Server, um Websites, Dateien, Container, Datenbanken und LLMs auf einem Linux -Server zu verwalten.

  • rulego
  • ⛓️Rugele ist ein leichter, leistungsstarker, leistungsstarker, eingebetteter Komponenten-Orchestrierungsregel-Motor-Rahmen für GO.

  • hkr04
  • Leichtes C ++ MCP (Modellkontextprotokoll) SDK

  • sigoden
  • Erstellen Sie einfach LLM -Tools und -Argarten mit einfachen Bash/JavaScript/Python -Funktionen.

  • RockChinQ
  • 😎简单易用、🧩丰富生态 - 大模型原生即时通信机器人平台 | 适配 qq / 微信(企业微信、个人微信) / 飞书 / 钉钉 / diskord / telegram / slack 等平台 | 支持 Chatgpt 、 Deepseek 、 Diffy 、 Claude 、 Gemini 、 xai 、 ppio 、 、 ulama 、 lm Studio 、阿里云百炼、火山方舟、 siliconflow 、 qwen 、 mondshot 、 chatglm 、 sillytraven 、 mcp 等 llm 的机器人 / agent | LLM-basierte Instant Messaging Bots-Plattform, unterstützt Zwietracht, Telegramm, Wechat, Lark, Dingtalk, QQ, Slack

  • modelscope
  • Bauen Sie LLM-Multi-Agent-Anwendungen auf einfachere Weise auf.

  • dmayboroda
  • On-Premise-Konversationslappen mit konfigurierbaren Behältern

    Reviews

    3.2 (5)
    Avatar
    user_vhzH69lz
    2025-04-26

    Solon-ai by opensolon is an incredible tool for anyone looking to leverage artificial intelligence in their projects. It's user-friendly and offers powerful features that make AI accessible to both beginners and experts. Highly recommend it for anyone interested in AI!

    Avatar
    user_Ym8KxWq4
    2025-04-26

    Solon-AI by opensolon is a remarkable tool that has impressed me with its efficiency and user-friendly interface. This AI-driven platform simplifies complex tasks, making it perfect for professionals looking to streamline their workflow. Highly recommend exploring Solon-AI for anyone in need of an innovative solution to enhance productivity!

    Avatar
    user_QoURB2nr
    2025-04-26

    Solon-AI by OpenSolon is an impressive tool that integrates seamlessly with the MCP application. Its functionality is robust, and it offers a user-friendly interface that simplifies complex tasks. The welcome information provided is clear and guides users effectively through the setup process. Highly recommend for anyone looking to enhance their workflow with AI capabilities!

    Avatar
    user_03Xi7EoW
    2025-04-26

    Solon-ai by opensolon is an impressive application that has transformed my workflow through its intuitive design and effective solutions. It offers seamless integration and user-friendly features, making it ideal for enhancing productivity. The advanced capabilities of Solon-ai have significantly improved my efficiency and I highly recommend it to anyone looking for a reliable AI application.

    Avatar
    user_Vfco8Tcc
    2025-04-26

    Solon-AI by OpenSolon is a remarkable tool that seamlessly integrates into various workflows. Its user-friendly interface and robust functionalities have significantly improved my productivity. The support from the OpenSolon team is fantastic, making this AI solution an indispensable asset for anyone in need of advanced, efficient automation. Highly recommend giving it a try!