/MainProcess] 22208184909825/agent-e80a0 agent invoke chat to retry again llm er...
错误信息
[2025-09-03 11:10:25,969: ERROR/MainProcess] 22208184909825/agent-e80a0 agent invoke chat to retry again llm error: Error code: 400 - {'error': {'message': "Invalid schema for function 'self_intent_recognition_0': None is not of type 'array'. (request id: 20250903110948261917640BBDOPt2p)", 'type': 'openai_error', 'param': '', 'code': 'invalid_function_parameters'}}
AI 解决方案
报错分析报告
1.错误翻译
原文:Invalid schema for function 'self_intent_recognition_0': None is not of type 'array'. (request id: 20250903110948261917640BBDOPt2p)
译文:函数'self_intent_recognition_0'的schema无效:None不是array类型。(请求ID: 20250903110948261917640BBDOPt2p)
2. 原因分析
self_intent_recognition_0的参数schema定义中,某字段预期为array类型,但实际传入了None值。 3.解决方案
需确保函数参数为非空array类型(或设置默认空数组)。以下是修复示例:
#### 方案1:修正Function Schema(JSON Schema)
{
"name": "self_intent_recognition_0",
"description": "自意图识别函数",
"parameters": {
"type": "object",
"properties": {
"intents": {
"type": "array", // 明确类型为array
"items": { "type": "string" },
"default": [] // 避免None,设默认空数组
}
},
"required": ["intents"] // 标记为必填(按需调整)
}
}
#### 方案2:修正调用参数(Python示例)
# 调用LLM Function时传递合法array参数(而非None)
import openai
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo-0613",
messages=[{"role": "user", "content": "测试"}],
functions=[{
"name": "self_intent_recognition_0",
"parameters": {
"type": "object",
"properties": {
"intents": {"type": "array", "items": {"type": "string"}}
}
}
}],
function_call={"name": "self_intent_recognition_0"},
function_arguments={"intents": []} # 传空数组或实际值(如["查询订单"])
)
4. 预防措施
None混入array字段。