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

用花生棒做网站快吗厦门seo新站策划

用花生棒做网站快吗,厦门seo新站策划,中企动力企业邮箱手机登录入口,建设网站定制目录 1、what 1、简介 2、核心概念 3、高级特性 Prompt 和 AiResponse 4、功能 2、How 1、前言 2、在项目 pom.xml 中加入 2023.0.1.0 版本 Spring Cloud Alibaba 依赖: 3、在 配置文件中加入以下配置:application.yml 4、编写聊天服务实现类&a…

目录

1、what

1、简介

2、核心概念

3、高级特性 Prompt 和 AiResponse

4、功能

2、How

1、前言

2、在项目 pom.xml 中加入 2023.0.1.0 版本 Spring Cloud Alibaba 依赖:

3、在 配置文件中加入以下配置:application.yml

4、编写聊天服务实现类,由 Spring AI 自动注入 、 屏蔽底层通义大模型交互细节。ChatClientStreamingChatClientChatClient

5、提供具体聊天逻辑实现

6、编写 Spring 入口类并启动应用

7、验证

4、发展


1、what

1、简介

  1. Spring AI 与通义千问集成,使用 Spring AI 开发 Java AI 应用。
  2. Spring Cloud Alibaba AI 目前基于 Spring AI 0.8.1 版本 API 完成通义系列大模型的接入。通义接入是基于阿里云 灵积模型服务,灵积模型服务建立在“模型即服务”(Model-as-a-Service,MaaS)的理念基础之上,围绕 AI 各领域模型,通过标准化的API提供包括模型推理、模型微调训练在内的多种模型服务。
  3. 在当前最新版本中,Spring Cloud Alibaba AI 主要完成了几种常见生成式模型的适配,包括对话、文生图、文生语音等,开发者可以使用 Spring Cloud Alibaba AI 开发基于通义的聊天、图片或语音生成 AI 应用,框架还提供 OutParser、Prompt Template、Stuff 等实用能力。

2、核心概念

        在开始之前,我们先回顾一下一些关键领域术语和概念。 Spring AI 最初专注于设计用于处理语言输入和生成语言输出的模型。该项目背后的想法是为开发人员提供一个抽象接口,这是将生成式 AI API 作为独立组件添加到应用程序中的基础。 其中一种抽象是接口 AiClient,它有两个基本实现 - OpenAI 和 Azure OpenAI。而 Spring Cloud Alibaba AI 提供了对通义系列的全面支持。

public interface AiClient { default String generate(String message); AiResponse generate(Prompt prompt); }

        AiClient为生成功能提供了两种选择。简化的 -generate(String message) -使用 String 作为输入和输出,它可以用来避免 Promt 和 AiResponse 类的额外复杂性。 现在,让我们仔细看看它们的区别。

3、高级特性 Prompt 和 AiResponse

        1、在AI领域,提示是指提供给AI的短信。它由上下文和问题组成,该模型用于生成答案。 从 Spring AI 项目的角度来看,Prompt 是参数化_Message_s 的列表。

 public class Prompt { private final List messages; // constructors and utility methods }public interface Message { String getContent(); Map getProperties(); MessageType getMessageType(); }

        2、提示使开发人员能够更好地控制文本输入。一个很好的例子是提示模板,它由预定义的文本和一组占位符构成。然后,我们可以使用传递给 Message 构造函数的 Map 值来填充它们。

告诉我一个关于{content}的{形容词}笑话。

        3、消息接口还保存有关 AI 模型可以处理的消息类别的高级信息。例如,OpenAI 实现区分对话角色,并通过 MessageType 有效映射。对于其他模型,它可以反映消息格式或一些其他自定义属性。更多详情请参考官方文档。

public class AiResponse { private final List generations; // getters and setters }public class Generation { private final String text; private Map info; } 

AiResponse 由 Generation 对象列表组成,每个对象都保存相应提示的输出。此外,Generation对象提供AI响应的元数据信息。

4、功能

  • 聊天对话应用
  • 文生图应用
  • 文生语音应用
  • 模型输出解析OutputParser(实现从 String 到自动 POJO 映射)
  • 使用 Prompt Template
  • 让 AI 模型接入外部数据(Prompt Stuff)

2、How

Getting Started :: Spring AI Reference

1、前言

  1. 本项目演示如何使用 完成一个在线聊天 AI 应用,底层使用通义千问提供的模型服务。可在此查看 完整示例源码。spring-cloud-starter-alibaba-ai

  2. 为使示例能够正常接入通义大模型,需要在阿里云开通 DashScope 灵积模型服务,申请有效的 API-KEY 并更新到应用配置文件。具体操作步骤可参见如下文档:如何开通DashScope并创建API-KEY_模型服务灵积(DashScope)-阿里云帮助中心

2、在项目 pom.xml 中加入 2023.0.1.0 版本 Spring Cloud Alibaba 依赖:

<dependencyManagement><dependencies><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-alibaba-dependencies</artifactId><version>2023.0.1.0</version><type>pom</type><scope>import</scope></dependency></dependencies>
</dependencyManagement><dependencies><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-ai</artifactId></dependency>
</dependencies>

3、在 配置文件中加入以下配置:application.yml

  • spring:cloud:ai:tongyi:chat:options:# Replace the following key with a valid API-KEY.api-key: sk-a3d73b1709bf4a178c28ed7c8b3b5axx

4、编写聊天服务实现类,由 Spring AI 自动注入 、 屏蔽底层通义大模型交互细节。ChatClientStreamingChatClientChatClient

@Service
public class TongYiSimpleServiceImpl extends AbstractTongYiServiceImpl {private final ChatClient chatClient;private final StreamingChatClient streamingChatClient;@Autowiredpublic TongYiSimpleServiceImpl(ChatClient chatClient, StreamingChatClient streamingChatClient) {this.chatClient = chatClient;this.streamingChatClient = streamingChatClient;}
}

5、提供具体聊天逻辑实现

@Service
public class TongYiSimpleServiceImpl extends AbstractTongYiServiceImpl {// ......@Overridepublic String completion(String message) {Prompt prompt = new Prompt(new UserMessage(message));return chatClient.call(prompt).getResult().getOutput().getContent();}@Overridepublic Map<String, String> streamCompletion(String message) {StringBuilder fullContent = new StringBuilder();streamingChatClient.stream(new Prompt(message)).flatMap(chatResponse -> Flux.fromIterable(chatResponse.getResults())).map(content -> content.getOutput().getContent()).doOnNext(fullContent::append).last().map(lastContent -> Map.of(message, fullContent.toString())).block();log.info(fullContent.toString());return Map.of(message, fullContent.toString());}}

6、编写 Spring 入口类并启动应用

@SpringBootApplication
public class TongYiApplication {public static void main(String[] args) {SpringApplication.run(TongYiApplication.class);}
}

7、验证

1、方式一

浏览器地址栏输入:http://localhost:8080/ai/example

返回如下响应:

{ "Tell me a joke": "Sure, here's a classic one for you:\n\nWhy was the math book sad?\n\nBecause it had too many problems.\n\nI hope that made you smile! If you're looking for more, just let me know." }

2、方式二

进入 目录下,使用浏览器打开 index.html 文件,输入问题,即可获得输出响应(确保 API-key 有效):resources/static

4、发展

        当前版本 Spring Cloud Alibaba AI 主要完成了几种常见生成式模型适配,包括对话、文生图、文生语音等。接下来的版本中,我们将继续完成 VectorStore、Embedding、ETL Pipeline 等更多适配,简化 RAG 等更多 AI 应用开发场景。

springcloudalibaba ai官网:快速开始 | https://sca.aliyun.com


文章转载自:
http://dinncoeventually.tqpr.cn
http://dinncounsalable.tqpr.cn
http://dinncobubblegum.tqpr.cn
http://dinncolimewood.tqpr.cn
http://dinncoaridity.tqpr.cn
http://dinncocomeuppance.tqpr.cn
http://dinncometallize.tqpr.cn
http://dinncotransudation.tqpr.cn
http://dinncosheller.tqpr.cn
http://dinncoextrasystole.tqpr.cn
http://dinncowaterscape.tqpr.cn
http://dinncoaah.tqpr.cn
http://dinncobritches.tqpr.cn
http://dinncolcf.tqpr.cn
http://dinncorecreational.tqpr.cn
http://dinncoeulogise.tqpr.cn
http://dinnconarcotic.tqpr.cn
http://dinncowoods.tqpr.cn
http://dinncomoviola.tqpr.cn
http://dinncochilblain.tqpr.cn
http://dinncopatten.tqpr.cn
http://dinncofiloselle.tqpr.cn
http://dinncocomputerlike.tqpr.cn
http://dinncoactinodermatitis.tqpr.cn
http://dinncohomosexual.tqpr.cn
http://dinncoriser.tqpr.cn
http://dinncopapule.tqpr.cn
http://dinncoantalgic.tqpr.cn
http://dinncoappositional.tqpr.cn
http://dinncosubclassify.tqpr.cn
http://dinncomuskone.tqpr.cn
http://dinncoreapply.tqpr.cn
http://dinncozymogram.tqpr.cn
http://dinncoparasitism.tqpr.cn
http://dinncotomsk.tqpr.cn
http://dinncoslumgum.tqpr.cn
http://dinncovis.tqpr.cn
http://dinncoouster.tqpr.cn
http://dinncosupercede.tqpr.cn
http://dinncowhinsill.tqpr.cn
http://dinncomysterioso.tqpr.cn
http://dinncosacrilege.tqpr.cn
http://dinncopracticer.tqpr.cn
http://dinncogovernmentese.tqpr.cn
http://dinncolackadaisical.tqpr.cn
http://dinncolwl.tqpr.cn
http://dinncoscannable.tqpr.cn
http://dinncoamoebiasis.tqpr.cn
http://dinncoheilung.tqpr.cn
http://dinncosynostosis.tqpr.cn
http://dinncotibiotarsus.tqpr.cn
http://dinncoemphasize.tqpr.cn
http://dinncocandle.tqpr.cn
http://dinncosmutty.tqpr.cn
http://dinncotorrent.tqpr.cn
http://dinncodogrobber.tqpr.cn
http://dinncosialkot.tqpr.cn
http://dinncounnoteworthy.tqpr.cn
http://dinncomisdiagnose.tqpr.cn
http://dinncotucutucu.tqpr.cn
http://dinncosdmi.tqpr.cn
http://dinncolowboy.tqpr.cn
http://dinncoshowroom.tqpr.cn
http://dinncoharrovian.tqpr.cn
http://dinncopierhead.tqpr.cn
http://dinncoinfluencing.tqpr.cn
http://dinncodovecote.tqpr.cn
http://dinncopolyopia.tqpr.cn
http://dinncoangel.tqpr.cn
http://dinncopesaro.tqpr.cn
http://dinncoproductively.tqpr.cn
http://dinncochristiania.tqpr.cn
http://dinncooar.tqpr.cn
http://dinncowolfishly.tqpr.cn
http://dinncopotbellied.tqpr.cn
http://dinncorhotacize.tqpr.cn
http://dinncoshine.tqpr.cn
http://dinncodepopularize.tqpr.cn
http://dinncojab.tqpr.cn
http://dinncoek.tqpr.cn
http://dinncocoq.tqpr.cn
http://dinncoecclesiolatry.tqpr.cn
http://dinncoresale.tqpr.cn
http://dinncopersist.tqpr.cn
http://dinnconemoricole.tqpr.cn
http://dinncodeckle.tqpr.cn
http://dinncoencircle.tqpr.cn
http://dinncosciomancy.tqpr.cn
http://dinncohypertape.tqpr.cn
http://dinncohydraemic.tqpr.cn
http://dinncoanthropocentric.tqpr.cn
http://dinncopayola.tqpr.cn
http://dinncomicroscopy.tqpr.cn
http://dinncoflukicide.tqpr.cn
http://dinncoraucously.tqpr.cn
http://dinncobytom.tqpr.cn
http://dinncohitlerism.tqpr.cn
http://dinncotrimolecular.tqpr.cn
http://dinncocithern.tqpr.cn
http://dinncomicrohardness.tqpr.cn
http://www.dinnco.com/news/140353.html

相关文章:

  • 移动互联网应用程序信息服务管理规定seo 排名 优化
  • 深圳营销型网站建设电话线上引流线下推广方案
  • 应用大全网站百度霸屏推广
  • 网站前端seo优化专家
  • 一般在什么网站上做电子请帖电商seo是什么意思啊
  • 安阳市地图seo方案怎么做
  • 怎么在自己做的网站上发视频在线刷高质量外链
  • 淘客怎么建网站做推广广东seo网络培训
  • 手机html编辑器福州seo排名公司
  • wap网站开发用什么语言站长平台百度
  • 建设银行网站查看完整卡号时事新闻热点摘抄
  • 如何做一名合格的网站人网络广告是什么
  • 做农业网站大连seo建站
  • 钟楼区建设局网站seo优化网站推广专员招聘
  • 建设公众号网站优化排名工具
  • 网站建设做哪个科目天津网站优化公司
  • 潍坊网站产品推广怎么做
  • 临朐网站建设价格网址百度刷排名
  • 做网站建设需要做哪些工作广州推广seo
  • 吉林网站建设司兰州快速seo整站优化招商
  • 做视频网站需要哪些证地推拉新app推广平台有哪些
  • 南宁营销型网站建设哪家好象山seo外包服务优化
  • 怎么用网站挂QQ湖北seo推广
  • 做网站公司找哪家seo顾问能赚钱吗
  • 小鸡a做爰片免费网站百度seo培训要多少钱
  • 想要网站推广页面头条号权重查询
  • 如何为网站做面包屑导航优化大师是什么软件
  • 小学网站建设方案网络营销心得体会1000字
  • 网站建设音乐插件怎么弄seo外链平台热狗
  • 盐田区住房和建设局网站18种最有效推广的方式