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

哪家企业网站做的好如何建立手机论坛

哪家企业网站做的好,如何建立手机论坛,企业邮箱正确的写法,专业网站制作公司是如何处理一个优秀网站的分类目录#xff1a;《自然语言处理从入门到应用》总目录 Cassandra聊天消息记录 Cassandra是一种分布式数据库#xff0c;非常适合存储大量数据#xff0c;是存储聊天消息历史的良好选择#xff0c;因为它易于扩展#xff0c;能够处理大量写入操作。 # 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_pointscontact_points, session_idtest-session )message_history.add_user_message(hi!)message_history.add_ai_message(whats up?) message_history.messages [HumanMessage(contenthi!, additional_kwargs{}, exampleFalse), AIMessage(contentwhats up?, additional_kwargs{}, exampleFalse)]DynamoDB聊天消息记录 首先确保我们已经正确配置了AWS CLI并再确保我们已经安装了boto3。接下来创建我们将存储消息 DynamoDB表 import boto3# Get the service resource. dynamodb boto3.resource(dynamodb)# Create the DynamoDB table. table dynamodb.create_table(TableNameSessionTable,KeySchema[{AttributeName: SessionId,KeyType: HASH}],AttributeDefinitions[{AttributeName: SessionId,AttributeType: S}],BillingModePAY_PER_REQUEST, )# Wait until the table exists. table.meta.client.get_waiter(table_exists).wait(TableNameSessionTable)# Print out some data about the table. print(table.item_count)输出 0DynamoDBChatMessageHistory from langchain.memory.chat_message_histories import DynamoDBChatMessageHistoryhistory DynamoDBChatMessageHistory(table_nameSessionTable, session_id0) history.add_user_message(hi!) history.add_ai_message(whats up?) history.messages输出 [HumanMessage(contenthi!, additional_kwargs{}, exampleFalse), AIMessage(contentwhats up?, additional_kwargs{}, exampleFalse)]使用自定义端点URL的DynamoDBChatMessageHistory 有时候在连接到AWS端点时指定URL非常有用比如在本地使用Localstack进行开发。对于这种情况我们可以通过构造函数中的endpoint_url参数来指定URL。 from langchain.memory.chat_message_histories import DynamoDBChatMessageHistoryhistory DynamoDBChatMessageHistory(table_nameSessionTable, session_id0, endpoint_urlhttp://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_nameSessionTable, session_id1) memory ConversationBufferMemory(memory_keychat_history, chat_memorymessage_history, return_messagesTrue) python_repl PythonREPL()# You can create the tool to pass to an agent tools [Tool(namepython_repl,descriptionA 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(...).,funcpython_repl.run )] llmChatOpenAI(temperature0) agent_chain initialize_agent(tools, llm, agentAgentType.CHAT_CONVERSATIONAL_REACT_DESCRIPTION, verboseTrue, memorymemory) agent_chain.run(inputHello!)日志输出 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(inputWho 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, textOwner).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(inputMy 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(inputWho 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(days1) history MomentoChatMessageHistory.from_client_params(session_id, cache_name,ttl, )history.add_user_message(hi!)history.add_ai_message(whats up?) history.messages输出 [HumanMessage(contenthi!, additional_kwargs{}, exampleFalse), AIMessage(contentwhats up?, additional_kwargs{}, exampleFalse)]MongoDB聊天消息记录 本节介绍如何使用MongoDB存储聊天消息记录。MongoDB是一个开放源代码的跨平台文档导向数据库程序。它被归类为NoSQL数据库程序使用类似JSON的文档并且支持可选的模式。MongoDB由MongoDB Inc.开发并在服务器端公共许可证SSPL下许可。 # Provide the connection string to connect to the MongoDB database connection_string mongodb://mongo_user:password123mongo:27017 from langchain.memory import MongoDBChatMessageHistorymessage_history MongoDBChatMessageHistory(connection_stringconnection_string, session_idtest-session)message_history.add_user_message(hi!)message_history.add_ai_message(whats up?) message_history.messages输出 [HumanMessage(contenthi!, additional_kwargs{}, exampleFalse), AIMessage(contentwhats up?, additional_kwargs{}, exampleFalse)]Postgres聊天消息历史记录 本节介绍了如何使用 Postgres 来存储聊天消息历史记录。 from langchain.memory import PostgresChatMessageHistoryhistory PostgresChatMessageHistory(connection_stringpostgresql://postgres:mypasswordlocalhost/chat_history, session_idfoo)history.add_user_message(hi!)history.add_ai_message(whats up?) history.messagesRedis聊天消息历史记录 本节介绍了如何使用Redis来存储聊天消息历史记录。 from langchain.memory import RedisChatMessageHistoryhistory RedisChatMessageHistory(foo)history.add_user_message(hi!) history.add_ai_message(whats up?) history.messages输出 [AIMessage(contentwhats up?, additional_kwargs{}), HumanMessage(contenthi!, 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://www.w-s-a.com/news/301088/

相关文章:

  • 做网站的职位叫什么问题常州金坛网站建设
  • 保健品网站模板用jsp做的网站前后端交互
  • 网站带后台品牌网页设计图片
  • 保定清苑住房和城乡建设局网站分类信息网站程序
  • 可以做视频推广的网站选择大连网站建设
  • 在线网站开发网站在哪里
  • 建站的步骤上海快速优化排名
  • 招聘网站做一下要多少钱网站设计公司 国际
  • 巩义专业网站建设公司首选seo研究院
  • 大流量网站解决访问量友情链接如何添加
  • 教育网站建设网永康市住房和城乡建设局网站
  • 阿里巴巴官网网站django 做网站的代码
  • 网站建设 军报wordpress 订餐模板
  • 网站虚拟主机 会计处理石家庄站建设费用多少
  • 网站建设 服务内容 费用简述网站开发流程
  • 公司制作网站跟企业文化的关系空间制作网站
  • 浙江建设监理协会网站个人网站设计规划书
  • wordpress太卡了贵州seo推广
  • 企业介绍微网站怎么做的手机软件商城免费下载
  • 新手网站设计定价网站开发销售
  • 网站开发公司oa有没有找人做标书的网站
  • 传统门户网站有哪些人武部正规化建设
  • 台州网站制作方案免费无代码开发平台
  • 精通网站建设 pdf微盘学做电商的步骤
  • 想在网上做设计接单有没有网站找一个免费域名的网站
  • 湘潭市网站建设科技有限公司杭州网站建设(推荐乐云践新)
  • 优秀网站评析西双版纳傣族自治州民宿
  • 常用的cms建站系统c2c网站模板
  • wordpress更换图标seo网站建设公司
  • 网站备案 深圳小程序怎么进入公众号