【问题标题】:IBM Watson Assistant: Where to set output.user_defined object in JSON editor?IBM Watson Assistant:在 JSON 编辑器中哪里设置 output.user_defined 对象?
【发布时间】:2019-05-09 06:06:33
【问题描述】:

IBM Watson Assistant apidoc v2 表示 output.user_defined 为

“包含响应中包含的任何自定义属性的对象。此对象包括在对话 JSON 编辑器中定义的任意属性,作为对话节点输出的一部分。”

但它没有说明在 JSON 编辑器中的哪个位置进行设置。是不是输出不足?

{
  "output": {
    "text": {
      "values": [],
      "selection_policy": "sequential"
    },
    "xxx": "aaa"
  },
  "context": {}
}

无法在 JSON 编辑器中将其设置为根级别,因为编辑器会抱怨只允许输出、output.generic、动作、上下文。

我应该将它放在 JSON 编辑器的什么位置,以便它出现在 output.user_defined 中以响应 /message REST 调用?

【问题讨论】:

    标签: ibm-cloud watson-assistant


    【解决方案1】:

    您可以将其作为 user_defined 移动到 output 部分。这是我尝试过的:

      "output": {
        "text": {
          "values": [],
          "selection_policy": "sequential"
        },
        "user_defined": {
          "test": "henrik"
        }
      }
    

    然后我使用我的test tool 的 V2 API 进行验证。以下是报告方式的相关部分:

      "output": {
        "generic": [
          {
            "text": "Ok, checking the event information.", 
            "response_type": "text"
          }, 
          {
            "text": "ok.", 
            "response_type": "text"
          }
        ], 
        "debug": {...
        }, 
        "intents": [...
        ], 
        "user_defined": {
          "test": "henrik"
        }, 
        "entities": [
          {...
    

    另请参阅the IBM Watson Assistan documentation with some more information on the response JSON 中的此部分。

    【讨论】:

    • 我按照建议做了。有用。但也发现了一些有趣的东西。如果 JSON 编辑器使用 output.generic 而不是 output.text,则将附加对象放在 output.additional 下方不会在 中给出结果output.user_defined.additiona 在响应中。
    【解决方案2】:

    正如@data_henrik 上面所说,通过 JSON 编辑器添加到响应的输出部分的额外 json 元素被移动到 V2 输出响应的 user_defined 部分。

    这些“额外”的 json 元素不必标记为 user_defined。在我自己的情况下,我的对话响应中有 output.extra 元素。在 V1 中,它们仍然是 output.extra,但在 V2 中,它们变成了 output.user_defined.extra。
    当您刚刚开始时,最好保持一致并使用 output.user_defined 作为您的起点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-27
      • 1970-01-01
      • 1970-01-01
      • 2019-12-03
      • 2021-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多