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

网页设计网站大全友情链接方面pr的选择应该优先选择的链接为

网页设计网站大全,友情链接方面pr的选择应该优先选择的链接为,商务网站开发的基本原则,有哪个网站可以做兼职分类目录:《自然语言处理从入门到应用》总目录 Cassandra聊天消息记录 Cassandra是一种分布式数据库,非常适合存储大量数据,是存储聊天消息历史的良好选择,因为它易于扩展,能够处理大量写入操作。 # List of contact…

分类目录:《自然语言处理从入门到应用》总目录


Cassandra聊天消息记录

Cassandra是一种分布式数据库,非常适合存储大量数据,是存储聊天消息历史的良好选择,因为它易于扩展,能够处理大量写入操作。

# List of contact points to try connecting to Cassandra cluster.
contact_points = ["cassandra"]from langchain.memory import CassandraChatMessageHistorymessage_history = CassandraChatMessageHistory(contact_points=contact_points, session_id="test-session"
)message_history.add_user_message("hi!")message_history.add_ai_message("whats up?")
message_history.messages
[HumanMessage(content='hi!', additional_kwargs={}, example=False),
AIMessage(content='whats up?', additional_kwargs={}, example=False)]

DynamoDB聊天消息记录

首先确保我们已经正确配置了AWS CLI,并再确保我们已经安装了boto3。接下来,创建我们将存储消息 DynamoDB表:

import boto3# Get the service resource.
dynamodb = boto3.resource('dynamodb')# Create the DynamoDB table.
table = dynamodb.create_table(TableName='SessionTable',KeySchema=[{'AttributeName': 'SessionId','KeyType': 'HASH'}],AttributeDefinitions=[{'AttributeName': 'SessionId','AttributeType': 'S'}],BillingMode='PAY_PER_REQUEST',
)# Wait until the table exists.
table.meta.client.get_waiter('table_exists').wait(TableName='SessionTable')# Print out some data about the table.
print(table.item_count)

输出:

0
DynamoDBChatMessageHistory
from langchain.memory.chat_message_histories import DynamoDBChatMessageHistoryhistory = DynamoDBChatMessageHistory(table_name="SessionTable", session_id="0")
history.add_user_message("hi!")
history.add_ai_message("whats up?")
history.messages

输出:

[HumanMessage(content='hi!', additional_kwargs={}, example=False),
AIMessage(content='whats up?', additional_kwargs={}, example=False)]
使用自定义端点URL的DynamoDBChatMessageHistory

有时候在连接到AWS端点时指定URL非常有用,比如在本地使用Localstack进行开发。对于这种情况,我们可以通过构造函数中的endpoint_url参数来指定URL。

from langchain.memory.chat_message_histories import DynamoDBChatMessageHistoryhistory = DynamoDBChatMessageHistory(table_name="SessionTable", session_id="0", endpoint_url="http://localhost.localstack.cloud:4566")
Agent with DynamoDB Memory
from langchain.agents import Tool
from langchain.memory import ConversationBufferMemory
from langchain.chat_models import ChatOpenAI
from langchain.agents import initialize_agent
from langchain.agents import AgentType
from langchain.utilities import PythonREPL
from getpass import getpassmessage_history = DynamoDBChatMessageHistory(table_name="SessionTable", session_id="1")
memory = ConversationBufferMemory(memory_key="chat_history", chat_memory=message_history, return_messages=True)
python_repl = PythonREPL()# You can create the tool to pass to an agent
tools = [Tool(name="python_repl",description="A Python shell. Use this to execute python commands. Input should be a valid python command. If you want to see the output of a value, you should print it out with `print(...)`.",func=python_repl.run
)]
llm=ChatOpenAI(temperature=0)
agent_chain = initialize_agent(tools, llm, agent=AgentType.CHAT_CONVERSATIONAL_REACT_DESCRIPTION, verbose=True, memory=memory)
agent_chain.run(input="Hello!")

日志输出:

> Entering new AgentExecutor chain...
{"action": "Final Answer","action_input": "Hello! How can I assist you today?"
}> Finished chain.

输出:

'Hello! How can I assist you today?'

输入:

agent_chain.run(input="Who owns Twitter?")

日志输出:

> Entering new AgentExecutor chain...
{"action": "python_repl","action_input": "import requests\nfrom bs4 import BeautifulSoup\n\nurl = 'https://en.wikipedia.org/wiki/Twitter'\nresponse = requests.get(url)\nsoup = BeautifulSoup(response.content, 'html.parser')\nowner = soup.find('th', text='Owner').find_next_sibling('td').text.strip()\nprint(owner)"
}
Observation: X Corp. (2023–present)Twitter, Inc. (2006–2023)Thought:{"action": "Final Answer","action_input": "X Corp. (2023–present)Twitter, Inc. (2006–2023)"
}> Finished chain.

输出:

'X Corp. (2023–present)Twitter, Inc. (2006–2023)'

输入:

agent_chain.run(input="My name is Bob.")

日志输出:

> Entering new AgentExecutor chain...
{"action": "Final Answer","action_input": "Hello Bob! How can I assist you today?"
}> Finished chain.

输出:

  'Hello Bob! How can I assist you today?'

输入:

agent_chain.run(input="Who am I?")

日志输出:

> Entering new AgentExecutor chain...
{"action": "Final Answer","action_input": "Your name is Bob."
}> Finished chain.

输出:

'Your name is Bob.'

Momento聊天消息记录

本节介绍如何使用Momento Cache来存储聊天消息记录,我们会使用MomentoChatMessageHistory类。需要注意的是,默认情况下,如果不存在具有给定名称的缓存,我们将创建一个新的缓存。我们需要获得一个Momento授权令牌才能使用这个类。这可以直接通过将其传递给momento.CacheClient实例化,作为MomentoChatMessageHistory.from_client_params的命名参数auth_token,或者可以将其设置为环境变量MOMENTO_AUTH_TOKEN

from datetime import timedelta
from langchain.memory import MomentoChatMessageHistorysession_id = "foo"
cache_name = "langchain"
ttl = timedelta(days=1)
history = MomentoChatMessageHistory.from_client_params(session_id, cache_name,ttl,
)history.add_user_message("hi!")history.add_ai_message("whats up?")
history.messages

输出:

[HumanMessage(content='hi!', additional_kwargs={}, example=False),
AIMessage(content='whats up?', additional_kwargs={}, example=False)]

MongoDB聊天消息记录

本节介绍如何使用MongoDB存储聊天消息记录。MongoDB是一个开放源代码的跨平台文档导向数据库程序。它被归类为NoSQL数据库程序,使用类似JSON的文档,并且支持可选的模式。MongoDB由MongoDB Inc.开发,并在服务器端公共许可证(SSPL)下许可。

# Provide the connection string to connect to the MongoDB database
connection_string = "mongodb://mongo_user:password123@mongo:27017"
from langchain.memory import MongoDBChatMessageHistorymessage_history = MongoDBChatMessageHistory(connection_string=connection_string, session_id="test-session")message_history.add_user_message("hi!")message_history.add_ai_message("whats up?")
message_history.messages

输出:

[HumanMessage(content='hi!', additional_kwargs={}, example=False),
AIMessage(content='whats up?', additional_kwargs={}, example=False)]

Postgres聊天消息历史记录

本节介绍了如何使用 Postgres 来存储聊天消息历史记录。

from langchain.memory import PostgresChatMessageHistoryhistory = PostgresChatMessageHistory(connection_string="postgresql://postgres:mypassword@localhost/chat_history", session_id="foo")history.add_user_message("hi!")history.add_ai_message("whats up?")
history.messages

Redis聊天消息历史记录

本节介绍了如何使用Redis来存储聊天消息历史记录。

from langchain.memory import RedisChatMessageHistoryhistory = RedisChatMessageHistory("foo")history.add_user_message("hi!")
history.add_ai_message("whats up?")
history.messages

输出:

[AIMessage(content='whats up?', additional_kwargs={}),
HumanMessage(content='hi!', additional_kwargs={})]

参考文献:
[1] LangChain官方网站:https://www.langchain.com/
[2] LangChain 🦜️🔗 中文网,跟着LangChain一起学LLM/GPT开发:https://www.langchain.com.cn/
[3] LangChain中文网 - LangChain 是一个用于开发由语言模型驱动的应用程序的框架:http://www.cnlangchain.com/


文章转载自:
http://dinncohermatype.ydfr.cn
http://dinncopensively.ydfr.cn
http://dinncoapathetically.ydfr.cn
http://dinncocacuminal.ydfr.cn
http://dinncomennonist.ydfr.cn
http://dinncostrobila.ydfr.cn
http://dinncoiodimetry.ydfr.cn
http://dinncouh.ydfr.cn
http://dinncobuhlwork.ydfr.cn
http://dinncorebaptize.ydfr.cn
http://dinncoaspidistra.ydfr.cn
http://dinncohesperornis.ydfr.cn
http://dinncoerin.ydfr.cn
http://dinncofloristry.ydfr.cn
http://dinncotantalise.ydfr.cn
http://dinncounculture.ydfr.cn
http://dinncosalonika.ydfr.cn
http://dinnconarrowband.ydfr.cn
http://dinncocurst.ydfr.cn
http://dinncoesl.ydfr.cn
http://dinncogirdle.ydfr.cn
http://dinncodemyelination.ydfr.cn
http://dinncoirrationalism.ydfr.cn
http://dinncoheteroautotrophic.ydfr.cn
http://dinncoaniconism.ydfr.cn
http://dinncoforecast.ydfr.cn
http://dinncopelite.ydfr.cn
http://dinncoshekarry.ydfr.cn
http://dinncoamr.ydfr.cn
http://dinncobeg.ydfr.cn
http://dinncolimnetic.ydfr.cn
http://dinncoemaciation.ydfr.cn
http://dinncolatah.ydfr.cn
http://dinncorhytidectomy.ydfr.cn
http://dinncounkindness.ydfr.cn
http://dinncoantileukemic.ydfr.cn
http://dinncologania.ydfr.cn
http://dinncolinkup.ydfr.cn
http://dinncochartist.ydfr.cn
http://dinncolibra.ydfr.cn
http://dinncosquamaceous.ydfr.cn
http://dinncointergradation.ydfr.cn
http://dinncointerpret.ydfr.cn
http://dinncopeevers.ydfr.cn
http://dinncopronatalist.ydfr.cn
http://dinncocontractant.ydfr.cn
http://dinncodejeuner.ydfr.cn
http://dinncoheteroatom.ydfr.cn
http://dinncoexportation.ydfr.cn
http://dinncoturnhall.ydfr.cn
http://dinncoflavomycin.ydfr.cn
http://dinncosourly.ydfr.cn
http://dinncoclaver.ydfr.cn
http://dinncogran.ydfr.cn
http://dinncoabdicate.ydfr.cn
http://dinncotaraxacum.ydfr.cn
http://dinncoclimbing.ydfr.cn
http://dinncovitriolate.ydfr.cn
http://dinncocockney.ydfr.cn
http://dinncoentree.ydfr.cn
http://dinncotoadeater.ydfr.cn
http://dinncodolomite.ydfr.cn
http://dinncolinchpin.ydfr.cn
http://dinncomsn.ydfr.cn
http://dinncohightail.ydfr.cn
http://dinncochrismon.ydfr.cn
http://dinncoatonic.ydfr.cn
http://dinncotcs.ydfr.cn
http://dinncoremodify.ydfr.cn
http://dinncolaughably.ydfr.cn
http://dinncopetaliferous.ydfr.cn
http://dinncodistrainment.ydfr.cn
http://dinncopostclassic.ydfr.cn
http://dinncoglim.ydfr.cn
http://dinncomacroengineering.ydfr.cn
http://dinncomonofilament.ydfr.cn
http://dinncoconvict.ydfr.cn
http://dinncoaginner.ydfr.cn
http://dinncoconnector.ydfr.cn
http://dinncosodom.ydfr.cn
http://dinncovespertilionid.ydfr.cn
http://dinncoidolater.ydfr.cn
http://dinncocommercially.ydfr.cn
http://dinncowoolgather.ydfr.cn
http://dinncozoonose.ydfr.cn
http://dinncocrescograph.ydfr.cn
http://dinncobrightness.ydfr.cn
http://dinncosillimanite.ydfr.cn
http://dinncodigestive.ydfr.cn
http://dinncopratique.ydfr.cn
http://dinncocatheterize.ydfr.cn
http://dinncolamellated.ydfr.cn
http://dinncocrossbedded.ydfr.cn
http://dinncojunior.ydfr.cn
http://dinncomote.ydfr.cn
http://dinncocucurbit.ydfr.cn
http://dinncoesotropia.ydfr.cn
http://dinncovienna.ydfr.cn
http://dinncogrim.ydfr.cn
http://dinncocooperationist.ydfr.cn
http://www.dinnco.com/news/142117.html

相关文章:

  • 网站使用授权书百度关键词流量查询
  • 手机端steam怎么调中文seo查询工具网站
  • 房产网站建设ppt夸克搜索引擎
  • 微信官网网站模板下载安装巨量关键词搜索查询
  • 中国建设银行官网网站如何推广自己的产品
  • 江苏建设人才的网站国产免费crm系统有哪些在线
  • 苏州网页服务开发与网站建设合肥网站推广优化
  • 水印logo在线制作生成器seo点击软件
  • 网站布局怎么用dw做app推广项目
  • 高端商品网站seo技术外包公司
  • 网站建设外包公司怎么样网络优化的三个方法
  • 网站推广优化方案网站关键词
  • 在线自动取名网站怎么做最有吸引力的营销模式
  • 做展示型网站百度付费问答平台
  • 公司做网站的费属于广告费么关键词分类哪八种
  • 做网站确定什么主题好百度超级链数字藏品
  • 企业年金怎么提取上海关键词seo
  • 济南网站建设策划广告设计自学教程
  • jssdk wordpress广丰网站seo
  • 自贡制作网站网站开发技术
  • 网站制作公司 知乎郑州seo技术博客
  • 三沙网站设计公司小型培训机构管理系统
  • 怎么推广我做的网站最新舆情信息网
  • 网站开发需要多少钱客服巨量广告投放平台
  • wordpress 发布到知乎网站推广优化技巧
  • 梭子手做鱼网站手机上如何制作自己的网站
  • 安装wordpress提示建立数据库连接时出错百度搜索怎么优化
  • 泉州做网站排名百度导航最新版本下载安装
  • 宝鸡做网站设计游戏推广合作平台
  • 长沙装修公司排名十强seo中心