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

黄冈网站建设费用龙华网站制作公司

黄冈网站建设费用,龙华网站制作公司,滨州网站建设 中企动力,能下短视频网站做牙本文我们将尝试AutoGen集成函数调用功能。函数调用最早出现在Open AI API中#xff0c;它允许用户调用外部API来增强系统的整体功能和效率。例如#xff0c;在对话过程中根据需要调用天气API。 函数调用和Agent有各种组合#xff0c;在这里我们将通过函数调用调用RAG检索增强… 本文我们将尝试AutoGen集成函数调用功能。函数调用最早出现在Open AI API中它允许用户调用外部API来增强系统的整体功能和效率。例如在对话过程中根据需要调用天气API。 函数调用和Agent有各种组合在这里我们将通过函数调用调用RAG检索增强生成机制并使用结果生成输出。 本文将介绍如何使用Langchian、Autogen、Retrieval Augmented GenerationRAG和函数调用来构建超级AI聊天机器人。 一、什么是Langchain LangChain是一个开源库为开发人员提供了构建由大型语言模型LLM支持的LLM应用程序的工具如OpenAI或Hugging Face。可以构建动态的、响应数据的应用程序利用自然语言处理方面的最新突破。 LangChain是一个框架使开发人员能够构建能够推理问题并将其分解为较小子任务的代理。 二、什么是Autogen AutoGen不仅仅是一种工具它也是协作人工智能的未来多个智能体聚集在一起将想法转化为现实人工智能智能体团结、创新和提升。 简单地说AutoGen和LangChain都是用于开发LLM驱动的应用程序的框架。然而两者之间存在一些关键区别 AutoGen是一个多智能体框架而LangChain是一个单智能体框架AutoGen更专注于代码生成而LangChain更专注于通用NLP任务 三、什么是检索增强生成 检索增强生成RAG是一种人工智能框架它从外部知识来源检索数据以提高响应质量。它通过矢量相似性搜索和对外部数据集的实时更新等技术来确保准确性。 四、什么是函数调用 函数调用简化了与外部工具和API通信的聊天机器人的创建。 换句话说函数调用帮助开发人员向模型描述函数并让模型智能地选择输出JSON对象。 五、搭建超级对话系统 安装环境以及所需要的包命令如下 !pip install langchain , pyautogen[retrievechat] , PyPDF2 , faiss-gpu 导入相关包 import autogenfrom langchain.embeddings import OpenAIEmbeddingsfrom langchain.vectorstores import FAISSfrom langchain.llms import OpenAIfrom langchain.memory import ConversationBufferMemoryfrom langchain.chains import ConversationalRetrievalChainfrom PyPDF2 import PdfReaderfrom langchain.text_splitter import RecursiveCharacterTextSplitter 步骤1配置AutoGen和API密钥 AutoGen的配置文件是一个名为config_list的list config_list:是一个列表其中包含使用的模型的配置 seed设置为42 有了这个配置下面看一下如何使用AutoGen config_list [ { model: gpt-4-1106-preview, api_key: openai_api, }]​llm_config_proxy { seed: 42, # change the seed for different trials temperature: 0, config_list: config_list, request_timeout: 600} 步骤2读取PDF文件 我们上传一个PDF文件并进行处理使用PyPDF2读取PDF文件 使用langchain中的text splitter将文本分割成chunk 使用OpenAIEmbeddings嵌入PDF文件然后FAISS存储在向量数据库中 Faiss可以将文本chunk转换为embedding。然后这些向量可以用于各种应用如相似性搜索。 reader PdfReader(/content/openchat.pdf)corpus .join([p.extract_text() for p in reader.pages if p.extract_text()])​splitter RecursiveCharacterTextSplitter(chunk_size1000,chunk_overlap200,)chunks splitter.split_text(corpus)​embeddings OpenAIEmbeddings(openai_api_key openai_api)vectors FAISS.from_texts(chunks, embeddings) 步骤3会话检索 一旦创建了数据库我们就可以对其进行查询。 我们就可以使用Langchain的ConversationalRetrievalChain对用户的Prompt进行相似性搜索 let call ConversationBufferMemory是一个简单的内存缓冲区用于存储会话的历史记录。 qa ConversationalRetrievalChain.from_llm( OpenAI(temperature0), vectors.as_retriever(), memoryConversationBufferMemory(memory_keychat_history, return_messagesTrue),) 步骤4指定Assistant代理的配置 AutoGen Agent支持对OpenAI模型的函数调用但我们需要使用以下代码段指定函数 llm_config_assistant { Seed : 42, temperature: 0, functions: [ { name: answer_PDF_question, description: Answer any PDF related questions, parameters: { type: object, properties: { question: { type: string, description: The question to ask in relation to PDF, } }, required: [question], }, } ], config_list: config_list, timeout: 120,} 步骤5配置Assistant Agent 让我们创建一个名为“assistant”的具有特定配置的自动化助理代理。我们使用该assistant阅读PDF并生成准确的答案。 assistant autogen.AssistantAgent( nameassistant, llm_configllm_config_assistant, system_messageYou are a helpful assistant, Answer the question based on the context. Keep the answer accurate. Respond Unsure about answer if not sure about the answer. ) 步骤6配置UserProxy代理。 User Proxy代理包括一个独特的功能function_map参数此参数用于将函数调用的配置与实际函数本身链接起来确保无缝集成和操作。 user_proxy autogen.UserProxyAgent( nameuser_proxy, human_input_modeNEVER, max_consecutive_auto_reply10, code_execution_config{work_dir: coding}, # llm_config_assistant llm_config_assistant, function_map{ answer_PDF_question: answer_PDF_question } ) 一旦设置了代理该脚本就会启动用户和聊天机器人之间的对话。这是通过调用user_proxy对象上的initiate_chat方法来完成的。initiate_chat方法需要两个参数充当聊天机器人的assistant实例和描述任务的文本消息。 user_proxy.initiate_chat( assistant, messageWrite a Openchat word blog post titled why openchat better than GPT3 that uses the exact keyword OpenChat at least once every 100 words. The blog post should include an introduction, main body, and conclusion. The conclusion should invite readers to leave a comment. The main body should be split into at least 4 different subsections.) 结果如下所示 user_proxy (to assistant):​​Write a Openchat word blog post titled why openchat better than GPT3 that uses the exact keyword OpenChat at least once every 100 words. The blog post should include an introduction, main body, and conclusion. The conclusion should invite readers to leave a comment. The main body should be split into at least 4 different subsections.​​--------------------------------------------------------------------------------assistant (to user_proxy):​# Why OpenChat is Better Than GPT-3​## Introduction​In the ever-evolving landscape of artificial intelligence, OpenChat has emerged as a groundbreaking platform, offering a unique set of capabilities that set it apart from its predecessors like GPT-3. In this blog post, we will delve into the reasons why OpenChat is not just a step ahead but a leap forward in AI communication technology.​## Main Body​### Enhanced Contextual Understanding​OpenChats ability to understand context surpasses that of GPT-3. It can maintain the thread of a conversation over a longer period, which allows for more coherent and meaningful interactions. This is particularly beneficial in customer service applications where conversations can be complex and require a deep understanding of the issue at hand.​### Superior Customization​One of the key advantages of OpenChat is its superior customization options. Unlike GPT-3, OpenChat can be tailored to fit the specific needs of any business or application. This means that it can adhere to brand voice, manage specialized knowledge bases, and integrate seamlessly with existing systems, providing a more personalized experience for users.​### Advanced Learning Capabilities​OpenChat is designed to learn and adapt more efficiently than GPT-3. It can quickly incorporate new information and adjust its responses accordingly. This continuous learning process ensures that OpenChat remains up-to-date with the latest data, trends, and user preferences, making it an invaluable tool for dynamic and fast-paced environments.​### Open-Source Community​The open-source nature of OpenChat is a game-changer. It allows developers from around the world to contribute to its development, leading to rapid innovation and improvement. This collaborative approach ensures that OpenChat is constantly evolving and benefiting from the collective expertise of a global community, unlike the more closed ecosystem of GPT-3.​## Conclusion​OpenChat represents a significant advancement in AI-powered communication, offering enhanced contextual understanding, superior customization, advanced learning capabilities, and the support of an open-source community. Its ability to provide more nuanced and adaptable interactions makes it a superior choice for businesses and developers looking to harness the power of AI.​We invite you to share your thoughts and experiences with OpenChat and GPT-3. Have you noticed the differences in your interactions? Leave a comment below and join the conversation about the future of AI communication. 结论 在这篇文章中我们解释了如何使用AutoGen、langchain、函数调用和检索增强生成来创建一个超级AI聊天机器人。当这些组件结合在一起时能够更有效地处理复杂的任务生成更相关和更了解上下文的内容响应将更加强大和通用。 参考文献 [1] https://levelup.gitconnected.com/autogen-langchian-rag-function-call-super-ai-chabot-3951911607f2 [2] https://www.microsoft.com/en-us/research/blog/autogen-enabling-next-generation-large-language-model-applications/ [3] https://github.com/microsoft/autogen [4] https://python.langchain.com/docs/get_started/introduction [5] https://www.microsoft.com/en-us/research/blog/autogen-enabling-next-generation-large-language-model-applications/
http://www.ihoyoo.com/news/45432.html

相关文章:

  • 幸福宝推广app网站下载潜江建设局网站
  • 网站建设需求流程图设计方案英语
  • 肇庆做网站设计公司怎样设置网站关键词
  • 潍坊网站建设淘宝客网站模块
  • 网站地图怎么弄公司没有备案了网站
  • shanxi建设银行网站首页东莞外贸公司网站制作
  • 深圳平台网站建设呼和浩特做网站的
  • 保健品网站怎么做的手机网站开发一个多少钱
  • 单位建设网站申请广州网站关键排名
  • 简单网站开发实例网站建设敬请期待图片素材
  • 有网站开发经验怎么写简历合肥网站建设-中国互联
  • 健身顾问在哪些网站做推广wordpress忘了秘密
  • 网上书店网站开发代码网络彩票建立网站
  • 网站建设项目工作分解结构中国网站的特点
  • 台州市建设规划局网站班子成员崇信县门户网站最新留言
  • 响应式官方网站杭州建设厅官网证件查询
  • 辽宁平台网站建设哪里好农业电商网站建设
  • 网站建设的经验做法报告编号怎么获取
  • 网站开发还是做数据库开发wordpress火车头发布规则
  • wordpress汉化插件下载地址seo在线培训
  • html5 网站开发定制58同城个人房屋出租信息发布
  • 网站建设的现状分析512 做网站
  • 怎么用织梦做网站前台wordpress页面不要侧边栏
  • 洛阳网站seo想办个网站怎么做
  • 外贸人常用网站wordpress企业站模板下载
  • 学网站建设 去那里电子商务网站建站
  • 长沙做一个网站多少钱怎样推广app
  • 哪家做的网站有利于百度推广电子网站建设维护
  • 青岛网站设计哪家公司建设银行网站打不开怎么办
  • 阿里云备案后 增加网站网站流量不够