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

管理系统官方网站东道设计报价

管理系统官方网站,东道设计报价,地推是什么意思,爱客crm多少钱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/502941/

相关文章:

  • 苏州网站建设设计制作公司灰色关键词排名代发
  • wordpress上删除主题北京seo费用是多少
  • 微企点自助建站系统怎样搭建网站视频教程
  • 什么叫微网站哪些网站可以做旅游
  • 网站的基础建设个体户可以做企业网站
  • 统计后台网站有哪些做5173这样的网站要多少人
  • 陕西中小企业网站建设推广城市分类信息网站系统
  • 能看人与动物做的网站wordpress中文免费主题下载
  • 中国数据统计网站成都工装设计公司排名
  • 东莞公司制作网站北京工厂网站建设
  • 网站开发从哪开始学建立网站站点的过程
  • 六安网站建设费用网页游戏制作平台
  • 自己做网站开发如何找客户域名查ip
  • 网站开发怎么设置打印按钮企业系统化管理
  • 网页设计与网站开发素材如何做企业招聘网站
  • 好的软件开发培训机构天津seo外包团队
  • 10元建站摄影协会网站源码
  • 满屏网站设计做多大亚马逊海外网站
  • 当当网站建设的目标杭州做公司官网的公司
  • 宜黄建设局网站门户网站建设 存在的问题
  • 个人做网站时不要做什么样的网站举例一个成功的网络营销案例
  • 二七区做网站长沙优化网站服务
  • 哪个网站专门做游戏脚本太原网站建设小程序
  • 水网站源码网站充值页面模板
  • 中英网站模板网站搭建软件d
  • 罗湖附近公司做网站建设哪家便宜陕西省网站开发
  • 苗木网站建设网站关键词推广做自然排名
  • 浙江做网站公司排名做如美团式网站要多少钱
  • c2c电子商务网站有哪些佛山企业网站优化
  • 房山区网站建设做婚姻网站赚钱