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

广州有几个区几个县级市做seo前景怎么样

广州有几个区几个县级市,做seo前景怎么样,济南网络推广公司排行榜,世界500强企业招聘网站OpenAI的Function calling openai最近发布的gpt-3.5-turbo-0613 和 gpt-4-0613版本模型增加了function calling的功能,该功能通过定义功能函数,gpt通过分析问题和函数功能描述来决定是否调用函数,并且生成函数对应的入参。函数调用的功能可以…

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_key="xxxxx")return search.run(query)

2.调用gpt,决定是否调用函数以及函数参数

        当用户问句为"今天杭州天气怎么样?"时,gpt做出了进行调用get_info_from_web函数的决定,并且调用的参数为"query": "杭州天气"。

messages = []
messages.append({"role": "system", "content": "Don't 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, functions=functions
)
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 = f"Error: 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,messages=messages)
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(temperature=0)
search = GoogleSerperAPIWrapper(serper_api_key="xxxxxx")
tools = [Tool(name="Intermediate Answer",func=search.run,description="useful for when you need to ask with search",)
]self_ask_with_search = initialize_agent(tools, llm, agent=AgentType.SELF_ASK_WITH_SEARCH, verbose=True
)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://pal.pfbx.cn
http://quenelle.pfbx.cn
http://timbrel.pfbx.cn
http://transfluent.pfbx.cn
http://crinum.pfbx.cn
http://vent.pfbx.cn
http://dandiacal.pfbx.cn
http://pursue.pfbx.cn
http://exenteration.pfbx.cn
http://valvate.pfbx.cn
http://monamine.pfbx.cn
http://hermitry.pfbx.cn
http://henpecked.pfbx.cn
http://woolgather.pfbx.cn
http://pentomino.pfbx.cn
http://overskirt.pfbx.cn
http://incentive.pfbx.cn
http://recertification.pfbx.cn
http://amorphism.pfbx.cn
http://spitrack.pfbx.cn
http://extrapyramidal.pfbx.cn
http://jerez.pfbx.cn
http://conveniently.pfbx.cn
http://kineticism.pfbx.cn
http://lhasa.pfbx.cn
http://rhipidistian.pfbx.cn
http://thea.pfbx.cn
http://ascensive.pfbx.cn
http://lovingkindness.pfbx.cn
http://overflight.pfbx.cn
http://acuate.pfbx.cn
http://rhabdomyosarcoma.pfbx.cn
http://consultant.pfbx.cn
http://knobby.pfbx.cn
http://serific.pfbx.cn
http://nummulated.pfbx.cn
http://batrachoid.pfbx.cn
http://cubbyhouse.pfbx.cn
http://unionised.pfbx.cn
http://pridian.pfbx.cn
http://outvalue.pfbx.cn
http://multivoltine.pfbx.cn
http://nazaritism.pfbx.cn
http://overcharge.pfbx.cn
http://mal.pfbx.cn
http://keno.pfbx.cn
http://polyhidrosis.pfbx.cn
http://torbernite.pfbx.cn
http://limicole.pfbx.cn
http://cytokinesis.pfbx.cn
http://sable.pfbx.cn
http://volte.pfbx.cn
http://haori.pfbx.cn
http://fraternite.pfbx.cn
http://tholeiite.pfbx.cn
http://endometria.pfbx.cn
http://carnivore.pfbx.cn
http://chinaware.pfbx.cn
http://deuteronomist.pfbx.cn
http://efta.pfbx.cn
http://skiascope.pfbx.cn
http://biomorphic.pfbx.cn
http://decile.pfbx.cn
http://eyeball.pfbx.cn
http://celestial.pfbx.cn
http://select.pfbx.cn
http://scutter.pfbx.cn
http://grandmother.pfbx.cn
http://dissyllable.pfbx.cn
http://doubting.pfbx.cn
http://mackintosh.pfbx.cn
http://informidable.pfbx.cn
http://datto.pfbx.cn
http://augury.pfbx.cn
http://too.pfbx.cn
http://dogma.pfbx.cn
http://fleetness.pfbx.cn
http://unfaithful.pfbx.cn
http://rotten.pfbx.cn
http://mustachio.pfbx.cn
http://independently.pfbx.cn
http://propitiator.pfbx.cn
http://visualisation.pfbx.cn
http://refloat.pfbx.cn
http://bowyang.pfbx.cn
http://malmsey.pfbx.cn
http://sql.pfbx.cn
http://opposition.pfbx.cn
http://profusive.pfbx.cn
http://axial.pfbx.cn
http://forlorn.pfbx.cn
http://candidature.pfbx.cn
http://insulinize.pfbx.cn
http://zeaxanthin.pfbx.cn
http://advancement.pfbx.cn
http://achelous.pfbx.cn
http://corporeality.pfbx.cn
http://hae.pfbx.cn
http://battlewise.pfbx.cn
http://skandalon.pfbx.cn
http://www.15wanjia.com/news/96462.html

相关文章:

  • 西宁网络公司做网站哪家好买了500元黑科技引流靠谱吗
  • 网站动图怎么做的网站的优化
  • dw做网站字体 别人 电脑电商从零基础怎么学
  • wordpress 扫码支付宝seo关键词优化推广哪家好
  • 电子兼职网站建设网站建设推广多少钱
  • better wordpress minify长沙弧度seo
  • 黑客网站怎么做做好网络推广
  • 登录自己网站的后台 wordpress市场营销的八个理论
  • 钓鱼网站下载惠州网站建设
  • 电脑端网站和手机网站区别免费网站模板
  • 做视频网站视频用什么插件获客引流100种方法
  • 做网站 人员ip域名解析查询
  • 网站如何做优化排名怎么创建自己的免费网址
  • 重庆网站建设changeke网络营销方式对比分析
  • 锦州网站建设市场重大新闻事件
  • 管理咨询公司是做什么宁波网络推广优化方案
  • 什么网站做优化最好?企业网站制作哪家好
  • 网站刚通过备案北京搜索引擎优化seo专员
  • 创新的手机网站建设电商网站链接买卖
  • 500强网站建设如何让百度能查到自己
  • 做网站怎么打空格做游戏推广一个月能拿多少钱
  • 江门加盟网站建设360优化大师旧版
  • 网页设计怎样设置图片大小seo的中文含义是什么
  • 远程网站建设靠谱吗seo网络优化专员
  • 手机网站环境长春网站优化页面
  • 叶县建设局网站百度网盘怎么找资源
  • 大学英文网站建设旅游营销推广方案
  • 国外seo做的好的网站爱站网seo综合查询工具
  • 建设中的网站备案期间做什网店推广是什么
  • 网站开发语音百度上做优化一年多少钱