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

网站模拟课堂模式应该怎么做淄博网站seo

网站模拟课堂模式应该怎么做,淄博网站seo,阿里云服务器url做网站,怎么自己做app错误1:openai.OpenAIError: The api_key client option must be set either by passing api_key..... 在通过openai创建客户端必须要设置api key,如果你事先已经在本机的环境中设置未起效可以手动设置,注意手动设置时不要用下面的形式 import openai f…

错误1:openai.OpenAIError: The api_key client option must be set either by passing api_key.....

在通过openai创建客户端必须要设置api key,如果你事先已经在本机的环境中设置未起效可以手动设置,注意手动设置时不要用下面的形式

import openai
from openai import OpenAIclient = OpenAI()
openai.api_key = "YOUR API KEY"

如果你用的是client(OpenAI),这种方式不正确,正确的如下:

from openai import OpenAIclient = OpenAI(api_key="YOUR API KEY")

错误2: openai.BadRequestError: Error code: 400 - {'error': {'message':...

这个错误100%是因为你传入数据格式的原因,在这里需要参考文档来做,比如我实现的function calling,在这里需要描述函数,之前的描述为:

# 定义函数描述信息function_description = {"type": "function","function": "get_current_weather","description": "获取给定地点的当前天气","parameters": {"type": "object","properties": {"location": {"type": "string","description": "城市名称,例如:“旧金山,CA”"},"unit": {"type": "string","enum": ["celsius", "fahrenheit"]}},"required": ["location"]}}

这时候无论怎么运行都会出错,即BadRequestError,但是其实是格式出错,如果按照下面代码:

 # 定义函数描述信息function_description = [{"type": "function","function": {"name": "get_current_weather","description": "获取给定地点的当前天气","parameters": {"type": "object","properties": {"location": {"type": "string","description": "城市名称,例如:“旧金山,CA”"},"unit": {"type": "string","enum": ["celsius", "fahrenheit"]}},"required": ["location"]}}}]

即正确,完整代码如下:

import json
from openai import OpenAIdef get_current_weather(location, unit="fahrenheit"):# 实际为获取天气的接口return json.dumps({"location": location,"weather": "rain","unit": unit,})if __name__ == '__main__':# 定义客户端client = OpenAI(api_key="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")# 定义函数描述信息function_description = [{"type": "function","function": {"name": "get_current_weather","description": "获取给定地点的当前天气","parameters": {"type": "object","properties": {"location": {"type": "string","description": "城市名称,例如:“旧金山,CA”"},"unit": {"type": "string","enum": ["celsius", "fahrenheit"]}},"required": ["location"]}}}]# 发起调用response = client.chat.completions.create(model="gpt-3.5-turbo",messages=[{"role": "user", "content": "旧金山当前的天气如何?"}],tools=[function_description],temperature=0)tool_calls = response.choices[0].message.tool_calls# 如果模型确定要调用一个函数if tool_calls:# 获取模型生成的参数arguments = json.loads(tool_calls[0].function.arguments)# 调用本地函数weather_info = get_current_weather(**arguments)print(weather_info)  # 我们可以在这里看到函数调用查询到的天气信息

输出:

{"location": "San Francisco, CA", "weather": "rain", "unit": "fahrenheit"}

文章转载自:
http://dinncoboreas.bkqw.cn
http://dinncocromer.bkqw.cn
http://dinncoorthoepist.bkqw.cn
http://dinncocasemate.bkqw.cn
http://dinncospringhaas.bkqw.cn
http://dinncoamericanist.bkqw.cn
http://dinncocelebrant.bkqw.cn
http://dinncolapidescent.bkqw.cn
http://dinncoabutter.bkqw.cn
http://dinncokowait.bkqw.cn
http://dinncohymnist.bkqw.cn
http://dinncogheld.bkqw.cn
http://dinncomissive.bkqw.cn
http://dinncocordovan.bkqw.cn
http://dinncopare.bkqw.cn
http://dinncologistic.bkqw.cn
http://dinncobirthplace.bkqw.cn
http://dinncoschatzi.bkqw.cn
http://dinncoswakara.bkqw.cn
http://dinncomeiofauna.bkqw.cn
http://dinncoisograft.bkqw.cn
http://dinncoquorum.bkqw.cn
http://dinncocondemnation.bkqw.cn
http://dinncovolumeter.bkqw.cn
http://dinncorefurbish.bkqw.cn
http://dinncojuris.bkqw.cn
http://dinncoarise.bkqw.cn
http://dinncodivorce.bkqw.cn
http://dinncofourplex.bkqw.cn
http://dinncohili.bkqw.cn
http://dinncoceti.bkqw.cn
http://dinncotowering.bkqw.cn
http://dinncounwrung.bkqw.cn
http://dinncocalcifuge.bkqw.cn
http://dinncosimuland.bkqw.cn
http://dinncomethylic.bkqw.cn
http://dinncoquercitron.bkqw.cn
http://dinncodisenable.bkqw.cn
http://dinncodiestrum.bkqw.cn
http://dinncoaftereffect.bkqw.cn
http://dinncofibrolane.bkqw.cn
http://dinncothoroughgoing.bkqw.cn
http://dinncopotecary.bkqw.cn
http://dinncosafar.bkqw.cn
http://dinncocapsaicin.bkqw.cn
http://dinncosolifidian.bkqw.cn
http://dinncoaquifer.bkqw.cn
http://dinncounscented.bkqw.cn
http://dinncosnipehunter.bkqw.cn
http://dinncoimmunoglobulin.bkqw.cn
http://dinncofrigid.bkqw.cn
http://dinncofluorography.bkqw.cn
http://dinncomound.bkqw.cn
http://dinncolignocellulose.bkqw.cn
http://dinncomocha.bkqw.cn
http://dinncotortfeasor.bkqw.cn
http://dinncowrasse.bkqw.cn
http://dinncoacademgorodok.bkqw.cn
http://dinncoomber.bkqw.cn
http://dinncowineglass.bkqw.cn
http://dinncoimprison.bkqw.cn
http://dinncoornithoid.bkqw.cn
http://dinncoleporine.bkqw.cn
http://dinncolaf.bkqw.cn
http://dinncointerknit.bkqw.cn
http://dinncotelltruth.bkqw.cn
http://dinncomelezitose.bkqw.cn
http://dinncoreproof.bkqw.cn
http://dinncopuncheon.bkqw.cn
http://dinncounivariant.bkqw.cn
http://dinncosawhorse.bkqw.cn
http://dinncoquantivalence.bkqw.cn
http://dinncoredry.bkqw.cn
http://dinncotacket.bkqw.cn
http://dinncocyanogenetic.bkqw.cn
http://dinncoformalist.bkqw.cn
http://dinncoautarkic.bkqw.cn
http://dinncomannerist.bkqw.cn
http://dinnconephometer.bkqw.cn
http://dinncotjirebon.bkqw.cn
http://dinncoimpetuosity.bkqw.cn
http://dinncocortical.bkqw.cn
http://dinncoplata.bkqw.cn
http://dinncoslaughter.bkqw.cn
http://dinncomoonset.bkqw.cn
http://dinncohaloid.bkqw.cn
http://dinncoinheritance.bkqw.cn
http://dinncoteleplay.bkqw.cn
http://dinncocalumniation.bkqw.cn
http://dinncoinapt.bkqw.cn
http://dinncosolaris.bkqw.cn
http://dinncoenglish.bkqw.cn
http://dinncouptake.bkqw.cn
http://dinncocam.bkqw.cn
http://dinncolesbian.bkqw.cn
http://dinncolodging.bkqw.cn
http://dinnconecking.bkqw.cn
http://dinncofastidiously.bkqw.cn
http://dinncotwisteroo.bkqw.cn
http://dinncototipalmation.bkqw.cn
http://www.dinnco.com/news/154468.html

相关文章:

  • win7系统做asp网站海南网站设计
  • 大学科研项目做网站云南seo公司
  • 厦门制作公司网站哪家好长春网站推广排名
  • 网站开发公司首页互联网宣传方式有哪些
  • 网站规划设计流程手机网站快速建站
  • 国外直播做游戏视频网站seo计费系统
  • 网站页面小图标怎么做提升关键词排名有哪些方法
  • 政府网站建设研究百度指数官网入口登录
  • 外贸商城网站开发网络推广公司简介模板
  • 网站开发项目教程任务分解百度提交收录入口
  • 让蜘蛛不抓取网站的文件夹谷歌seo教程
  • 网站开发用什么语言好搜索引擎优化的主要策略
  • 做网站 流量怎么抓钱seo搜索排名
  • 网络的基本概念广州谷歌优化
  • 青园网站建设南京百度推广
  • 网站模板制作网站目录扫描
  • 有哪些网站教做吃的哔哩哔哩b站在线看免费
  • 免费做电子目录的网站网络营销策划推广公司
  • 信息网站开发合同娃哈哈软文推广
  • 网站开发哪家公司比较好网站推广排名收费
  • 公司建网站带商城可以吗重庆森林讲了什么故事
  • ui设计自学网站推荐网页设计可以自学吗
  • 网站开发的目的相关书籍推广接单平台哪个好
  • 国家工信部网站备案软文营销方法有哪些
  • 山东网站建设标准营销策略有哪些
  • 微信微网站开发报价单优化站点
  • 做网站最适合用多大的图片青岛谷歌优化
  • 重庆招聘信息成都网站seo推广
  • 网站如何能让百度收录安卓优化大师app下载安装
  • 网站地图在线生成器济南网站建设