Spring AI 1.0.0 M1 发布
Spring AI 1.0.0 Milestone 1 版本现已发布,具有以下新功能和改进:
ChatClient Fluent API
Fluent API 提供了构造 Prompt 的方法,然后将其作为输入传递给 AI 模型。用户可以使用ChatClient.Builder
对象创建一个ChatClient
。可以从 Spring Boot 自动配置中获取自动配置的ChatClient.Builder
对象,也可以通过编程方式创建一个。
示例:
@RestController class MyController { private final ChatClient chatClient; MyController(ChatClient.Builder chatClientBuilder) { this.chatClient = chatClientBuilder.build(); } @GetMapping("/ai") String generation(String userInput) { return this.chatClient.prompt() .user(userInput) .call() .content(); } }
user
方法设置 prompt 的用户文本。call
方法调用 AI 模型,提供各种重载以返回响应。在本例中,content
方法返回一个字符串。
还可以响应式调用 AI 模型(using WebClient under the covers),如下所示。
Flux<String> output = chatClient.prompt() .user("Tell me a joke") .stream() .content();
一个常见用例是从对 AI 模型的调用返回 JSON。使用entity
方法可以轻松实现这一点。
record ActorFilms(String actor, List<String> movies) { } ActorFilms actorFilms = chatClient.prompt() .user("Generate the filmography for a random actor.") .call() .entity(ActorFilms.class);
在@Configuration
类中创建时ChatClient
,可以指定默认值,例如系统文本。这种设计时和运行时的分离使得运行时代码最少,只需要属性占位符值。例如:
@Configuration class Config { @Bean ChatClient chatClient(ChatClient.Builder builder) { return builder.defaultSystem("You are a friendly chat bot that answers question in the voice of a {voice}") .build(); } } @RestController class AIController { private final ChatClient chatClient AIController(ChatClient chatClient) { this.chatClient = chatClient; } @GetMapping("/ai") Map<String, String> completion(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message, String voice) { return Map.of( "completion", chatClient.prompt() .system(sp -> sp.param("voice", voice)) .user(message) .call() .content()); } }
评估(Evaluation)
帮助解决 AI 幻觉问题。用户可以使用一个 AI 模型来评估另一个 AI 模型的响应是否准确。初步使用的是一个简单的RelevancyEvaluator
,但事实证明也非常有用,在 1.0 M2 中还会有所新增。
dataController.delete(); dataController.load(); String userText = "What is the purpose of Carina?"; ChatResponse response = ChatClient.builder(chatModel) .build().prompt() .advisors(new QuestionAnswerAdvisor(vectorStore, SearchRequest.defaults())) .user(userText) .call() .chatResponse(); var relevancyEvaluator = new RelevancyEvaluator(ChatClient.builder(chatModel)); EvaluationRequest evaluationRequest = new EvaluationRequest(userText, (List<Content>) response.getMetadata().get(QuestionAnswerAdvisor.RETRIEVED_DOCUMENTS), response); EvaluationResponse evaluationResponse = relevancyEvaluator.evaluate(evaluationRequest); assertTrue(evaluationResponse.isPass(), "Response is not relevant to the question");
新的 AI 模型
- Bedrock Anthropic Claude 3 - ben-gineer
- Watson AI - PabloSanchi
- OpenAI Speech - hemeda3
- Multi-modality support for OpenAI
- AWS Bedrock claude3
- MiniMax - mxsl-gr
- ZhiPu - mxsl-gr
- Azure Open AI image generation - bmoussaud
更新模型
- OpenAI - 支持 GPT4o 和多模态
- Google Gemini Pro 1.5 pro、flash 等
- Anthropic function calling
- Ollama 多模态支持
- 改进了 streaming function calling 支持 - Grogdunn
新的 Vector Stores
- Apache Cassandra - michaelsembwever
- Elastic Search - JM-Lab
- MongoDB Atlas - Kirbstomper
- SAP HanaDB - rahulmitt
Test Container 支持
Spring AI 提供 Testcontainer 支持,用于在测试中或通过 docker compose 启动向量存储数据库。
更多详情可查看官方博客。

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
Java 流媒体服务框架 ZLM4J 发布 1.0.8 版本
流媒体服务框架ZLM4J发布1.0.8版本 🔥🔥🔥ZLM4J 打造属于Java的流媒体生态框架,打通直播协议栈、视频监控协议栈、实时音视频协议栈,是您二开流媒体不二的选择。 🌟发布 1.0.8(已上传到中央仓库无需自己编译!) 开源地址:https://gitee.com/aizuda/zlm4j 使用文档:https://ux5phie02ut.feishu.cn/wiki/NA2ywJRY2ivALSkPfUycZFM4nUB <dependency> <groupId>com.aizuda</groupId> <artifactId>zlm4j</artifactId> <version>1.0.8</version> </dependency> 版本 1.0.8 更新日志: 拉取基于2024-05-29-master分支开发 发布jar到中央仓库 增加mk_proxy_player_create3,mk_proxy_player_create4函...
- 下一篇
vxe-table 4.7.1 已经发布,vue 表格解决方案
vxe-table 4.7.1 已经发布,vue 表格解决方案 此版本更新内容包括: 兼容按需加载 table 增加方法 setRow 详情查看:https://gitee.com/xuliangzhan_admin/vxe-table/releases/4.7.1
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- SpringBoot2整合Thymeleaf,官方推荐html解决方案
- MySQL8.0.19开启GTID主从同步CentOS8
- SpringBoot2更换Tomcat为Jetty,小型站点的福音
- Red5直播服务器,属于Java语言的直播服务器
- CentOS7,8上快速安装Gitea,搭建Git服务器
- CentOS6,7,8上安装Nginx,支持https2.0的开启
- CentOS8,CentOS7,CentOS6编译安装Redis5.0.7
- Jdk安装(Linux,MacOS,Windows),包含三大操作系统的最全安装
- SpringBoot2整合MyBatis,连接MySql数据库做增删改查操作
- SpringBoot2全家桶,快速入门学习开发网站教程