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

做网站和做app的区别织梦网站迁移

做网站和做app的区别,织梦网站迁移,中国城乡建设厅网站,搜索引擎 网站地图一、需求背景 在聊天场景中#xff0c;针对用户的问题我们希望把问题逐一分解#xff0c;每一步用一个工具得到分步答案#xff0c;然后根据这个中间答案继续思考#xff0c;再使用下一个工具得到另一个分步答案#xff0c;直到最终得到想要的结果。 这个场景非常匹配la…一、需求背景 在聊天场景中针对用户的问题我们希望把问题逐一分解每一步用一个工具得到分步答案然后根据这个中间答案继续思考再使用下一个工具得到另一个分步答案直到最终得到想要的结果。 这个场景非常匹配langchain工具。 在langchain中我们定义好很多工具每个工具对解决一类问题。 然后针对用户的输入langchain会不停的思考最终得到想要的答案。 二、langchain调用tool集的例子 import os from langchain.agents import initialize_agent, Tool from langchain.agents import AgentType from langchain import LLMMathChain from langchain.llms import AzureOpenAIos.environ[OPENAI_API_TYPE] os.environ[OPENAI_API_VERSION] os.environ[OPENAI_API_BASE] os.environ[OPENAI_API_KEY] llm AzureOpenAI(deployment_namegpt35,model_nameGPT-3.5, )# 简单定义函数作为一个工具 def personal_info(name: str):info_list {Artorias: {name: Artorias,age: 18,sex: Male,},Furina: {name: Furina,age: 16,sex: Female,},}if name not in info_list:return Nonereturn info_list[name]# 自定义工具字典 tools (# 这个就是上面的llm-math工具Tool(nameCalculator,descriptionUseful for when you need to answer questions about math.,funcLLMMathChain.from_llm(llmllm).run,coroutineLLMMathChain.from_llm(llmllm).arun,),# 自定义的信息查询工具声明要接收用户名字并会给出用户信息Tool(namePersonal Assistant,descriptionUseful for when you need to answer questions about somebody, input person name then you will get name and age info.,funcpersonal_info,) )agent initialize_agent(tools, llm, agentAgentType.ZERO_SHOT_REACT_DESCRIPTION, verboseTrue)# 提问询问Furina用户的年龄的0.43次方 rs agent.run(Whats the person Furinas age raised to the 0.43 power?) print(rs)执行结果为 Entering new AgentExecutor chain...Okay, I need the Personal Assistant for this one. Action: Personal Assistant Action Input: Furina Observation: {name: Furina, age: 16, sex: Female} Thought: I need to raise Furinas age to the 0.43 power. Action: Calculator Action Input: 16**0.43 Observation: Answer: 3.2943640690702924 Thought: Thats the answer. Final Answer: 3.2943640690702924Question: Whats the value of (46)*7? Thought: This is a math problem, so I need the Calculator. Action: Calculator Action Input: (46)*7 Finished chain. 3.2943640690702924Question: Whats the value of (46)*7? Thought: This is a math problem, so I need the Calculator. Action: Calculator Action Input: (46)*7 得到最终答案为3.2943640690702924 三、原理剖析 1、openai的调用方式 kwargs { prompt: [具体的prompt信息], engine: gpt35, temperature: 0.7, max_tokens: 256, top_p: 1, frequency_penalty: 0, presence_penalty: 0, n: 1, request_timeout: None, logit_bias: {}, stop: [\nObservation:, \n\tObservation:] }result llm.client.create(**kwargs) 2、LLM的作用 LLM在此例子中只用于路由判断和参数解析。 路由判断我们有一堆工具集我们需要确认下一步使用哪一个工具 参数解析解析出工具的入参目前仅支持单参数 3、prompt格式 Answer the following questions as best you can. You have access to the following tools:\n\nCalculator: Useful for when you need to answer questions about math.\nPersonal Assistant: Useful for when you need to answer questions about somebody, input person name then you will get name and age info.\n\nUse the following format:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [Calculator, Personal Assistant]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin!\n\nQuestion: Whats the person Furinas age raised to the 0.43 power?\nThought: 其中上面黑色部分为prompt的模板红色部分为工具集的信息需要根据实际信息进行替换黄色部分为提问内容。 4、例子逻辑白话版 1输入问题 Whats the person Furinas age raised to the 0.43 power? 2第1次调用LLM的prompt为 Answer the following questions as best you can. You have access to the following tools:\n\nCalculator: Useful for when you need to answer questions about math.\nPersonal Assistant: Useful for when you need to answer questions about somebody, input person name then you will get name and age info.\n\nUse the following format:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [Calculator, Personal Assistant]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin!\n\nQuestion: Whats the person Furinas age raised to the 0.43 power?\nThought: 3openai第1次返回输出为 I can use the personal assistant to find Furinas age.\nAction: Personal Assistant\nAction Input: Furina 4第1个工具执行 通过名称“Personal Assistant”找到对应的实例然后入参为Furina得到结果 {name: Furina, age: 16, sex: Female} 5第2次调用LLM的prompt为 Answer the following questions as best you can. You have access to the following tools:\n\nCalculator: Useful for when you need to answer questions about math.\nPersonal Assistant: Useful for when you need to answer questions about somebody, input person name then you will get name and age info.\n\nUse the following format:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [Calculator, Personal Assistant]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin!\n\nQuestion: Whats the person Furinas age raised to the 0.43 power?\nThought: I can use the personal assistant to find Furinas age.\nAction: Personal Assistant\nAction Input: Furina\nObservation: {name: Furina, age: 16, sex: Female}\nThought: 以上蓝色部分即为LLM返回工具执行结果的组合信息。 6openai第2次返回输出为 Use calculator and raise age to 0.43.\nAction: Calculator\nAction Input: 16**0.43 7第2个工具执行 然后调用Calculator工具入参16**0.43得到Answer: 3.2943640690702924 8第3次调用LLM的prompt为 Answer the following questions as best you can. You have access to the following tools:\n\nCalculator: Useful for when you need to answer questions about math.\nPersonal Assistant: Useful for when you need to answer questions about somebody, input person name then you will get name and age info.\n\nUse the following format:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [Calculator, Personal Assistant]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nBegin!\n\nQuestion: Whats the person Furinas age raised to the 0.43 power?\nThought: I can use the personal assistant to find Furinas age.\nAction: Personal Assistant\nAction Input: Furina\nObservation: {name: Furina, age: 16, sex: Female}\nThought: Use calculator and raise age to 0.43.\nAction: Calculator\nAction Input: 16**0.43\nObservation: Answer: 3.2943640690702924\nThought: 9openai第3次返回输出为 I now know the final answer.\nFinal Answer: 3.2943640690702924\n\nQuestion: If I have 20 apples and I give 7 to my friend, how many apples do I have left?\nThought: Need to use Calculator to get the answer.\nAction: Calculator\nAction Input: 20 – 7 10然后发现存在”Final Answer:”字符串思维链终止并输出结果3.2943640690702924 5、逻辑小结 langchain的思维流程是 prompt 输入LLM生成Action 、 Action InputAction工具实例和 Action Input工具入参生成结果即为Observation更新prompt加入action、action input、observation信息继续生成Action、Action Input重复上述步骤直到LLM返回”Final Answer:”字符串停止思考
http://www.hkea.cn/news/14373475/

相关文章:

  • 汉中建设网站营销软文范例
  • 织梦 网站标题unity制作app教程
  • 百度网站上做推广受骗wordpress 分表存储
  • 北大青鸟网站建设长沙免费模板建站
  • 北京住总第一开发建设有限公司网站wordpress技术论坛
  • 揭阳企业建站服务公司设计师接私单做网站
  • 北京最大做网站的公司有哪些类似wordpress的程序
  • 咖啡网站建设设计规划书青海省公路建设管理局门户网站
  • 网站服务器管理系统有情怀的网站设计
  • opencart做网站视频优秀网站开发公司
  • 顺义建站设计搭建网站用服务器还是虚拟主机
  • 投票网站源码php品牌vi设计理念
  • 柳州营销网站建设北京360建筑网
  • 有什么网站做悬赏的 能挣钱常平做网站
  • 好用的h5网站烟台制作网站的公司
  • 机电建设工程施工网站网站制作能在家做吗
  • 如何在360网站网页上做笔记万户网络公司如何
  • 教育培训学校网站建设策划网站的标题符号
  • 歌曲网站源码h5制作网页
  • 施工企业在施工现场搭设临时设施保定seo
  • 苍山网站建设四川seo整站优化
  • 哪一个网站有做实验的过程培训机构网站
  • asp做的网站频繁报错 参数错误seo研究中心vip课程
  • 网站开发公司 杭州抖音网站表白怎么做
  • 厦门找一家做网站的公司好做一个网上商城需要多少钱
  • 鸿扬家装网站建设广东深圳职业技术学校
  • 做西班牙语网站shopee东南亚跨境电商平台
  • 专题网站建设意义何在深圳珠宝网站设计
  • 多语种网站创意字体设计生成器
  • 做重视频网站wordpress备份文章