/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”的架构无效:None 不是“array”类型。(请求ID: 20250903110948261917640BBDOPt2p)
2. 原因分析
self_intent_recognition_0的参数架构(Schema)中,某字段预期类型为array,但实际传入了None值。None)。3.解决方案
以Python OpenAI Function Calling为例,修复Schema定义与传参:
from openai import OpenAI
client = OpenAI()
# 修复后的函数Schema(明确数组字段+默认值)
functions = [
{
"name": "self_intent_recognition_0",
"parameters": {
"type": "object",
"properties": {
"target_array_field": { # 假设问题字段为target_array_field
"type": "array",
"items": {"type": "string"}, # 数组元素类型(按需调整)
"default": [] # 用空数组替代None作为默认值
}
},
"required": ["target_array_field"]
}
}
]
# 调用时传数组(空数组或有效值,禁止None)
response = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": "测试"}],
functions=functions,
function_call={
"name": "self_intent_recognition_0",
"arguments": {"target_array_field": []} # 传空数组而非None
}
)
4. 预防措施
None混入数组字段。isinstance(param, list)检查),强制数组字段传list类型(空数组[]优于None)。---
分析完成,如需进一步调试请提供完整Schema定义或调用代码片段。