尧图网站建设 尧图网络
  • 首页
  • 关于我们
  • 服务项目
  • 案例展示
  • 建站流程
  • 资讯中心
  • 联系我们
首页/资讯中心/详情

---1

---1
📅 发布时间:2026/6/17 22:19:59

BadRequestError Traceback (most recent call last)
Cell In[12], line 5
1 # 第一次请求调用大模型
2 messages = [
3 {"role": "user", "content": "明天北京天气咋样?"}
4 ]
----> 5 response = client.chat.completions.create(
6 model = MODEL_NAME,
7 messages = messages,
8 tools = tools # 注意,tools是可以定义多个的
9 )

File D:\aitest\code\pk-llm-test\.venv\Lib\site-packages\openai\_utils\_utils.py:286, in required_args.<locals>.inner.<locals>.wrapper(*args, **kwargs)
284 msg = f"Missing required argument: {quote(missing[0])}"
285 raise TypeError(msg)
--> 286 return func(*args, **kwargs)

File D:\aitest\code\pk-llm-test\.venv\Lib\site-packages\openai\resources\chat\completions\completions.py:1156, in Completions.create(self, messages, model, audio, frequency_penalty, function_call, functions, logit_bias, logprobs, max_completion_tokens, max_tokens, metadata, modalities, n, parallel_tool_calls, prediction, presence_penalty, prompt_cache_key, reasoning_effort, response_format, safety_identifier, seed, service_tier, stop, store, stream, stream_options, temperature, tool_choice, tools, top_logprobs, top_p, user, verbosity, web_search_options, extra_headers, extra_query, extra_body, timeout)
1110 @required_args(["messages", "model"], ["messages", "model", "stream"])
1111 def create(
1112 self,
(...) 1153 timeout: float | httpx.Timeout | None | NotGiven = not_given,
1154 ) -> ChatCompletion | Stream[ChatCompletionChunk]:
1155 validate_response_format(response_format)
-> 1156 return self._post(
1157 "/chat/completions",
1158 body=maybe_transform(
1159 {
1160 "messages": messages,
1161 "model": model,
1162 "audio": audio,
1163 "frequency_penalty": frequency_penalty,
1164 "function_call": function_call,
1165 "functions": functions,
1166 "logit_bias": logit_bias,
1167 "logprobs": logprobs,
1168 "max_completion_tokens": max_completion_tokens,
1169 "max_tokens": max_tokens,
1170 "metadata": metadata,
1171 "modalities": modalities,
1172 "n": n,
1173 "parallel_tool_calls": parallel_tool_calls,
1174 "prediction": prediction,
1175 "presence_penalty": presence_penalty,
1176 "prompt_cache_key": prompt_cache_key,
1177 "reasoning_effort": reasoning_effort,
1178 "response_format": response_format,
1179 "safety_identifier": safety_identifier,
1180 "seed": seed,
1181 "service_tier": service_tier,
1182 "stop": stop,
1183 "store": store,
1184 "stream": stream,
1185 "stream_options": stream_options,
1186 "temperature": temperature,
1187 "tool_choice": tool_choice,
1188 "tools": tools,
1189 "top_logprobs": top_logprobs,
1190 "top_p": top_p,
1191 "user": user,
1192 "verbosity": verbosity,
1193 "web_search_options": web_search_options,
1194 },
1195 completion_create_params.CompletionCreateParamsStreaming
1196 if stream
1197 else completion_create_params.CompletionCreateParamsNonStreaming,
1198 ),
1199 options=make_request_options(
1200 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
1201 ),
1202 cast_to=ChatCompletion,
1203 stream=stream or False,
1204 stream_cls=Stream[ChatCompletionChunk],
1205 )

File D:\aitest\code\pk-llm-test\.venv\Lib\site-packages\openai\_base_client.py:1259, in SyncAPIClient.post(self, path, cast_to, body, options, files, stream, stream_cls)
1245 def post(
1246 self,
1247 path: str,
(...) 1254 stream_cls: type[_StreamT] | None = None,
1255 ) -> ResponseT | _StreamT:
1256 opts = FinalRequestOptions.construct(
1257 method="post", url=path, json_data=body, files=to_httpx_files(files), **options
1258 )
-> 1259 return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))

File D:\aitest\code\pk-llm-test\.venv\Lib\site-packages\openai\_base_client.py:1047, in SyncAPIClient.request(self, cast_to, options, stream, stream_cls)
1044 err.response.read()
1046 log.debug("Re-raising status error")
-> 1047 raise self._make_status_error_from_response(err.response) from None
1049 break
1051 assert response is not None, "could not resolve response (should never happen)"

BadRequestError: Error code: 400 - {'error': {'message': 'Failed to deserialize the JSON body into the target type: tools[0]: missing field `function` at line 1 column 404', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_request_error'}}

相关新闻

  • 2025喷砂机哪家好?喷砂机十大厂家排名榜单
  • 2025弯管定制加工厂/型材拉弯加工厂权威排行
  • 从复旦实验室到国际前沿:王迅院士的硬核学术人生

最新新闻

  • 闲置手表别乱卖❗️大连20年老店回收不踩坑✨ - 奢品小当家
  • 2026 无锡防水修缮优选:吉修匠深耕太湖运河水乡腹地,专攻卫生间超长梅雨季高湿淤软黏土滨湖弱酸返渗丘陵裂隙长效止水 - 吉修匠
  • 哈尔滨正规黄金回收门店排行,精选六家靠谱渠道盘点 - 奢侈品回收测评
  • 苏州晟雅泰电子:NT5CC64M16GP-DI这个物料的参数和应用领域剖析
  • 探索模块化AI创作引擎:构建高效扩散模型工作流的完整指南
  • 大模型推理成本如何导致AI回答错误率飙升

日新闻

  • 2026年不锈钢卷板厂家推荐排行榜:冷轧热轧/304/201不锈钢卷板,高颜值耐腐蚀源头厂家实力精选 - 企业推荐官【官方】
  • FLUX.1-dev FP8模型实战指南:24GB以下显卡高效部署方案
  • 2026佛山长途搬家价目表:跨省跨市搬家费用完整计算指南 - 从来都是英雄出少年

周新闻

  • 3步解锁iOS设备:applera1n激活锁绕过完全指南
  • 39 2026 人工智能证书终极盘点,普通人选 AI 证书可以从这些方向入手
  • Redis 暴露公网有多危险?从端口检查到补救步骤

月新闻

  • 【总结】入门篇:50句话让你记住架构核心概念
  • WeChatMsg技术方案解析:实现Mac微信数据自主管理的完整解决方案
  • WeChatMsg:革新性微信数据备份方案,打造你的专属数字记忆库

关于尧图

  • 公司简介
  • 团队介绍
  • 企业文化
  • 荣誉资质

服务项目

  • 定制开发
  • 电商建站
  • UI 设计
  • 运维服务

快速链接

  • 案例展示
  • 建站流程
  • 常见问题
  • 资讯中心

联系方式

  • 📍北京市朝阳区互联网产业园 A 座 10 层
  • 📞400-888-8888
  • ✉️contact@rkmt.cn
  • 🕐周一至周日 9:00-21:00

© 2024 北京尧图网络科技有限公司 版权所有 | 京 ICP 备 XXXXXXXX 号