当前位置: 首页 > 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.rkmt.cn/news/76994.html

相关文章:

  • 2025喷砂机哪家好?喷砂机十大厂家排名榜单
  • 2025弯管定制加工厂/型材拉弯加工厂权威排行
  • 从复旦实验室到国际前沿:王迅院士的硬核学术人生
  • 2025杭州隔音窗品牌推荐权威排行
  • 袋式过滤器怎么选?这份深度解析与TOP报告值得参考
  • 2025电动车连接器厂家不踩坑,深圳防水连接器厂家来了
  • 人体工学椅源头工厂有哪些?2025安吉人体工学椅厂家实力榜
  • 2025年申请3A信用认证,这些高口碑机构值得选,企业信用等级认证/ROHS认证/3A信用认证办理哪家强
  • 办公椅批发供应商怎么选?2025办公椅生产厂家推荐榜
  • 2025别墅庭院花园设计公司TOP5权威推荐:专业机构甄选指
  • 2025年工业火花塞源头工厂推荐:比较好的工业火花塞源头工厂
  • 14年Java老兵亲测:用飞算JavaAI做引导式开发,新人三天交付订单系统
  • 2025年终盘点:除氟剂生产厂家TOP5推荐——技术与成本双优之选
  • 关于“4000元空调”五大AI引擎推荐结果的客观数据分析报告
  • 长途搬家公司物流推荐,深圳跨省搬家到北京、上海、杭州、长沙搬家公司推荐:哪个跨省搬家公司服务、口碑好?
  • 2025年终盘点:聚合氯化铝采购指南——高性价比厂家推荐
  • 2025英国留学中介十大排名榜
  • 2025年江阴外墙清洗专业公司推荐:比较好的外墙清洗公司有哪
  • 2025最佳英国留学中介公司
  • 2025年终盘点:聚合氯化铝厂家综合实力榜
  • 完整教程:C++ 抽象类与多态原理深度解析:从纯虚函数到虚表机制(附高频面试题)
  • 富通天下:打造数字化私域平台,福州奇富网络小额贷客服服务赋能中国外贸品牌出海!
  • 2025年建筑木模板直销厂家权威推荐榜单:建筑施工模板‌/建筑模板‌/胶合板‌‌源头厂家精选
  • vue vxe-gantt table 甘特图实现任务可拖拽自动调整日期
  • 2025源头地道肠厂家TOP5权威推荐:甄选诚信商家,原味地
  • 机器学习实践项目(二)- 房价预测增强篇 - 特征工程四 - 教程
  • 2025 年氧化铝陶瓷定制厂家最新推荐榜,技术实力与市场口碑深度解析的优质企业甄选99 氧化铝陶瓷,95 氧化铝陶瓷,绝缘陶瓷,氧化铝绝缘陶瓷公司推荐
  • 链路追踪--使用nginx-ingress-controller记录后端pod真实ip
  • 基于BP_Adaboost分类器与RBF神经网络的回归实现
  • 2025 年 12 月东莞食材配送公司权威推荐榜:生鲜食材、食堂配送服务口碑之选,精选源头直供与高效冷链