当前位置: 首页 > news >正文

天津网站建设怎么样wordpress插件支付宝积分

天津网站建设怎么样,wordpress插件支付宝积分,住房和城乡建设部官网证件查询,wordpress首饰商城系统Spring AI 来了#xff0c;打造Java生态大模型应用开发新框架#xff01; Spring AI 开发框架设计理念Spring AI 主要功能特性如下 Spring AI 应用开发案例案例一#xff1a;基于大模型的对话应用开发案例二#xff1a;RAG 检索增强应用开发案例三#xff1a;Function Cal… Spring AI 来了打造Java生态大模型应用开发新框架 Spring AI 开发框架设计理念Spring AI 主要功能特性如下 Spring AI 应用开发案例案例一基于大模型的对话应用开发案例二RAG 检索增强应用开发案例三Function Calling Agent 应用开发 尽管 Python 长期主导 AI 大模型应用开发领域但 Java 并未熄火Spring AI 来了正式告别实验期迈向广泛应用新阶段这意味着 Spring 生态体系的广大开发者迎来 AI 大模型应用开发的新里程。 Spring AI 开发框架设计理念 Spring AI 是一个 AI 工程师的应用框架它提供了一个友好的 API 和开发 AI 应用的抽象旨在简化 AI 大模型应用的开发工作。 Spring AI 吸取了知名 Python 项目的精髓比如LangChain 和 LlamaIndex。Spring AI 是基于这样一个理念创立的未来的 AI 大模型应用将不仅限于 Python 开发者而且会普及到多种编程语言中。Spring AI 的核心是提供了开发 AI 大模型应用所需的基本抽象模型这些抽象拥有多种实现方式使得开发者可以用很少的代码改动就能实现组件的轻松替换。 Spring AI 主要功能特性如下 第一、 对主流 AI 大模型供应商提供了支持比如OpenAI、Microsoft、Amazon、Google HuggingFace、Ollama、MistralAI 支持目前对国内大模型支持还不友好。第二、 支持 AI 大模型类型包括聊天、文本到图像、文本到声音比如OpenAI with DALL-E、StabilityAI 等。第三、 支持主流的 Embedding Model 和向量数据库比如Azure Vector Search、Chroma、Milvus、Neo4j、PostgreSQL/PGVector、PineCone、Redis 等。第四、 把 AI 大模型输出映射到简单的 Java 对象POJOs上。第五、 支持了函数调用Function calling功能。第六、 为数据工程提供 ETL数据抽取、转换和加载框架。第七、 支持 Spring Boot 自动配置和快速启动便于运行 AI 模型和管理向量库。 当前Spring AI 最新版本为 0.8.1具体使用也比较简单符合 Java 开发者的开发习惯。 更详细的特性在这里https://spring.io/projects/spring-ai Spring AI 应用开发案例 接下来我们来看3个具体的开发案例Spring AI 最新版本为 0.8.1具体使用也比较简单符合 Java 开发者的开发习惯。 案例一基于大模型的对话应用开发 package org.springframework.ai.openai.samples.helloworld.simple;import org.springframework.ai.chat.ChatClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController;import java.util.Map;RestController public class SimpleAiController {private final ChatClient chatClient;Autowiredpublic SimpleAiController(ChatClient chatClient) {this.chatClient chatClient;}GetMapping(/ai/simple)public MapString, String completion(RequestParam(value message, defaultValue Tell me a joke) String message) {return Map.of(generation, chatClient.call(message));} }案例二RAG 检索增强应用开发 package org.springframework.samples.ai.azure.openai.rag;import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.ai.client.AiClient; import org.springframework.ai.client.AiResponse; import org.springframework.ai.client.Generation; import org.springframework.ai.document.Document; import org.springframework.ai.embedding.EmbeddingClient; import org.springframework.ai.loader.impl.JsonLoader; import org.springframework.ai.prompt.Prompt; import org.springframework.ai.prompt.SystemPromptTemplate; import org.springframework.ai.prompt.messages.Message; import org.springframework.ai.prompt.messages.UserMessage; import org.springframework.ai.retriever.impl.VectorStoreRetriever; import org.springframework.ai.vectorstore.VectorStore; import org.springframework.ai.vectorstore.impl.InMemoryVectorStore; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.io.Resource;import java.util.List; import java.util.Map; import java.util.stream.Collectors;public class RagService {private static final Logger logger LoggerFactory.getLogger(RagService.class);Value(classpath:/data/bikes.json)private Resource bikesResource;Value(classpath:/prompts/system-qa.st)private Resource systemBikePrompt;private final AiClient aiClient;private final EmbeddingClient embeddingClient;public RagService(AiClient aiClient, EmbeddingClient embeddingClient) {this.aiClient aiClient;this.embeddingClient embeddingClient;}public Generation retrieve(String message) {// Step 1 - Load JSON document as Documentslogger.info(Loading JSON as Documents);JsonLoader jsonLoader new JsonLoader(bikesResource,name, price, shortDescription, description);ListDocument documents jsonLoader.load();logger.info(Loading JSON as Documents);// Step 2 - Create embeddings and save to vector storelogger.info(Creating Embeddings...);VectorStore vectorStore new InMemoryVectorStore(embeddingClient);vectorStore.add(documents);logger.info(Embeddings created.);// Step 3 retrieve related documents to queryVectorStoreRetriever vectorStoreRetriever new VectorStoreRetriever(vectorStore);logger.info(Retrieving relevant documents);ListDocument similarDocuments vectorStoreRetriever.retrieve(message);logger.info(String.format(Found %s relevant documents., similarDocuments.size()));// Step 4 Embed documents into SystemMessage with the system-qa.st prompt templateMessage systemMessage getSystemMessage(similarDocuments);UserMessage userMessage new UserMessage(message);// Step 4 - Ask the AI modellogger.info(Asking AI model to reply to question.);Prompt prompt new Prompt(List.of(systemMessage, userMessage));logger.info(prompt.toString());AiResponse response aiClient.generate(prompt);logger.info(AI responded.);logger.info(response.getGeneration().toString());return response.getGeneration();}private Message getSystemMessage(ListDocument similarDocuments) {String documents similarDocuments.stream().map(entry - entry.getContent()).collect(Collectors.joining(\n));SystemPromptTemplate systemPromptTemplate new SystemPromptTemplate(systemBikePrompt);Message systemMessage systemPromptTemplate.createMessage(Map.of(documents, documents));return systemMessage;} }案例三Function Calling Agent 应用开发 Spring AI Function Calling 函数调用工作流程如下图所示包含了 Prompt 提示词、大模型、业务服务 API、回调、大模型响应等核心模块。
http://www.zqtcl.cn/news/164988/

相关文章:

  • 医院网站建设投标要求wordpress文章的表是什么
  • 怎么做网站后门海外营销推广
  • 网站建设中英版网站要做手机版怎么做的
  • 安徽网站开发与维护专业阜阳建设部网站
  • 山东省住房和建设厅网站网站优化大计
  • 大良建网站织梦建设两个网站 视频
  • 用html5制作个人网站航空港建设局网站
  • 祥云平台建站网站备案通过什么可以备案
  • 免费建造网站系统php和wordpress
  • 九脉堂是做网站的网站权重不稳定
  • 网站怎么做来流量门户网站的发布特点
  • 网站设计相似侵权吗免费游戏网站建设
  • 湖北长安建设网站制作一个网站的步骤是什么
  • js网站开发成都房地产最新政策
  • 天津网站制作维护无锡网络推广外包
  • 国外中文网站排行娱乐新闻做的好的网站
  • 零食网站建设需求分析规划设计网址
  • 建立网站备案的法律依据wordpress 招商系统
  • 建设银行全球门户网站网站建设技能
  • 提供企业网站建设价格10元一年的虚拟主机
  • 塔城建设局网站电子商务网站建设方案目录
  • 网站容易被百度收录个人建购物网站怎么备案
  • 中文网站什么意思wordpress电脑访问不了
  • 杨家坪网站建设企业生产erp软件公司
  • 网站模块设计软件河北seo优化_网络建设营销_网站推广服务 - 河北邢台seo
  • 陕西正天建设有限公司网站西安专业网页制作
  • 网站建设工作室介绍范文seo网站排名的软件
  • 上海网站建设-网建知识可编辑个人简历模板
  • 北京新鸿儒做的网站shopify做国内网站
  • 网站怎样做百度推广机关门户网站建设要求