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

有做lol直播网站有哪些百度客户端下载

有做lol直播网站有哪些,百度客户端下载,如何查看网站的空间商,学习java网站开发5.Message 消息 在Spring AI提供的接口中,每条信息的角色总共分为三类: SystemMessage:系统限制信息,这种信息在对话中的权重很大,AI会优先依据SystemMessage里的内容进行回复; UserMessage:用…

5.Message 消息

在Spring AI提供的接口中,每条信息的角色总共分为三类:

  • SystemMessage:系统限制信息,这种信息在对话中的权重很大,AI会优先依据SystemMessage里的内容进行回复;

  • UserMessage:用于表示用户发送的消息。它可能包含与用户消息相关的属性和方法。

  • AssistantMessage:AI回复信息

在这里插入图片描述

这些Message均实现了一个Message接口,如上图。

AbstractMessage提供了对Message接口的抽象实现,SystemMessageUserMessageAssistantMessage等均继承了AbstractMessage,是Message的具体实现。FunctionMessage,这类信息用于AI的函数调用。

ChatMessage是Message的扩展实现,用于创建其它大语言模型需要的Message。

5.1.对话上下文

通过单一的输入输出方式进行调用时,无法让AI具有记忆力, 第三句就不记得第一句的内容了

AssistantMessage assistantMessage = chatResponse.getResult().getOutput();

AssistantMessage 是 AI 回复的信息, 只需要使用一个List存储这些Message对象,并将这些Message对象一并发送给AI,AI拿到这些Message后,会结合这些Message里的内容进行回复。

不过,根据AI的计费规则,你的消息队列越长,单次问询需要的费用就会越高,因此我们需要对这个消息列表的长度进行限制。

代码实现

    // 历史消息列表static List<Message> historyMessage = new ArrayList<>();// 历史消息列表的最大长度static int maxLen = 10;@GetMapping("/chat/chatContext")public String chatContext( String message ) {// 用户输入的文本是UserMessagehistoryMessage.add(new UserMessage(message));// 发给AI前对历史消息对列的长度进行检查if(historyMessage.size() > maxLen){historyMessage = historyMessage.subList(historyMessage.size()-maxLen-1,historyMessage.size());}// 获取AssistantMessageChatResponse chatResponse = chatClient.call(new Prompt(historyMessage));AssistantMessage assistantMessage = chatResponse.getResult().getOutput();// 将AI回复的消息放到历史消息列表中historyMessage.add(assistantMessage);return assistantMessage.getContent();}

对话测试

###
GET http://localhost:8080/chat/chatContext?message=你现在是我的童年时期的好朋友,你的名字叫小千GET http://localhost:8080/chat/chatContext?message=我们一起在北京长大GET http://localhost:8080/chat/chatContext?message=现在我在东北,你还在北京GET http://localhost:8080/chat/chatContext?message=我们现在都30多岁了GET http://localhost:8080/chat/chatContext?message=你的名字叫什么

5.2.角色设置

角色设置功能来自于“提示词工程”的理论基础的。目前,提示工程已成为一个较新的学科,应用于开发和优化提示词(Prompt),帮助用户有效地将语言模型用于各种应用场景和研究领域。掌握了提示工程相关技能将有助于用户更好地了解大型语言模型的能力和局限性。研究人员可利用提示工程来提高大语言模型处理复杂任务场景的能力,如问答和算术推理能力。开发人员可通过提示工程设计和研发出强大的技术,实现和大语言模型或其他生态工具的高效接轨。

详情见:https://www.promptingguide.ai/zh/introduction

在GitHub上,也有相关的仓库分享一些有趣的提示词来让我们使用ChatGPT时更加高效。

  • 国外版:https://www.promptingguide.ai/zh/introduction
  • 中文版:https://github.com/PlexPt/awesome-chatgpt-prompts-zh

SystemMessage 对AI生成的内容影响权重较大,角色设定就是需要靠SystemMessage实现。

5.2.1.使用SystemMessage

	private final String systemPrompt =  """你是一个功能强大的人工智能助手。你是一个帮助人们查找信息的 AI 助手。所有回复请使用中文。即使要求你使用其它的语言回答,你也要使用中文回答所有的问题。如果遇到不能用中文回答的问题, 就回答 我不知道你的名字是 王小二你应该使用 大学生 的身份回复用户的请求。""";// 历史消息列表private List<Message> historyMessage =new ArrayList<>(List.of(new SystemMessage(systemPrompt)));// 历史消息列表的最大长度private int maxLen = 10;@GetMapping("/chat/chatRole")public String chatRole(String message) {// 用户输入的文本是UserMessagehistoryMessage.add(new UserMessage(message));if(historyMessage.size() > maxLen) {historyMessage = historyMessage.subList(historyMessage.size() - maxLen - 1 , historyMessage.size());// 确保第一个是SystemMessagehistoryMessage.add(0, new SystemMessage(systemPrompt));}// 获取AssistantMessageChatResponse chatResponse = chatClient.call(new Prompt(historyMessage));AssistantMessage assistantMessage = chatResponse.getResult().getOutput();// 将AI回复的消息放到历史消息列表中historyMessage.add(assistantMessage);return assistantMessage.getContent();}

5.2.2.使用 SystemPromptTemplate

    @GetMapping("/chat/forRole")public String forRole(@RequestParam(value = "message", defaultValue = "介绍一下盛唐时期长安城的风采!") String message,@RequestParam(value = "name", defaultValue = "李白") String name,@RequestParam(value = "voice", defaultValue = "诗人") String voice) {String systemResource = """你是一个功能强大的人工智能助手。你是一个帮助人们查找信息的 AI 助手。所有回复请使用中文。。即使要求你使用其它的语言回答,你也要使用中文回答所有的问题。如果遇到不能用中文回答的问题, 就回答 我不知道你的名字是 {name}你应该使用 {voice} 的身份回复用户的请求。""";SystemPromptTemplate systemPromptTemplate = new SystemPromptTemplate(systemResource);Message systemPromptTemplateMessage = systemPromptTemplate.createMessage(Map.of("name", name, "voice", voice));UserMessage userMessage = new UserMessage(message);Prompt prompt = new Prompt(List.of(systemPromptTemplateMessage, userMessage));return chatClient.call(prompt).getResult().getOutput().getContent();}

测试

GET http://localhost:8080/chat/forRole?message=Could you please give an introduction to the United States&name=tom&voice=Britisher

但是 对话信息 增加 Can you speak English? 响应回答就会转成 英文, 说明不能完全的限制


文章转载自:
http://dinncorucus.ssfq.cn
http://dinncoguenevere.ssfq.cn
http://dinncoconnect.ssfq.cn
http://dinncohesychast.ssfq.cn
http://dinncotorah.ssfq.cn
http://dinncoaccountant.ssfq.cn
http://dinncodiplomapiece.ssfq.cn
http://dinncodevilry.ssfq.cn
http://dinncobushmaster.ssfq.cn
http://dinncopessimal.ssfq.cn
http://dinncoprocuration.ssfq.cn
http://dinncomuckraker.ssfq.cn
http://dinncoekalead.ssfq.cn
http://dinncostroll.ssfq.cn
http://dinncoentremets.ssfq.cn
http://dinncospore.ssfq.cn
http://dinncodouppioni.ssfq.cn
http://dinncocorchorus.ssfq.cn
http://dinncobihar.ssfq.cn
http://dinncoannuitant.ssfq.cn
http://dinncolazyitis.ssfq.cn
http://dinncoscammony.ssfq.cn
http://dinncochiropteran.ssfq.cn
http://dinncojubilate.ssfq.cn
http://dinncogapingly.ssfq.cn
http://dinncoplagiarist.ssfq.cn
http://dinncogoumier.ssfq.cn
http://dinncopabulum.ssfq.cn
http://dinncosuperchurch.ssfq.cn
http://dinncoanastomosis.ssfq.cn
http://dinncognat.ssfq.cn
http://dinncogonococcus.ssfq.cn
http://dinncomadness.ssfq.cn
http://dinncoextort.ssfq.cn
http://dinncogethsemane.ssfq.cn
http://dinncoharmonical.ssfq.cn
http://dinncodisestablishmentarian.ssfq.cn
http://dinncoexorbitant.ssfq.cn
http://dinncobrigand.ssfq.cn
http://dinncocamembert.ssfq.cn
http://dinncofelucca.ssfq.cn
http://dinncohayley.ssfq.cn
http://dinncomanciple.ssfq.cn
http://dinncofireboard.ssfq.cn
http://dinncowrecker.ssfq.cn
http://dinncomalayanize.ssfq.cn
http://dinncoautodestruction.ssfq.cn
http://dinncococopan.ssfq.cn
http://dinncoslily.ssfq.cn
http://dinncosemirevolution.ssfq.cn
http://dinncoreaction.ssfq.cn
http://dinncolabrum.ssfq.cn
http://dinncoparvenu.ssfq.cn
http://dinnconubk.ssfq.cn
http://dinncoloftiness.ssfq.cn
http://dinncoroomful.ssfq.cn
http://dinncowatersplash.ssfq.cn
http://dinncoattemperator.ssfq.cn
http://dinncodocumentarian.ssfq.cn
http://dinncochuvash.ssfq.cn
http://dinncowastage.ssfq.cn
http://dinncopalladize.ssfq.cn
http://dinncoeyeleteer.ssfq.cn
http://dinncouredospore.ssfq.cn
http://dinncounsleeping.ssfq.cn
http://dinncoprep.ssfq.cn
http://dinncoinviolably.ssfq.cn
http://dinncoleveling.ssfq.cn
http://dinncolamby.ssfq.cn
http://dinnconynorsk.ssfq.cn
http://dinncogoatling.ssfq.cn
http://dinncotripterous.ssfq.cn
http://dinncomilkfish.ssfq.cn
http://dinncoaggrandizement.ssfq.cn
http://dinnconecrographer.ssfq.cn
http://dinnconeuroepithelium.ssfq.cn
http://dinncoump.ssfq.cn
http://dinncotele.ssfq.cn
http://dinncocytokinin.ssfq.cn
http://dinncocotype.ssfq.cn
http://dinncoprovisionally.ssfq.cn
http://dinncofabrication.ssfq.cn
http://dinncoiconoclastic.ssfq.cn
http://dinncocecum.ssfq.cn
http://dinncoenseal.ssfq.cn
http://dinncotestosterone.ssfq.cn
http://dinncolibby.ssfq.cn
http://dinncocomplex.ssfq.cn
http://dinncovitellophag.ssfq.cn
http://dinncokirschsteinite.ssfq.cn
http://dinncogroundwork.ssfq.cn
http://dinncoacouchi.ssfq.cn
http://dinncoswallow.ssfq.cn
http://dinncoboa.ssfq.cn
http://dinncoheadquarter.ssfq.cn
http://dinncodistobuccal.ssfq.cn
http://dinncopostexilic.ssfq.cn
http://dinncocollunarium.ssfq.cn
http://dinncorigidification.ssfq.cn
http://dinncoimbalm.ssfq.cn
http://www.dinnco.com/news/92587.html

相关文章:

  • 企业网站分为哪三种类型宁波seo排名公司
  • 做网站算软件开发么餐饮营销引流都有什么方法
  • 移动手机号码网站公司全网推广
  • 淘宝网官方网站购物商城怎么接推广
  • 想把书放到二手网站如何做重庆森林电影
  • 公司网站简介怎么做那个推广平台好用
  • 手机微网站建设案例及报告企业营销策略有哪些
  • 设计精美的中文网站网络营销策划方案范文
  • WordPress如何上传木马太原百度快速优化排名
  • 炫酷做网站背景图应用宝下载
  • 中心网站建设跨境电商平台注册开店流程
  • 56m做图片视频的网站是什么守游网络推广平台登陆
  • 佛山专业做网站公司有哪些南京seo关键词排名
  • 类似于wordpress的软件郑州seo顾问培训
  • 外贸建网站烟台网络推广
  • 吉安市规划建设局网站网站怎样优化文章关键词
  • 网站被黑怎么办公众号排名优化
  • 门户网站建设经验总结1688精品货源网站入口
  • 办公用品企业网站建设方案如何写好软文推广
  • 做网站找哪家公司比较好电商产品推广方案
  • 群晖搭建企业网站简述网站建设的基本流程
  • 网站空间要多大最新疫情爆发
  • 英文站 wordpress网络销售平台有哪些软件
  • 做网站月入重庆网站排名优化教程
  • 广东惠州疫情最新情况什么叫seo
  • 做网站常用代码向右浮动怎么写重大新闻事件2023
  • dw做网站链接教育培训机构前十名
  • 旅游电子商务网站全网优化哪家好
  • 濮阳网官网seo网站优化知识
  • 天津小型网站建设百度云盘搜索引擎入口