Invalid JSON payload received. Unknown name "patternProperties" at 'tools[0].fun...

2026年04月17日 09:36 processing

错误信息

Invalid JSON payload received. Unknown name "patternProperties" at 'tools[0].function_declarations[3].***.properties[4].value': Cannot find field. Invalid JSON payload received. Unknown name "const" at 'tools[0].function_declarations[35].***.properties[0].value': Cannot find field. Invalid JSON payload received. Unknown name "const" at 'tools[0].function_declarations[44].***.properties[7].value.any_of[0]': Cannot find field. Invalid JSON payload received. Unknown name "const" at 'tools[0].function_declarations[44].***.properties[7].value.any_of[1]': Cannot find field. Invalid JSON payload received. Unknown name "const" at 'tools[0].function_declarations[44].***.properties[7].value.any_of[2]': Cannot find field.

AI 解决方案

报错分析

1.错误翻译


原文:Invalid JSON payload received. Unknown name "patternProperties" at 'tools[0].function_declarations[3].***.properties[4].value': Cannot find field.
译文:收到无效的JSON负载。在路径'tools[0].function_declarations[3].***.properties[4].value'处找到未知名称"patternProperties":无法找到该字段。

原文:Invalid JSON payload received. Unknown name "const" at 'tools[0].function_declarations[35].***.properties[0].value': Cannot find field.
译文:收到无效的JSON负载。在路径'tools[0].function_declarations[35].***.properties[0].value'处找到未知名称"const":无法找到该字段。

2. 原因分析


  • 根本原因:JSON负载中使用了DMXAPI平台不支持的字段(patternPropertiesconst),这些字段不在函数声明的Schema定义中。

  • 具体位置tools[0].function_declarations数组内多个对象的propertiesany_of子字段中,错误使用了未定义的Schema关键字。
  • 3.解决方案


    移除/替换不支持的字段,使用平台兼容的Schema语法:

    {
      "tools": [
        {
          "function_declarations": [
            {
              "***": {
                "properties": [
                  {},
                  {},
                  {},
                  {},
                  {
                    "value": {
                      // 替换patternProperties为支持的字段(如properties)
                      "properties": { /* 原patternProperties的内容 */ }
                    }
                  }
                ]
              }
            },
            {
              "***": {
                "properties": [
                  {
                    "value": "固定值" // 替换const为直接赋值
                  }
                ]
              }
            },
            {
              "***": {
                "properties": [
                  {
                    "value": {
                      "any_of": [
                        { "type": "string" }, // 替换const为具体类型/值
                        { "type": "number" }
                      ]
                    }
                  }
                ]
              }
            }
          ]
        }
      ]
    }
    

    4.️ 预防措施


  • ✅ 使用JSON Schema验证工具(如[AJV](https://ajv.js.org/)、[QuickType](https://quicktype.io/))提前校验payload;

  • ✅ 严格参照[DMXAPI函数声明Schema文档](https://platform.openai.com/docs/api-reference/chat/create#chat-create-tools),禁用未定义的字段(patternProperties/const等)。
  • ---
    请修正JSON负载后重新提交。