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

---1

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'}}

http://www.jsqmd.com/news/66458/

相关文章:

  • 2025保安过滤器厂家综合实力榜TOP3:上海青上过滤以技术革新领跑行业
  • 2025靠谱注塑加工厂家推荐:产能与精度双在线
  • 2025英国留学中介机构排行榜最新
  • Q:Word 文档,vbs脚本,批量标准化表格(统一表格宽度、内边距及布局样式)
  • 2025英国留学中介哪个好
  • OEM ESCL Simulator for VW Touareg, Audi A8, Porsche Cayenne Bentley: Immobilizer Repair 2004-2015
  • 2025喷砂机哪家好?喷砂机十大厂家排名榜单
  • 使用 aardio 写一个基于pyocd的单片机下载器
  • 混合机厂家口碑榜:本地直销TOP10强推荐,槽型混合机/混合机/烘箱/对开门烘箱/泳池专用臭氧发生器/脱硝臭氧发生器混合机品牌排行
  • 2025年盘点:3A信用认证申请优质服务商口碑榜,ISO20000/知识产权认证/企业信用认证/3A信用认证代理口碑推荐榜
  • 2025不锈钢半管加工厂综合实力榜单
  • 2025年度竹木地板加工厂TOP5实力推荐:竹木地板厂家哪家
  • 2025弯管定制加工厂/型材拉弯加工厂权威排行
  • 从复旦实验室到国际前沿:王迅院士的硬核学术人生
  • 2025深度测评!多个中国防伪印刷工厂品质揭秘
  • 2025杭州隔音窗品牌推荐权威排行
  • 袋式过滤器怎么选?这份深度解析与TOP报告值得参考
  • 2025盘管加工生产厂家/中频热弯加工厂家综合榜单
  • 2025年中国五大园艺火花塞生产厂家推荐:有实力的园艺火花塞
  • 2025防水涂料哪个品牌好:知名的防水涂料品牌推荐对比
  • 在嵌入式Linux系统上使用LiteLLM部署轻量级语言模型全攻略
  • 2025年申请3A信用认证,这些高口碑机构值得选,企业信用等级认证/ROHS认证/3A信用认证办理哪家强
  • 2025电动车连接器厂家不踩坑,深圳防水连接器厂家来了
  • 人体工学椅源头工厂有哪些?2025安吉人体工学椅厂家实力榜
  • 小程序与APP的区别
  • 2025尺码扣厂家推荐:四眼钮扣厂家哪家好?口碑清单收好
  • 使用ai的方法给epub文件中的汉字加拼音
  • 办公椅批发供应商怎么选?2025办公椅生产厂家推荐榜
  • 2025年12月分散剂厂家最新推荐:高效决策清单
  • [ABC194C] Squared Error