IBM WATSON Unity SDK 无法到达子节点

IBM WATSON Unity SDK can't reach child node

我带着更多问题回来了。我使用的是 Unity 5.5.1f1 和 Watson Developer Cloud Unity SDK v0.13.0。我没有使用小部件,而是使用了 Watson/Examples/ServiceExamples/Scripts 中的脚本,它们运行良好,并且我能够启动对话服务。但是,我很快意识到使用此设置,我似乎无法访问子节点。请查看下面的对话编辑器屏幕截图:

如果我在线测试这段对话,结果会是这样:

Watson: Hello, welcome to the paradise!
Me: Can you turn off the music please. 
Watson: Ok, let's turn off something, you can say music, ac, and lights.
Me: music
Watson: ok, turn the music off. [child node]

但是,当我通过 Unity 执行此操作时,它变成了:

Watson: Hello, welcome to the paradise!
Me: Can you turn off the music please. 
Watson: Ok, let's turn off something, you can say music, ac, and lights.
Me: music
Watson: say what? [anything_else node]

对话好像只停留在父节点,根本没有到达子节点。或者也许发送到服务器的每条消息都会重置服务?请帮忙!!

最佳,

为了到达子节点,您需要在请求中传递上下文。在响应中会有一个 context 属性 你可以传递给下一个请求。

Conversation m_Conversation = new Conversation();

private void SendInitalMessage(string input)
{
  if (string.IsNullOrEmpty(input))
    throw new ArgumentNullException("input");

  //  Send inital message to the service
  m_Conversation.Message(OnInitalMessage, <workspace-id>, input);
}



private void OnInitalMessage(MessageResponse resp, string customData)
{
    if (resp != null)
    {
        //  Check response here

        //  Create a message request object with the context
        MessageRequest messageRequest = new MessageRequest();
        messageRequest.InputText = <input-text>;
        messageRequest.alternate_intents = true;
        messageRequest.ContextData = resp.context; // Context of the conversation

        //  Send the second message
        SendFollowupMessage(messageRequest);
    }
    else
    {
       Debug.Log("Message Only: Failed to invoke Message();");
    }
}


private void SendFollowupMessage(MessageRequest messageRequest)
{
    if (messageRequest == null)
        throw new ArgumentNullException("messageRequest");

    m_Conversation.Message(OnFollowupMessage, <workspace-id>, messageRequest);
}


private void OnFollowupMessage(MessageResponse resp, string customData)
{
    if (resp != null)
    {
        // Check response here
    }
    else
    {
        Debug.Log("Full Request: Failed to invoke Message();");
    }
}

上下文对象包含 conversationID 和其他数据,供服务跟踪用户在对话中的位置。

"context": {
    "conversation_id": "<conversation-id>",
    "system": {
        "dialog_stack": [
            {
                "dialog_node": "<dialog-node>"
            }
        ],
        "dialog_turn_counter": <turn-counter>,
        "dialog_request_counter": <request-counter>,
        "branch_exited": <branch-exited>,
        "branch_exited_reason": "<exited-reason>"
     },
     "defaultCounter": <default-counter>
}

编辑:数据模型似乎已更新。 resp.context.system.dialog_stack 不应该是字符串数组。它应该是一个 RuntimeDialogStack 对象数组。

[fsObject]
SystemResponse
{
    public RuntimeDialogStack[] dialog_stack {get;set;}
    public int dialog_turn_counter {get;set;}
    public int dialog_request_counter {get;set;}
}

[fsObject]
public class RuntimeDialogStack 
{
    public string dialog_node {get;set;} 
    public bool invoked_subdialog {get;set;}
}

编辑 2:看起来我一直在使用不匹配的版本字符串进行测试。请尝试此数据模型并确保 VisualRecognition 数据模型中的版本参数为 2017-02-03

[fsObject]
SystemResponse
{
    public DialogNode[] dialog_stack {get;set;}
    public int dialog_turn_counter {get;set;}
    public int dialog_request_counter {get;set;}
}

[fsObject]
DialogNode
{
    public string dialog_node {get;set;}
    public bool invoked_subdialog {get;set;}
}