【问题标题】:IBM Watson Conversation API DOC not presentIBM Watson 对话 API 文档不存在
【发布时间】:2017-07-09 12:50:33
【问题描述】:

关于 IBM Watson 文档 https://www.ibm.com/watson/developercloud/conversation/api/v1/?curl#introduction

我看的是唯一的 CURL 请求示例。 我需要Java请求示例

你能帮帮我吗?

【问题讨论】:

    标签: ibm-cloud ibm-watson watson watson-conversation


    【解决方案1】:
    【解决方案2】:

    首先,添加 Maven 依赖项:

    <dependency>
      <groupId>com.ibm.watson.developer_cloud</groupId>
      <artifactId>java-sdk</artifactId>
      <version>3.3.1</version>
    </dependency>
    

    使用 Gradle 编译:com.ibm.watson.developer_cloud:java-sdk:3.3.1

    并使用following 代码请求对话服务:

    ConversationService service = new ConversationService(ConversationService.VERSION_DATE_2017_03_02);
    service.setUsernameAndPassword("<username>", "<password>");
    
    MessageRequest newMessage = new MessageRequest.Builder().inputText("Hi").build();
    MessageResponse response = service.message("<workspace-id>", newMessage).execute();
    System.out.println(response);
    //Moving from Node 1 to Node 2.
    
    Map<String, Object> context = new HashMap<String, Object>();
    
    // first message
    MessageRequest newMessage = new MessageRequest.Builder()
        .input(new InputData.Builder("First message").build())
        .context(context)
        .build();
    
    MessageResponse response = service.message("<workspace-id>", newMessage).execute();
    
    // second message
    newMessage = new MessageRequest.Builder()
        .input(new InputData.Builder("Second message").build())
        .context(response.getContext()) // output context from the first message
        .build();
    
    response = service.message("<workspace-id>", newMessage).execute();
    
    System.out.println(response);
    

    查看来自 IBM Developers 的 Java SDK 内的代码。

    我想你可以用Conversation and Discovery 点赞这个项目来验证其他例子。

    【讨论】:

      【解决方案3】:

      新版 Watson Assistant(以前称为 Conversation)API 参考文档包括 Java 示例:https://console.bluemix.net/apidocs/assistant?language=java

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-10-11
        • 2016-09-20
        • 1970-01-01
        • 2017-03-17
        • 1970-01-01
        • 2017-05-28
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多