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

东莞便宜做网站甘肃省建设厅网站资质升级公示

东莞便宜做网站,甘肃省建设厅网站资质升级公示,做网站怎么添加背景图片,稷山网站建设Langchain 的 Conversation buffer window memory ConversationBufferWindowMemory 保存一段时间内对话交互的列表。它仅使用最后 K 个交互。这对于保持最近交互的滑动窗口非常有用,因此缓冲区不会变得太大。 我们首先来探讨一下这种存储器的基本功能。 示例代码&…

Langchain 的 Conversation buffer window memory

ConversationBufferWindowMemory 保存一段时间内对话交互的列表。它仅使用最后 K 个交互。这对于保持最近交互的滑动窗口非常有用,因此缓冲区不会变得太大。

我们首先来探讨一下这种存储器的基本功能。

示例代码,

from langchain.memory import ConversationBufferWindowMemory
memory = ConversationBufferWindowMemory( k=1)
memory.save_context({"input": "hi"}, {"output": "whats up"})
memory.save_context({"input": "not much you"}, {"output": "not much"})
memory.load_memory_variables({})

输出结果,

    {'history': 'Human: not much you\nAI: not much'}

我们还可以获取历史记录作为消息列表(如果您将其与聊天模型一起使用,这非常有用)。

示例代码,

memory = ConversationBufferWindowMemory( k=1, return_messages=True)
memory.save_context({"input": "hi"}, {"output": "whats up"})
memory.save_context({"input": "not much you"}, {"output": "not much"})
memory.load_memory_variables({})

输出结果,

    {'history': [HumanMessage(content='not much you', additional_kwargs={}),AIMessage(content='not much', additional_kwargs={})]}

Using in a chain

让我们看一下示例,再次设置 verbose=True 以便我们可以看到提示。

from langchain.llms import OpenAI
from langchain.chains import ConversationChain
conversation_with_summary = ConversationChain(llm=OpenAI(temperature=0), # We set a low k=2, to only keep the last 2 interactions in memorymemory=ConversationBufferWindowMemory(k=2), verbose=True
)
conversation_with_summary.predict(input="Hi, what's up?")

输出结果,

    > Entering new ConversationChain chain...Prompt after formatting:The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.Current conversation:Human: Hi, what's up?AI:> Finished chain." Hi there! I'm doing great. I'm currently helping a customer with a technical issue. How about you?"

示例代码,

conversation_with_summary.predict(input="What's their issues?")

输出结果,

    > Entering new ConversationChain chain...Prompt after formatting:The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.Current conversation:Human: Hi, what's up?AI:  Hi there! I'm doing great. I'm currently helping a customer with a technical issue. How about you?Human: What's their issues?AI:> Finished chain." The customer is having trouble connecting to their Wi-Fi network. I'm helping them troubleshoot the issue and get them connected."

示例代码,

conversation_with_summary.predict(input="Is it going well?")

输出结果,

    > Entering new ConversationChain chain...Prompt after formatting:The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.Current conversation:Human: Hi, what's up?AI:  Hi there! I'm doing great. I'm currently helping a customer with a technical issue. How about you?Human: What's their issues?AI:  The customer is having trouble connecting to their Wi-Fi network. I'm helping them troubleshoot the issue and get them connected.Human: Is it going well?AI:> Finished chain." Yes, it's going well so far. We've already identified the problem and are now working on a solution."

示例代码,

# Notice here that the first interaction does not appear.
conversation_with_summary.predict(input="What's the solution?")

输出结果,

    > Entering new ConversationChain chain...Prompt after formatting:The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.Current conversation:Human: What's their issues?AI:  The customer is having trouble connecting to their Wi-Fi network. I'm helping them troubleshoot the issue and get them connected.Human: Is it going well?AI:  Yes, it's going well so far. We've already identified the problem and are now working on a solution.Human: What's the solution?AI:> Finished chain." The solution is to reset the router and reconfigure the settings. We're currently in the process of doing that."

完结!

http://www.yayakq.cn/news/813338/

相关文章:

  • msn网站制作东莞自助建站软件
  • 网站开发岗位要求提高网站建设管理水平
  • 网站数据库空间东莞常平美食
  • 顺德建设网站多少钱建设企业网站支票打印软件
  • 浙江建设干部学校网站首页做网站平面一套多少钱
  • 电子商务网站建设系统功能设计一个自己公司网站开发
  • 社团网站建设肇庆企业做网站
  • 做html网站模板seo sem关键词优化
  • 购物网站的文化建设问题wordpress 主题笔记
  • 建立网站时首先考虑的问题做新零售这些注册网站和找货源6
  • 企业网站备案流程深圳做棋牌网站建设哪家便宜
  • 最专业网站建设delphi7 网站开发
  • 手把手教你做网站7嘟嘟嘟在线观看播放免费
  • 500云空间网站做啤酒行业的网站
  • 长春网站建设net快闪ppt模板免费下载
  • 网站做app收费标准企业网站建设的目的有()
  • 网站正在建设html游戏平台网站建设
  • 有没有可以做各种字体的网站牛肉煲的做法
  • 怎么开免费网站如何查询一个网站的空间服务商
  • 教师招聘网站长城建设集团铁路专业简历制作
  • 技术成果交易网站建设方案福州高端网站建设
  • 给你一个网站怎么做的上海招聘信息最新招聘2022
  • 茂名公司网站设计网站交互做的比较好的
  • 摄像头做直播网站洛可可成都设计公司
  • 有哪些好的模板网站免费网站推广
  • 玉树市公司网站建设国内大中型网站建设知名公司
  • 徐州学习网站建设桂林百姓生活网
  • 广州网站推广教程网站建设趋势
  • asp.net网站连接mysql怎么套模板做网站
  • 云南网站建设哪家强微网站开发哪家好