watson-developer-cloud / java-sdk

:1st_place_medal: Java SDK to use the IBM Watson services.
http://watson-developer-cloud.github.io/java-sdk/
Apache License 2.0
594 stars 532 forks source link

[Watson-Assistant v1] Missing fields in Workspace model get overridden after update request #1205

Closed prasant94 closed 8 months ago

prasant94 commented 2 years ago

The Workspace model in the sdk is missing some fields that we receive if we make a curl request to the Get Workspace API. Specifically, the WorkspaceSystemSettings field (WorkspaceSystemSettings.java) in Workspace is missing the fields auto_learn and intent_classification fields.

  "system_settings": {
    "off_topic": {
      "enabled": true
    },
    "auto_learn": { <-- missing
      "apply": true
    },
    "disambiguation": {
      "prompt": "Did you mean:",
      "enabled": false,
      "randomize": true,
      "max_suggestions": 2,
      "suggestion_text_policy": "title",
      "none_of_the_above_prompt": "None of the above."
    },
    "human_agent_assist": {
      "prompt": "Did you mean:"
    },
    "intent_classification": { <-- missing
      "training_backend_version": "v2"
    },
    "spelling_auto_correct": true
  },

Can those be added to the SDK?

As of now, if we use the UpdateWorkspace method in the java sdk to update a workspace (with append = false), auto_learn gets disabled and intent_classification goes from Enhanced version to Classic version

FYI - I checked the go and nodejs sdks and they also seem to be missing these.

kevinkowa commented 2 years ago

auto_learn is not included on the sdks, it’s marked as for internal use only. As for intent_classification, it's not listed in our docs. This could potentially be available later on in some future release.

For now if you need to modify them, feel free to use the following custom code:

public final MediaType JSON
          = MediaType.get("application/json; charset=utf-8");
​
OkHttpClient client = new OkHttpClient();
​
String post(String url, String json, String token) throws IOException {
  RequestBody body = RequestBody.create(JSON, json);
  Request request = new Request.Builder()
          .url(url)
          .addHeader("Authorization", "Bearer " + token)
          .post(body)
          .build();
  try (Response response = client.newCall(request).execute()) {
    return response.body().string();
  }
}
​
...
​
Assistant service = new Assistant(version);
String workspaceId = "xxxxxxx-xxxxx-xxxx-xxxx-xxxxxxx";
​
String bearerToken = ((IamAuthenticator)service.getAuthenticator()).getToken();
​
String jsonBody = "{\"system_settings\": {" +
        "        \"auto_learn\": {" +
        "            \"apply\": true" +
        "        }," +
        "        \"intent_classification\": {" +
        "            \"training_backend_version\": \"v2\"" +
        "        }," +
        "        \"spelling_auto_correct\": true" +
        "    }}";
String response = post( service.getServiceUrl() + "/v1/workspaces/" + workspaceId + "?version=2021-06-14", jsonBody, bearerToken);
prasant94 commented 2 years ago

The main problem is

As of now, if we use the UpdateWorkspace method in the java sdk to update a workspace (with append = false), auto_learn gets disabled and intent_classification goes from Enhanced version to Classic version

I don't want to change those two fields. I only want to be able to update the rest of the Workspace without affecting those two settings. But since I can't include them in the request, they get changed (presumably to their default values)

kevinkowa commented 2 years ago

@prasant94 what did it have for training_backend_version & auto_learn before calling the function?

prasant94 commented 2 years ago

training_backend_version was v2 and auto_learn was {"apply": true}

These are the responses I got from calling Get Workspace API with curl:

Before

  "system_settings": {
    "off_topic": {
      "enabled": true
    },
    "auto_learn": {
      "apply": true
    },
    "disambiguation": {
      "prompt": "Did you mean:",
      "enabled": false,
      "randomize": true,
      "max_suggestions": 2,
      "suggestion_text_policy": "title",
      "none_of_the_above_prompt": "None of the above."
    },
    "human_agent_assist": {
      "prompt": "Did you mean:"
    },
    "intent_classification": {
      "training_backend_version": "v2"
    },
    "spelling_auto_correct": true
  }

After

  "system_settings": {
    "off_topic": {
      "enabled": true
    },
    "disambiguation": {
      "prompt": "Did you mean:",
      "enabled": false,
      "randomize": true,
      "max_suggestions": 2,
      "suggestion_text_policy": "title",
      "none_of_the_above_prompt": "None of the above."
    },
    "human_agent_assist": {
      "prompt": "Did you mean:"
    },
    "spelling_auto_correct": true
  }
apaparazzi0329 commented 8 months ago

Closing due to age. If this is still a concern using the latest version of the java-sdk please feel free to reopen this issue.