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

白云区建材网站建设海口关键词优化报价

白云区建材网站建设,海口关键词优化报价,小说引流推广,哈尔滨建站软件OpenAI的Function calling openai最近发布的gpt-3.5-turbo-0613 和 gpt-4-0613版本模型增加了function calling的功能#xff0c;该功能通过定义功能函数#xff0c;gpt通过分析问题和函数功能描述来决定是否调用函数#xff0c;并且生成函数对应的入参。函数调用的功能可以…OpenAI的Function calling openai最近发布的gpt-3.5-turbo-0613 和 gpt-4-0613版本模型增加了function calling的功能该功能通过定义功能函数gpt通过分析问题和函数功能描述来决定是否调用函数并且生成函数对应的入参。函数调用的功能可以弥补gpt的一些缺点比如实时信息的缺乏、特定领域能力使得能够进一步利用gpt的逻辑推理能力可以将问题进行分解处理解决问题能力更加强大。 gpt的函数调用功能步骤如下     1.使用问句和函数定义调用gpt          2.gpt选择是否调用函数并输出参数          3.解析参数 调用函数          4.将函数返回作为追加信息再次调用gpt 下面是一个通过调用search api的例子 1.定义描述函数 下面代码介绍了一个搜索函数可以通过GoogleSerperAPI实时搜索网络上的信息。 ###定义functions用于描述函数作用和参数介绍。 functions [{name: get_info_from_web,description: get more informations from internet use google search,parameters: {type: object,properties: {query: {type: string,description: all the questions or information you want search from internet,}},required: [query],},} ]###函数定义 def get_info_from_web(query):search GoogleSerperAPIWrapper(serper_api_keyxxxxx)return search.run(query) 2.调用gpt决定是否调用函数以及函数参数 当用户问句为今天杭州天气怎么样时gpt做出了进行调用get_info_from_web函数的决定并且调用的参数为query: 杭州天气。 messages [] messages.append({role: system, content: Dont make assumptions about what values to plug into functions. Ask for clarification if a user request is ambiguous. }) messages.append({role: user, content: 今天杭州天气怎么样}) chat_response chat_completion_request(messages, functionsfunctions ) assistant_message chat_response.json()[choices][0][message] messages.append(assistant_message) print(assistant_message) {role: assistant,content: None,function_call: {name: get_info_from_web,arguments: {\n query: 杭州天气\n}} } 3.执行gpt的决定获得回答问题的中间结果 调用第2步中gpt输出的参数执行相应的函数获得中间结果。 assistant_message chat_response.json()[choices][0][message] if assistant_message.get(function_call):if assistant_message[function_call][name] get_info_from_web:query json.loads(assistant_message[function_call][arguments])[query]results get_info_from_web(query)else:results fError: function {assistant_message[function_call][name]} does not exist print(results) 81°F 4.函数结果和原始问题再次询问gpt获得最终结果 messages.append({role: function, name: assistant_message[function_call][name], content: results}) second_response openai.ChatCompletion.create(model GPT_MODEL,messagesmessages) print(second_response[choices][0][message][content]) 今天杭州的天气是81°F。 LangChain的Search Agent         在openai的function calling发布之前LangChain的Agent就可以实现类似功能。Agent接口是LangChain中一个重要的模块一些应用程序需要根据用户输入灵活地调用LLM和其他工具。Agent接口为此类应用程序提供了灵活性。Agent可以访问一套工具并根据用户输入确定要使用哪些工具。Agent可以使用多个工具并将一个工具的输出用作下一个工具的输入。 以下是search agent的例子。定义GoogleSerperApi工具作为LLM可用的tool帮助解决相关问题。 from langchain.utilities import GoogleSerperAPIWrapper from langchain.llms.openai import OpenAI from langchain.agents import initialize_agent, Tool from langchain.agents import AgentTypellm OpenAI(temperature0) search GoogleSerperAPIWrapper(serper_api_keyxxxxxx) tools [Tool(nameIntermediate Answer,funcsearch.run,descriptionuseful for when you need to ask with search,) ]self_ask_with_search initialize_agent(tools, llm, agentAgentType.SELF_ASK_WITH_SEARCH, verboseTrue )self_ask_with_search.run(今天杭州天气怎么样 )Entering new AgentExecutor chain...Yes. Follow up: 今天是几号 Intermediate answer: Sunday, July 16, 2023 Follow up: 杭州今天的天气情况 Intermediate answer: 88°F So the final answer is: 88°F Finished chain. 88°F agent功能通过设计prompt实现search agent的prompt设计如下 Question: Who lived longer, Muhammad Ali or Alan Turing? Are follow up questions needed here: Yes. Follow up: How old was Muhammad Ali when he died? Intermediate answer: Muhammad Ali was 74 years old when he died. Follow up: How old was Alan Turing when he died? Intermediate answer: Alan Turing was 41 years old when he died. So the final answer is: Muhammad AliQuestion: When was the founder of craigslist born? Are follow up questions needed here: Yes. Follow up: Who was the founder of craigslist? Intermediate answer: Craigslist was founded by Craig Newmark. Follow up: When was Craig Newmark born? Intermediate answer: Craig Newmark was born on December 6, 1952. So the final answer is: December 6, 1952Question: Who was the maternal grandfather of George Washington? Are follow up questions needed here: Yes. Follow up: Who was the mother of George Washington? Intermediate answer: The mother of George Washington was Mary Ball Washington. Follow up: Who was the father of Mary Ball Washington? Intermediate answer: The father of Mary Ball Washington was Joseph Ball. So the final answer is: Joseph BallQuestion: Are both the directors of Jaws and Casino Royale from the same country? Are follow up questions needed here: Yes. Follow up: Who is the director of Jaws? Intermediate answer: The director of Jaws is Steven Spielberg. Follow up: Where is Steven Spielberg from? Intermediate answer: The United States. Follow up: Who is the director of Casino Royale? Intermediate answer: The director of Casino Royale is Martin Campbell. Follow up: Where is Martin Campbell from? Intermediate answer: New Zealand. So the final answer is: NoQuestion: {input} Are followup questions needed here:{agent_scratchpad}可以从prompt看出通过四个例子提出了解决问题的方式即通过follow up Intermediate answer 分解问题并解决子问题。follow up是gpt的输出表示需要search tool搜索的问题 Intermediate answer 则为search tool的答案循环多次之后得到最终答案。
http://www.hkea.cn/news/14491212/

相关文章:

  • 网站设计与开发专家html网站建设方案
  • 丰金网络 做网站WordPress网站图片预加载
  • qq上网站做我女朋友网站建设网络营销平台 云搜系统
  • 企业网站建设工作流程网站怎么更改关键词
  • 网络营销从网站建设开始开一个网站要花多少钱
  • 肇庆cms建站系统网站模板种类
  • 费县网站建设足球外围网站怎么做
  • 微博网站开发平台淘宝网站的推广方案
  • 吉林建设教育协会网站seo教程书籍
  • 魏县网站建设推广wordpress寻模板
  • 武威建设银行网站网络推广外包内容
  • 网站开发费用如何记账铁岭做网站信息
  • 临沂网站改版电商类网站咋做
  • 个人博客网站开发的意义网站关键词优化多少钱
  • 可以做旅行计划的网站网站内容全屏截屏怎么做
  • 网站推广服务好公司排名网站收录做关键词排名
  • 赣州建站九江市seo
  • 建网站做淘宝客可以吗网站虚拟主机
  • 网站建设方面的销售经验一起做网店17广州沙河
  • 搜索引擎网站排名优化方案大连建设工业产品网站
  • 建设企业网站开发公司未成年人思想道德建设网站
  • 百度云自助建站wordpress会被黑吗
  • 自己做卖东西的网站庆阳市建设局网站
  • 做小程序的平台seo关键词优化方案
  • 龙华营销型网站建设公司邯郸网站建设联系电话
  • 买服务器网站wordpress与微信小程序
  • seoshanghai net重庆seo案例
  • 自己用iis怎么建设网站建设银行网站官网登录短信验证
  • 高权重网站做员会来顶排名网络科技有限公司注册资金最低
  • 用python做网站怎么赚钱做系统网站提醒有风险