【问题标题】:Intents get changed with every input Watson Conversation(new name Watson Assistant)?每次输入 Watson Conversation(新名称 Watson Assistant)时,意图都会改变?
【发布时间】:2018-03-25 12:15:38
【问题描述】:

一旦应用程序(Java Web 应用程序)连接了一个对话,就需要传回相同的上下文。但是每次我发送输入(文本到 Watson)时,意图都会改变(不同的节点),它不会保持相同的意图。为什么? 我在哪里犯错?

public class TestConversation {

    public static void main(String[] args) {
        BufferedReader br = null;
        MessageResponse response = null;
        Map context = new HashMap();

        try {
            br = new BufferedReader(new InputStreamReader(System.in));

            String userName = br.readLine();
            // Add userName to context to be used by Conversation.
            context.put("userName", userName);

            while (true) {
                String input = br.readLine();
                response = conversationAPI(input, context);
                System.out.println("Watson Response: " + response.getText().get(0));
                context = response.getContext();
                System.out.println("———–");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static MessageResponse conversationAPI(String input, Map context) {
        ConversationService service = new ConversationService(ConversationService.VERSION_DATE_2016_07_11);

        // Credentials of Workspace of Conversation
        service.setUsernameAndPassword("******************", "****************");
        MessageRequest newMessage = new MessageRequest.Builder().inputText(input).context(context).build();

        // Workspace ID of Conversation current workspace
        String workspaceId = "******************";
        MessageResponse response = service.message(workspaceId, newMessage).execute();
        return response;
    }

}

[附上代码截图][1]

[]:https://i.stack.imgur.com/bym6u.png

【问题讨论】:

  • 是否找到正确的对话节点,然后根据输入进行处理?你的问题不清楚。
  • @data_henrik 不,它总是去其他节点(不同)

标签: java watson-conversation


【解决方案1】:

将分析您发送回对话的每个输入,然后返回所写内容的意图 + 实体。

如果您的对话流程设置正确以忽略它,它应该没有影响。

如果你想强制它,你可以发送intents[]entities[] in。它将禁用检查并假设这些是找到的值。

【讨论】:

  • 问题是当我在 Eclipse 中运行(java)应用程序时,它工作正常,但是当我将它部署到 tomcat 并与 Facebook Messenger 集成时,Bot 无法识别输入并回复“我没看懂。你可以试试改写。”我不明白这个问题。因为机器人在 Watson 和 eclipse 中运行良好。
猜你喜欢
  • 1970-01-01
  • 2020-11-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-12-12
  • 2019-07-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多