基于 Java 的 LLM 应用开发框架,Agents-Flex beta.5 发布
Agents-Flex: 一个基于 Java 的 LLM(大语言模型)应用开发框架。
基本能力
- LLM 的访问能力
- Prompt、Prompt Template 定义加载的能力
- Function Calling 定义、调用和执行等能力
- 记忆的能力(Memory)
- Embedding
- Vector Store
- 文档处理
- 加载器(Loader)
- Http
- FileSystem
- 分割器(Splitter)
- 解析器(Parser)
- PoiParser
- PdfBoxParser
- 加载器(Loader)
- Agent
- LLM Agent
- IOAgent
- Chain 执行链
- SequentialChain 顺序执行链
- ParallelChain 并发(并行)执行链
- LoopChain 循环执行连
- ChainNode
- AgentNode Agent 执行节点
- EndNode 终点节点
- RouterNode 路由节点
- GroovyRouterNode Groovy 规则路由
- QLExpressRouterNode QLExpress 规则路由
- LLMRouterNode LLM 路由(由 AI 自行判断路由规则)
简单对话
使用 OpenAi 大语言模型:
@Test public void testChat() { OpenAiLlmConfig config = new OpenAiLlmConfig(); config.setApiKey("sk-rts5NF6n*******"); Llm llm = new OpenAiLlm(config); String response = llm.chat("请问你叫什么名字"); System.out.println(response); }
使用 “通义千问” 大语言模型:
@Test public void testChat() { QwenLlmConfig config = new QwenLlmConfig(); config.setApiKey("sk-28a6be3236****"); config.setModel("qwen-turbo"); Llm llm = new QwenLlm(config); String response = llm.chat("请问你叫什么名字"); System.out.println(response); }
使用 “讯飞星火” 大语言模型:
@Test public void testChat() { SparkLlmConfig config = new SparkLlmConfig(); config.setAppId("****"); config.setApiKey("****"); config.setApiSecret("****"); Llm llm = new SparkLlm(config); String response = llm.chat("请问你叫什么名字"); System.out.println(response); }
历史对话示例
public static void main(String[] args) { SparkLlmConfig config = new SparkLlmConfig(); config.setAppId("****"); config.setApiKey("****"); config.setApiSecret("****"); Llm llm = new SparkLlm(config); HistoriesPrompt prompt = new HistoriesPrompt(); System.out.println("您想问什么?"); Scanner scanner = new Scanner(System.in); String userInput = scanner.nextLine(); while (userInput != null) { prompt.addMessage(new HumanMessage(userInput)); llm.chatStream(prompt, (context, response) -> { System.out.println(">>>> " + response.getMessage().getContent()); }); userInput = scanner.nextLine(); } }
Function Calling
- 第一步:通过注解定义本地方法
public class WeatherUtil { @FunctionDef(name = "get_the_weather_info", description = "get the weather info") public static String getWeatherInfo( @FunctionParam(name = "city", description = "the city name") String name ) { //在这里,我们应该通过第三方接口调用 api 信息 return name + "的天气是阴转多云。 "; } }
- 第二步:通过 Prompt、Functions 传入给大模型,然后得到结果
public static void main(String[] args) { OpenAiLlmConfig config = new OpenAiLlmConfig(); config.setApiKey("sk-rts5NF6n*******"); OpenAiLlm llm = new OpenAiLlm(config); FunctionPrompt prompt = new FunctionPrompt("今天北京的天气怎么样", WeatherUtil.class); FunctionResultResponse response = llm.chat(prompt); Object result = response.invoke(); System.out.println(result); //"北京的天气是阴转多云。 " }
模块构成
开源地址:

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
vxe-table 4.7.17 已经发布,vue 表格解决方案
vxe-table 4.7.17 已经发布,vue 表格解决方案 此版本更新内容包括: table (v4保留兼容)调整 filterMethod 为 tableFilterMethod (v4保留兼容)调整 filterRemoteMethod 为 tableFilterRemoteMethod (v4保留兼容)调整 filterResetMethod 为 tableFilterResetMethod (v4保留兼容)调整 filterRecoverMethod 为 tableFilterRecoverMethod (v4保留兼容)调整 defaultFilterMethod为 defaultTableFilterMethod (v4保留兼容)调整 filterClassName 为 tableFilterClassName (v4保留兼容)调整 showFilterFooter 为 tableCellClassName (v4保留兼容)调整 cellClassName 为 tableFilterMethod (v4保留兼容)调整 cellStyle 为 tableCellStyle...
- 下一篇
DHorse v1.5.1 发布,基于 k8s 的发布平台
版本说明 新增特性 支持k8s的v1.30.x版本; 优化特性 优化回滚功能; 修复注册来源的回滚问题; 新增和修改应用时校验应用名; 升级kubernetes-client至v6.13.0; 调整部署明细表头展示; 升级指南 升级指南 DHorse介绍 DHorse是一个轻量级、简单易用的云应用管理平台,具有多云和多环境管理、应用管理和部署、服务治理等功能,使用该平台不需要了解容器和k8s的概念。 功能特性 简洁的操作界面 以应用为中心,屏蔽K8S的底层概念 支持SpringBoot、Vue、React、Nodejs、Html、Go、Flask、Django、Nuxt、Next、.Net应用部署 无需安装Docker即可构建镜像 无需安装Maven、Gradle、Node、Go、Python、Nodejs、.Net即可打包 支持多集群管理 支持多环境部署 支持日志收集 支持链路追踪 架构 预览 文档 Gitee:https://gitee.com/i512team/dhorse GitHub:https://github.com/512team/dhorse 操作手册:https:/...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- SpringBoot2初体验,简单认识spring boot2并且搭建基础工程
- Hadoop3单机部署,实现最简伪集群
- CentOS8编译安装MySQL8.0.19
- Docker安装Oracle12C,快速搭建Oracle学习环境
- Eclipse初始化配置,告别卡顿、闪退、编译时间过长
- Docker使用Oracle官方镜像安装(12C,18C,19C)
- CentOS7编译安装Cmake3.16.3,解决mysql等软件编译问题
- SpringBoot2整合MyBatis,连接MySql数据库做增删改查操作
- Windows10,CentOS7,CentOS8安装MongoDB4.0.16
- CentOS6,CentOS7官方镜像安装Oracle11G