Skip to content

Commit

Permalink
chore(assistant): manual changes
Browse files Browse the repository at this point in the history
fix(assistant): rollback message system

fix(assistant): add integration test
  • Loading branch information
germanattanasio committed May 27, 2020
1 parent 8a9fb49 commit 7999d31
Show file tree
Hide file tree
Showing 25 changed files with 1,483 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ public class MessageInput extends DynamicModel<Object> {
@SerializedName("text")
protected String text;

@SerializedName("spelling_suggestions")
protected Boolean spellingSuggestions;

@SerializedName("spelling_auto_correct")
protected Boolean spellingAutoCorrect;

@SerializedName("suggested_text")
protected String suggestedText;

@SerializedName("original_text")
protected String originalText;

public MessageInput() {
super(new TypeToken<Object>() {});
}
Expand All @@ -46,4 +58,92 @@ public String getText() {
public void setText(final String text) {
this.text = text;
}

/**
* Gets the spellingSuggestions.
*
* <p>Whether to use spelling correction when processing the input. This property overrides the
* value of the **spelling_suggestions** property in the workspace settings.
*
* @return the spellingSuggestions
*/
public Boolean isSpellingSuggestions() {
return this.spellingSuggestions;
}

/**
* Sets the spellingSuggestions.
*
* @param spellingSuggestions the new spellingSuggestions
*/
public void setSpellingSuggestions(final Boolean spellingSuggestions) {
this.spellingSuggestions = spellingSuggestions;
}

/**
* Gets the spellingAutoCorrect.
*
* <p>Whether to use autocorrection when processing the input. If spelling correction is used and
* this property is `false`, any suggested corrections are returned in the **suggested_text**
* property of the message response. If this property is `true`, any corrections are automatically
* applied to the user input, and the original text is returned in the **original_text** property
* of the message response. This property overrides the value of the **spelling_auto_correct**
* property in the workspace settings.
*
* @return the spellingAutoCorrect
*/
public Boolean isSpellingAutoCorrect() {
return this.spellingAutoCorrect;
}

/**
* Sets the spellingAutoCorrect.
*
* @param spellingAutoCorrect the new spellingAutoCorrect
*/
public void setSpellingAutoCorrect(final Boolean spellingAutoCorrect) {
this.spellingAutoCorrect = spellingAutoCorrect;
}

/**
* Gets the suggestedText.
*
* <p>Any suggested corrections of the input text. This property is returned only if spelling
* correction is enabled and autocorrection is disabled.
*
* @return the suggestedText
*/
public String getSuggestedText() {
return this.suggestedText;
}

/**
* Sets the suggestedText.
*
* @param suggestedText the new suggestedText
*/
public void setSuggestedText(final String suggestedText) {
this.suggestedText = suggestedText;
}

/**
* Gets the originalText.
*
* <p>The original user input text. This property is returned only if autocorrection is enabled
* and the user input was corrected.
*
* @return the originalText
*/
public String getOriginalText() {
return this.originalText;
}

/**
* Sets the originalText.
*
* @param originalText the new originalText
*/
public void setOriginalText(final String originalText) {
this.originalText = originalText;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,8 @@ public String messageToHumanAgent() {
/**
* Gets the topic.
*
* <p>A label identifying the topic of the conversation, derived from the **user_label** property
* of the relevant node.
* <p>A label identifying the topic of the conversation, derived from the **title** property of
* the relevant node.
*
* @return the topic
*/
Expand All @@ -456,7 +456,7 @@ public String topic() {
* Gets the dialogNode.
*
* <p>The ID of the dialog node that the **topic** property is taken from. The **topic** property
* is populated using the value of the dialog node's **user_label** property.
* is populated using the value of the dialog node's **title** property.
*
* @return the dialogNode
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ public class WorkspaceSystemSettings extends GenericModel {
@SerializedName("human_agent_assist")
protected Map<String, Object> humanAgentAssist;

@SerializedName("spelling_suggestions")
protected Boolean spellingSuggestions;

@SerializedName("spelling_auto_correct")
protected Boolean spellingAutoCorrect;

@SerializedName("system_entities")
protected WorkspaceSystemSettingsSystemEntities systemEntities;

Expand All @@ -36,13 +42,17 @@ public static class Builder {
private WorkspaceSystemSettingsTooling tooling;
private WorkspaceSystemSettingsDisambiguation disambiguation;
private Map<String, Object> humanAgentAssist;
private Boolean spellingSuggestions;
private Boolean spellingAutoCorrect;
private WorkspaceSystemSettingsSystemEntities systemEntities;
private WorkspaceSystemSettingsOffTopic offTopic;

private Builder(WorkspaceSystemSettings workspaceSystemSettings) {
this.tooling = workspaceSystemSettings.tooling;
this.disambiguation = workspaceSystemSettings.disambiguation;
this.humanAgentAssist = workspaceSystemSettings.humanAgentAssist;
this.spellingSuggestions = workspaceSystemSettings.spellingSuggestions;
this.spellingAutoCorrect = workspaceSystemSettings.spellingAutoCorrect;
this.systemEntities = workspaceSystemSettings.systemEntities;
this.offTopic = workspaceSystemSettings.offTopic;
}
Expand Down Expand Up @@ -92,6 +102,28 @@ public Builder humanAgentAssist(Map<String, Object> humanAgentAssist) {
return this;
}

/**
* Set the spellingSuggestions.
*
* @param spellingSuggestions the spellingSuggestions
* @return the WorkspaceSystemSettings builder
*/
public Builder spellingSuggestions(Boolean spellingSuggestions) {
this.spellingSuggestions = spellingSuggestions;
return this;
}

/**
* Set the spellingAutoCorrect.
*
* @param spellingAutoCorrect the spellingAutoCorrect
* @return the WorkspaceSystemSettings builder
*/
public Builder spellingAutoCorrect(Boolean spellingAutoCorrect) {
this.spellingAutoCorrect = spellingAutoCorrect;
return this;
}

/**
* Set the systemEntities.
*
Expand Down Expand Up @@ -119,6 +151,8 @@ protected WorkspaceSystemSettings(Builder builder) {
tooling = builder.tooling;
disambiguation = builder.disambiguation;
humanAgentAssist = builder.humanAgentAssist;
spellingSuggestions = builder.spellingSuggestions;
spellingAutoCorrect = builder.spellingAutoCorrect;
systemEntities = builder.systemEntities;
offTopic = builder.offTopic;
}
Expand Down Expand Up @@ -167,6 +201,32 @@ public Map<String, Object> humanAgentAssist() {
return humanAgentAssist;
}

/**
* Gets the spellingSuggestions.
*
* <p>Whether spelling correction is enabled for the workspace.
*
* @return the spellingSuggestions
*/
public Boolean spellingSuggestions() {
return spellingSuggestions;
}

/**
* Gets the spellingAutoCorrect.
*
* <p>Whether autocorrection is enabled for the workspace. If spelling correction is enabled and
* this property is `false`, any suggested corrections are returned in the **suggested_text**
* property of the message response. If this property is `true`, any corrections are automatically
* applied to the user input, and the original text is returned in the **original_text** property
* of the message response.
*
* @return the spellingAutoCorrect
*/
public Boolean spellingAutoCorrect() {
return spellingAutoCorrect;
}

/**
* Gets the systemEntities.
*
Expand Down
55 changes: 53 additions & 2 deletions assistant/src/main/java/com/ibm/watson/assistant/v2/Assistant.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import com.ibm.watson.assistant.v2.model.DeleteSessionOptions;
import com.ibm.watson.assistant.v2.model.MessageOptions;
import com.ibm.watson.assistant.v2.model.MessageResponse;
import com.ibm.watson.assistant.v2.model.MessageResponseStateless;
import com.ibm.watson.assistant.v2.model.MessageStatelessOptions;
import com.ibm.watson.assistant.v2.model.SessionResponse;
import com.ibm.watson.common.SdkCommon;
import java.util.Map;
Expand Down Expand Up @@ -168,9 +170,10 @@ public ServiceCall<Void> deleteSession(DeleteSessionOptions deleteSessionOptions
}

/**
* Send user input to assistant.
* Send user input to assistant (stateful).
*
* <p>Send user input to an assistant and receive a response.
* <p>Send user input to an assistant and receive a response, with conversation state (including
* context data) stored by Watson Assistant for the duration of the session.
*
* <p>There is no rate limit for this operation.
*
Expand Down Expand Up @@ -207,4 +210,52 @@ public ServiceCall<MessageResponse> message(MessageOptions messageOptions) {
new com.google.gson.reflect.TypeToken<MessageResponse>() {}.getType());
return createServiceCall(builder.build(), responseConverter);
}

/**
* Send user input to assistant (stateless).
*
* <p>Send user input to an assistant and receive a response, with conversation state (including
* context data) managed by your application.
*
* <p>There is no rate limit for this operation.
*
* @param messageStatelessOptions the {@link MessageStatelessOptions} containing the options for
* the call
* @return a {@link ServiceCall} with a response type of {@link MessageResponseStateless}
*/
public ServiceCall<MessageResponseStateless> messageStateless(
MessageStatelessOptions messageStatelessOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(
messageStatelessOptions, "messageStatelessOptions cannot be null");
String[] pathSegments = {"v2/assistants", "message"};
String[] pathParameters = {messageStatelessOptions.assistantId()};
RequestBuilder builder =
RequestBuilder.post(
RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders =
SdkCommon.getSdkHeaders("conversation", "v2", "messageStateless");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
if (messageStatelessOptions.input() != null) {
contentJson.add(
"input",
com.ibm.cloud.sdk.core.util.GsonSingleton.getGson()
.toJsonTree(messageStatelessOptions.input()));
}
if (messageStatelessOptions.context() != null) {
contentJson.add(
"context",
com.ibm.cloud.sdk.core.util.GsonSingleton.getGson()
.toJsonTree(messageStatelessOptions.context()));
}
builder.bodyJson(contentJson);
ResponseConverter<MessageResponseStateless> responseConverter =
ResponseConverterUtils.getValue(
new com.google.gson.reflect.TypeToken<MessageResponseStateless>() {}.getType());
return createServiceCall(builder.build(), responseConverter);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public Builder newBuilder() {
/**
* Gets the global.
*
* <p>Information that is shared by all skills used by the Assistant.
* <p>Session context data that is shared by all skills used by the Assistant.
*
* @return the global
*/
Expand All @@ -93,10 +93,10 @@ public MessageContextGlobal global() {
/**
* Gets the skills.
*
* <p>Information specific to particular skills used by the Assistant.
* <p>Information specific to particular skills used by the assistant.
*
* <p>**Note:** Currently, only a single property named `main skill` is supported. This object
* contains variables that apply to the dialog skill used by the assistant.
* <p>**Note:** Currently, only a single child property is supported, containing variables that
* apply to the dialog skill used by the assistant.
*
* @return the skills
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,25 @@
*/
package com.ibm.watson.assistant.v2.model;

import com.google.gson.annotations.SerializedName;
import com.ibm.cloud.sdk.core.service.model.GenericModel;

/** Information that is shared by all skills used by the Assistant. */
/** Session context data that is shared by all skills used by the Assistant. */
public class MessageContextGlobal extends GenericModel {

protected MessageContextGlobalSystem system;

@SerializedName("session_id")
protected String sessionId;

/** Builder. */
public static class Builder {
private MessageContextGlobalSystem system;
private String sessionId;

private Builder(MessageContextGlobal messageContextGlobal) {
this.system = messageContextGlobal.system;
this.sessionId = messageContextGlobal.sessionId;
}

/** Instantiates a new builder. */
Expand All @@ -49,10 +55,22 @@ public Builder system(MessageContextGlobalSystem system) {
this.system = system;
return this;
}

/**
* Set the sessionId.
*
* @param sessionId the sessionId
* @return the MessageContextGlobal builder
*/
public Builder sessionId(String sessionId) {
this.sessionId = sessionId;
return this;
}
}

protected MessageContextGlobal(Builder builder) {
system = builder.system;
sessionId = builder.sessionId;
}

/**
Expand All @@ -74,4 +92,15 @@ public Builder newBuilder() {
public MessageContextGlobalSystem system() {
return system;
}

/**
* Gets the sessionId.
*
* <p>The session ID.
*
* @return the sessionId
*/
public String sessionId() {
return sessionId;
}
}
Loading

0 comments on commit 7999d31

Please sign in to comment.