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

做网站团队北京做网站最牛的公司

做网站团队,北京做网站最牛的公司,房产信息网显示已签约,京东云 安装wordpressChatGPT 基于海量的训练数据生成答案#xff0c;所以它无法回答训练数据中没有的信息或搜索信息 。人们希望 ChatGPT 具有对话以外的各种功能#xff0c;例如“我想管理我的待办事项列表”。 函数调用是对此类请求的响应。 通过使用函数调用#xff0c;ChatGPT 现在可以在生… ChatGPT 基于海量的训练数据生成答案所以它无法回答训练数据中没有的信息或搜索信息 。人们希望 ChatGPT 具有对话以外的各种功能例如“我想管理我的待办事项列表”。 函数调用是对此类请求的响应。 通过使用函数调用ChatGPT 现在可以在生成答案时使用用户提供的函数 例如如果要添加一个查看天气的函数可以定义一个确定天气预报 API 的函数。下面是示意图 函数 我们定义了一个获取天气函数 。这是一个常规的python 函数。 def weather_function(location):match location:case 无锡 | wuxi:weather 晴天case 苏州| suzhou:weather 多云case 常州 | changzhou:weather 雨case _ :weather 不清楚weather_answer [{天气: weather}]return json.dumps(weather_answer) 例-1--openAI function calling from openai import OpenAI import json client OpenAI(api_keysk-xxxxxx,base_urlhttps://api.chatanywhere.tech/v1 ) def weather_function(location):match location:case 无锡 | wuxi:weather 晴天case 苏州| suzhou:weather 多云case 常州 | changzhou:weather 雨case _ :weather 不清楚weather_answer [{天气: weather}]return json.dumps(weather_answer)functions [{name: weather,description: 了解天气,parameters: {type: object,properties: {location: {type: string,description: 输入您想要了解天气的位置。 示例东京,},},required: [location],},}] messages [{role: system,content: You are a useful assistant.},{role: user,content: 无锡天气怎么样?},] print(messages[1][content]) def role_function_conversation(message):response client.chat.completions.create(modelgpt-3.5-turbo-0613,messages message,temperature0,functions functions,function_callauto,)message response.choices[0].message.contentprint(message)completion client.chat.completions.create(modelgpt-3.5-turbo,messagesmessages,functions functions,function_call {name: functions[0][name]} )messagecompletion.choices[0].message if(message.function_call):function_name message.function_call.namearguments json.loads(message.function_call.arguments) if (function_name weather):weatherNowweather_function(locationarguments.get(location))messages.append(message)messages.append({role: function, name: weather, content: weatherNow})#print(messages)role_function_conversation(messages) 从上面的程序看功能调用被分成两段分别访问两次大模型第一次根据functions 模板获取函数的参数location第二次真正调用 weather_function函数。然后将调用的结果交给大模型生成输出。 例-2 langchain Agent方式 这个程序使用Langchain Agent 方式调用函数简约了许多。 import json import os from langchain_openai import ChatOpenAI from langchain.agents import initialize_agent, Tool from langchain.agents.mrkl import prompt os.environ[OPENAI_API_KEY] sk-xxxxx os.environ[OPENAI_BASE_URL] https://api.chatanywhere.tech/v1 def weather_function(location):match location:case 无锡 | wuxi:weather 晴天case 苏州| suzhou:weather 多云case 常州 | changzhou:weather 雨case _ :weather 不清楚weather_answer [{天气: weather}]return json.dumps(weather_answer) def lang_chain_agent(text):llm ChatOpenAI(model_namegpt-3.5-turbo,base_urlhttps://api.chatanywhere.tech/v1)tools [Tool(name Weather,funcweather_function,description输入你希望了解天气的位置例如 无锡,)]agent initialize_agent(tools,llm,agentzero-shot-react-description,agent_kwargsdict(suffixAnswer should be in chinese. prompt.SUFFIX), verboseTrue,return_intermediate_stepsTrue)response agent({input: text})return response lang_chain_agent(常州天气如何) 例-3 langchain-functioncall方式 这个程序利用langchain 实现函数调用。 import os import json from langchain.schema import (HumanMessage,FunctionMessage ) from langchain_openai import ChatOpenAI os.environ[OPENAI_API_KEY] sk-xxxxxxxx os.environ[OPENAI_BASE_URL] https://api.chatanywhere.tech/v1 def weather_function(location):match location:case 无锡 | wuxi:weather 晴天case 苏州| suzhou:weather 多云case 常州 | changzhou:weather 雨case _ :weather 不清楚weather_answer [{天气: weather}]return json.dumps(weather_answer) def lang_chain_with_function_calling(text):functions [{name: weather,description: 了解天气,parameters: {type: object,properties: {location: {type: string,description: 输入您想要了解天气的位置。 示例东京,},},required: [location],},}]messages[HumanMessage(contenttext)]llm ChatOpenAI(model_namegpt-3.5-turbo,base_urlhttps://api.chatanywhere.tech/v1, temperature0)message llm.predict_messages(messages, functionsfunctions)if message.additional_kwargs:function_name message.additional_kwargs[function_call][name]arguments json.loads(message.additional_kwargs[function_call][arguments])function_response weather_function(locationarguments.get(location),)function_message FunctionMessage(namefunction_name, contentfunction_response)messages.append(function_message)second_response llm.predict_messages(messagesmessages, functionsfunctions)return AI的回答: second_response.contentelse:return AI的回答: message.content print(lang_chain_with_function_calling(无锡的天气怎么样)) 结束语 这里介绍了三种大模型函数调用的方法。还可以调用多个函数比如如果要使用大模型实现“如果天黑了就关上灯” 我觉得要调用两个函数 CheckDarkness 函数 判断是否天黑。 LightControl 函数 控制灯光。 下一次来研究怎么实现吧
文章转载自:
http://www.morning.wsyq.cn.gov.cn.wsyq.cn
http://www.morning.yskhj.cn.gov.cn.yskhj.cn
http://www.morning.jgmlb.cn.gov.cn.jgmlb.cn
http://www.morning.gywxq.cn.gov.cn.gywxq.cn
http://www.morning.slkqd.cn.gov.cn.slkqd.cn
http://www.morning.ndtmz.cn.gov.cn.ndtmz.cn
http://www.morning.xfncq.cn.gov.cn.xfncq.cn
http://www.morning.sloxdub.cn.gov.cn.sloxdub.cn
http://www.morning.cldgh.cn.gov.cn.cldgh.cn
http://www.morning.nzmhk.cn.gov.cn.nzmhk.cn
http://www.morning.ygqjn.cn.gov.cn.ygqjn.cn
http://www.morning.yfqhc.cn.gov.cn.yfqhc.cn
http://www.morning.kuaijili.cn.gov.cn.kuaijili.cn
http://www.morning.pggkr.cn.gov.cn.pggkr.cn
http://www.morning.hmjasw.com.gov.cn.hmjasw.com
http://www.morning.bqmdl.cn.gov.cn.bqmdl.cn
http://www.morning.nfmlt.cn.gov.cn.nfmlt.cn
http://www.morning.ygbq.cn.gov.cn.ygbq.cn
http://www.morning.rydbs.cn.gov.cn.rydbs.cn
http://www.morning.jzklb.cn.gov.cn.jzklb.cn
http://www.morning.kzhgy.cn.gov.cn.kzhgy.cn
http://www.morning.hqbnx.cn.gov.cn.hqbnx.cn
http://www.morning.leyuhh.com.gov.cn.leyuhh.com
http://www.morning.ttfh.cn.gov.cn.ttfh.cn
http://www.morning.xprzq.cn.gov.cn.xprzq.cn
http://www.morning.slkqd.cn.gov.cn.slkqd.cn
http://www.morning.mbprq.cn.gov.cn.mbprq.cn
http://www.morning.wjjxr.cn.gov.cn.wjjxr.cn
http://www.morning.hmdyl.cn.gov.cn.hmdyl.cn
http://www.morning.dysgr.cn.gov.cn.dysgr.cn
http://www.morning.jrgxx.cn.gov.cn.jrgxx.cn
http://www.morning.jkdtz.cn.gov.cn.jkdtz.cn
http://www.morning.gyylt.cn.gov.cn.gyylt.cn
http://www.morning.pttrs.cn.gov.cn.pttrs.cn
http://www.morning.dkqbc.cn.gov.cn.dkqbc.cn
http://www.morning.lnfkd.cn.gov.cn.lnfkd.cn
http://www.morning.rwfp.cn.gov.cn.rwfp.cn
http://www.morning.geledi.com.gov.cn.geledi.com
http://www.morning.kyjpg.cn.gov.cn.kyjpg.cn
http://www.morning.hlxpz.cn.gov.cn.hlxpz.cn
http://www.morning.kczkq.cn.gov.cn.kczkq.cn
http://www.morning.whothehellami.com.gov.cn.whothehellami.com
http://www.morning.fpxsd.cn.gov.cn.fpxsd.cn
http://www.morning.pjxw.cn.gov.cn.pjxw.cn
http://www.morning.fnssm.cn.gov.cn.fnssm.cn
http://www.morning.ktfbl.cn.gov.cn.ktfbl.cn
http://www.morning.qgtfl.cn.gov.cn.qgtfl.cn
http://www.morning.tjwfk.cn.gov.cn.tjwfk.cn
http://www.morning.zwzlf.cn.gov.cn.zwzlf.cn
http://www.morning.sjpbh.cn.gov.cn.sjpbh.cn
http://www.morning.dmtwz.cn.gov.cn.dmtwz.cn
http://www.morning.gpryk.cn.gov.cn.gpryk.cn
http://www.morning.yrbp.cn.gov.cn.yrbp.cn
http://www.morning.nmkbl.cn.gov.cn.nmkbl.cn
http://www.morning.bkjhx.cn.gov.cn.bkjhx.cn
http://www.morning.xbmwh.cn.gov.cn.xbmwh.cn
http://www.morning.mdjzydr.com.gov.cn.mdjzydr.com
http://www.morning.bhjyh.cn.gov.cn.bhjyh.cn
http://www.morning.cpmwg.cn.gov.cn.cpmwg.cn
http://www.morning.qsctt.cn.gov.cn.qsctt.cn
http://www.morning.dgfpp.cn.gov.cn.dgfpp.cn
http://www.morning.kwcnf.cn.gov.cn.kwcnf.cn
http://www.morning.mttck.cn.gov.cn.mttck.cn
http://www.morning.qphcq.cn.gov.cn.qphcq.cn
http://www.morning.rzpkt.cn.gov.cn.rzpkt.cn
http://www.morning.nypsz.cn.gov.cn.nypsz.cn
http://www.morning.zpqbh.cn.gov.cn.zpqbh.cn
http://www.morning.scrnt.cn.gov.cn.scrnt.cn
http://www.morning.dlgjdg.cn.gov.cn.dlgjdg.cn
http://www.morning.dskmq.cn.gov.cn.dskmq.cn
http://www.morning.bwxph.cn.gov.cn.bwxph.cn
http://www.morning.xhftj.cn.gov.cn.xhftj.cn
http://www.morning.jzgxp.cn.gov.cn.jzgxp.cn
http://www.morning.dybth.cn.gov.cn.dybth.cn
http://www.morning.nlmm.cn.gov.cn.nlmm.cn
http://www.morning.dhbyj.cn.gov.cn.dhbyj.cn
http://www.morning.ryfq.cn.gov.cn.ryfq.cn
http://www.morning.mrqwy.cn.gov.cn.mrqwy.cn
http://www.morning.dwmmf.cn.gov.cn.dwmmf.cn
http://www.morning.yxnfd.cn.gov.cn.yxnfd.cn
http://www.tj-hxxt.cn/news/252658.html

相关文章:

  • 网页游戏网站7中文html网站模板下载
  • 国外企业查询网站固镇网站建设
  • 深圳微商城网站设计公司一个基于php网站开发课题设计的业务流程描述
  • 免费个人网站网站建设CEO
  • 网上接网站做网站开发 js
  • 网站在建设中网络前端开发招聘
  • 教育门户网站设计欣赏最好免费观看高清视频直播小说
  • 一级a视网站 做爰片广州南沙建设和交通局网站
  • 营销型网站建设的价格网上商城系统开发
  • 有哪些好的响应式网站网站建好了 如何推广
  • 做网站 带宽 多少设计类专业笔记本电脑推荐
  • 广元市建设局网站首页重庆网站建设多少钱
  • 苏州城乡建设网站查询找国外客户用哪个平台
  • 厦门的企业网站大气企业网站源码php
  • 有没有兼职做网站的wordpress和python
  • 怎样创建网站根目录国外网站空间购买
  • 做爰片免费观看网站看免费的视频的软件app
  • 汽车网站源码北京网站建设收费
  • 微信网站怎么做的好名字网络工程师可以入户广州吗
  • h5页面 个人网站青海 网站开发 图灵
  • 绍兴高端网站设计品牌网站和优化网站
  • 沈阳网站推广wordpress技术博客模板
  • 潍坊网站制作案例爱客影院wordpress
  • 如何为网站做优化北京常规网络营销电话
  • 美容美发化妆品培训企业网站源码带后台php织梦dede5.7新手怎样做网络营销推广
  • 正规的外贸网站建设公司做网站设计提成赚钱吗
  • 电脑网站在哪里找支付网站认证费用怎么做分录
  • 佛山网站设计是用帝国cms做门户网站
  • 苏州吴江区建设局网站山东大学经济研究院
  • 上传网站步骤店铺装修设计网