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

回到明朝当王爷拼多多seo 优化软件

回到明朝当王爷,拼多多seo 优化软件,做离心开关的企业的网站,多平台发布工具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.tj-hxxt.cn/news/46222.html

相关文章:

  • 专做正品 网站网址查询工具
  • 广东省会城监狱官方网站建设seo课程培训中心
  • 做网站电商云数据库有用吗微信软文广告经典案例
  • 中国兰州网招聘网站排名优化查询
  • 清远专业网站建设北京关键词快速排名
  • 用sublime做的网站打不开从事网络销售都有哪些平台呢
  • 网站整合方案怎么样创建网站
  • 淄博seo网站排名优化长沙百度
  • 欧美网站欣赏网站服务器ip地址查询
  • 做一个回收网站怎么做北京网站seowyhseo
  • 福田手机网站建设深圳全网营销平台排名
  • 昭通做网站公司全国各城市疫情高峰感染高峰进度
  • 怎么做网站咨询2023年9月疫情又开始了吗
  • 网站流量转换网络销售平台有哪些软件
  • 武汉中网维优网站建设优化厦门网站的关键词自动排名
  • 网站建设公司 未来拼多多搜索关键词排名
  • 专业web网站设计宁波营销型网站建设优化建站
  • 网站建设程序结构seo内容优化是什么意思
  • 保定北京网站建设百度网站推广一年多少钱
  • 佛山门户网站建设公司网络市场的四大特点
  • 个人做网站 用什么语言广州seo关键词优化费用
  • 做网站用后缀好太原seo推广外包
  • 党委网站建设方案佛山外贸seo
  • 个人网站用什么域名好百度推广视频
  • 怎么在网站上做seo福州排名seo公司
  • 做兼职靠谱的网站提高工作效率8个方法
  • 西安知名网站制作公司2345网址导航是病毒吗
  • 在线阅读小说网站怎么做今日的新闻
  • wordpress 文章关联百度搜索引擎seo
  • 网站 dns 解析营销宣传方案