Skip to content

Commit

Permalink
Merge pull request watson-developer-cloud#767 from watson-developer-c…
Browse files Browse the repository at this point in the history
…loud/fix-agent-res

fix(Assistant): node dialog response should have agent props
  • Loading branch information
mamoonraja authored Dec 22, 2020
2 parents 84213a9 + 53e532e commit 29568ee
Show file tree
Hide file tree
Showing 4 changed files with 579 additions and 402 deletions.
266 changes: 160 additions & 106 deletions ibm_watson/assistant_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-a45d89ef-20201209-192237
# IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-a45d89ef-20201221-115123
"""
The IBM Watson™ Assistant service combines machine learning, natural language
understanding, and an integrated dialog editor to create conversation flows between your
Expand Down Expand Up @@ -176,6 +176,66 @@ def message(self,
response = self.send(request)
return response

#########################
# Bulk classify
#########################

def bulk_classify(self,
workspace_id: str,
*,
input: List['BulkClassifyUtterance'] = None,
**kwargs) -> DetailedResponse:
"""
Identify intents and entities in multiple user utterances.
Send multiple user inputs to a workspace in a single request and receive
information about the intents and entities recognized in each input. This method
is useful for testing and comparing the performance of different workspaces.
This method is available only with Premium plans.
:param str workspace_id: Unique identifier of the workspace.
:param List[BulkClassifyUtterance] input: (optional) An array of input
utterances to classify.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `BulkClassifyResponse` object
"""

if workspace_id is None:
raise ValueError('workspace_id must be provided')
if input is not None:
input = [convert_model(x) for x in input]
headers = {}
sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME,
service_version='V1',
operation_id='bulk_classify')
headers.update(sdk_headers)

params = {'version': self.version}

data = {'input': input}
data = {k: v for (k, v) in data.items() if v is not None}
data = json.dumps(data)
headers['content-type'] = 'application/json'

if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
headers['Accept'] = 'application/json'

path_param_keys = ['workspace_id']
path_param_values = self.encode_path_vars(workspace_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v1/workspaces/{workspace_id}/bulk_classify'.format(
**path_param_dict)
request = self.prepare_request(method='POST',
url=url,
headers=headers,
params=params,
data=data)

response = self.send(request)
return response

#########################
# Workspaces
#########################
Expand Down Expand Up @@ -3255,66 +3315,6 @@ def delete_user_data(self, customer_id: str, **kwargs) -> DetailedResponse:
response = self.send(request)
return response

#########################
# bulkClassify
#########################

def bulk_classify(self,
workspace_id: str,
*,
input: List['BulkClassifyUtterance'] = None,
**kwargs) -> DetailedResponse:
"""
Identify intents and entities in multiple user utterances.
Send multiple user inputs to a workspace in a single request and receive
information about the intents and entities recognized in each input. This method
is useful for testing and comparing the performance of different workspaces.
This method is available only with Premium plans.
:param str workspace_id: Unique identifier of the workspace.
:param List[BulkClassifyUtterance] input: (optional) An array of input
utterances to classify.
:param dict headers: A `dict` containing the request headers
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
:rtype: DetailedResponse with `dict` result representing a `BulkClassifyResponse` object
"""

if workspace_id is None:
raise ValueError('workspace_id must be provided')
if input is not None:
input = [convert_model(x) for x in input]
headers = {}
sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME,
service_version='V1',
operation_id='bulk_classify')
headers.update(sdk_headers)

params = {'version': self.version}

data = {'input': input}
data = {k: v for (k, v) in data.items() if v is not None}
data = json.dumps(data)
headers['content-type'] = 'application/json'

if 'headers' in kwargs:
headers.update(kwargs.get('headers'))
headers['Accept'] = 'application/json'

path_param_keys = ['workspace_id']
path_param_values = self.encode_path_vars(workspace_id)
path_param_dict = dict(zip(path_param_keys, path_param_values))
url = '/v1/workspaces/{workspace_id}/bulk_classify'.format(
**path_param_dict)
request = self.prepare_request(method='POST',
url=url,
headers=headers,
params=params,
data=data)

response = self.send(request)
return response


class ListWorkspacesEnums:
"""
Expand Down Expand Up @@ -3447,6 +3447,60 @@ class Sort(str, Enum):
##############################################################################


class AgentAvailabilityMessage():
"""
AgentAvailabilityMessage.
:attr str message: (optional) The text of the message.
"""

def __init__(self, *, message: str = None) -> None:
"""
Initialize a AgentAvailabilityMessage object.
:param str message: (optional) The text of the message.
"""
self.message = message

@classmethod
def from_dict(cls, _dict: Dict) -> 'AgentAvailabilityMessage':
"""Initialize a AgentAvailabilityMessage object from a json dictionary."""
args = {}
if 'message' in _dict:
args['message'] = _dict.get('message')
return cls(**args)

@classmethod
def _from_dict(cls, _dict):
"""Initialize a AgentAvailabilityMessage object from a json dictionary."""
return cls.from_dict(_dict)

def to_dict(self) -> Dict:
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'message') and self.message is not None:
_dict['message'] = self.message
return _dict

def _to_dict(self):
"""Return a json dictionary representing this model."""
return self.to_dict()

def __str__(self) -> str:
"""Return a `str` version of this AgentAvailabilityMessage object."""
return json.dumps(self.to_dict(), indent=2)

def __eq__(self, other: 'AgentAvailabilityMessage') -> bool:
"""Return `true` when self and other are equal, false otherwise."""
if not isinstance(other, self.__class__):
return False
return self.__dict__ == other.__dict__

def __ne__(self, other: 'AgentAvailabilityMessage') -> bool:
"""Return `true` when self and other are not equal, false otherwise."""
return not self == other


class BulkClassifyOutput():
"""
BulkClassifyOutput.
Expand Down Expand Up @@ -7705,10 +7759,8 @@ class RuntimeEntity():
the entity, as defined by the entity pattern.
:attr RuntimeEntityInterpretation interpretation: (optional) An object
containing detailed information about the entity recognized in the user input.
This property is included only if the new system entities are enabled for the
workspace.
For more information about how the new system entities are interpreted, see the
[documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-beta-system-entities).
For more information about how system entities are interpreted, see the
[documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-system-entities).
:attr List[RuntimeEntityAlternative] alternatives: (optional) An array of
possible alternative values that the user might have intended instead of the
value returned in the **value** property. This property is returned only for
Expand Down Expand Up @@ -7746,11 +7798,9 @@ def __init__(self,
for the entity, as defined by the entity pattern.
:param RuntimeEntityInterpretation interpretation: (optional) An object
containing detailed information about the entity recognized in the user
input. This property is included only if the new system entities are
enabled for the workspace.
For more information about how the new system entities are interpreted, see
the
[documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-beta-system-entities).
input.
For more information about how system entities are interpreted, see the
[documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-system-entities).
:param List[RuntimeEntityAlternative] alternatives: (optional) An array of
possible alternative values that the user might have intended instead of
the value returned in the **value** property. This property is returned
Expand Down Expand Up @@ -9772,12 +9822,12 @@ class DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent(
specified response type must be supported by the client application or channel.
:attr str message_to_human_agent: (optional) An optional message to be sent to
the human agent who will be taking over the conversation.
:attr str agent_available: (optional) An optional message to be displayed to the
user to indicate that the conversation will be transferred to the next available
agent.
:attr str agent_unavailable: (optional) An optional message to be displayed to
the user to indicate that no online agent is available to take over the
conversation.
:attr AgentAvailabilityMessage agent_available: (optional) An optional message
to be displayed to the user to indicate that the conversation will be
transferred to the next available agent.
:attr AgentAvailabilityMessage agent_unavailable: (optional) An optional message
to be displayed to the user to indicate that no online agent is available to
take over the conversation.
:attr DialogNodeOutputConnectToAgentTransferInfo transfer_info: (optional)
Routing or other contextual information to be used by target service desk
systems.
Expand All @@ -9788,8 +9838,8 @@ def __init__(
response_type: str,
*,
message_to_human_agent: str = None,
agent_available: str = None,
agent_unavailable: str = None,
agent_available: 'AgentAvailabilityMessage' = None,
agent_unavailable: 'AgentAvailabilityMessage' = None,
transfer_info: 'DialogNodeOutputConnectToAgentTransferInfo' = None
) -> None:
"""
Expand All @@ -9800,12 +9850,12 @@ def __init__(
channel.
:param str message_to_human_agent: (optional) An optional message to be
sent to the human agent who will be taking over the conversation.
:param str agent_available: (optional) An optional message to be displayed
to the user to indicate that the conversation will be transferred to the
next available agent.
:param str agent_unavailable: (optional) An optional message to be
displayed to the user to indicate that no online agent is available to take
over the conversation.
:param AgentAvailabilityMessage agent_available: (optional) An optional
message to be displayed to the user to indicate that the conversation will
be transferred to the next available agent.
:param AgentAvailabilityMessage agent_unavailable: (optional) An optional
message to be displayed to the user to indicate that no online agent is
available to take over the conversation.
:param DialogNodeOutputConnectToAgentTransferInfo transfer_info: (optional)
Routing or other contextual information to be used by target service desk
systems.
Expand All @@ -9832,9 +9882,11 @@ def from_dict(
if 'message_to_human_agent' in _dict:
args['message_to_human_agent'] = _dict.get('message_to_human_agent')
if 'agent_available' in _dict:
args['agent_available'] = _dict.get('agent_available')
args['agent_available'] = AgentAvailabilityMessage.from_dict(
_dict.get('agent_available'))
if 'agent_unavailable' in _dict:
args['agent_unavailable'] = _dict.get('agent_unavailable')
args['agent_unavailable'] = AgentAvailabilityMessage.from_dict(
_dict.get('agent_unavailable'))
if 'transfer_info' in _dict:
args[
'transfer_info'] = DialogNodeOutputConnectToAgentTransferInfo.from_dict(
Expand All @@ -9856,10 +9908,10 @@ def to_dict(self) -> Dict:
_dict['message_to_human_agent'] = self.message_to_human_agent
if hasattr(self,
'agent_available') and self.agent_available is not None:
_dict['agent_available'] = self.agent_available
_dict['agent_available'] = self.agent_available.to_dict()
if hasattr(self,
'agent_unavailable') and self.agent_unavailable is not None:
_dict['agent_unavailable'] = self.agent_unavailable
_dict['agent_unavailable'] = self.agent_unavailable.to_dict()
if hasattr(self, 'transfer_info') and self.transfer_info is not None:
_dict['transfer_info'] = self.transfer_info.to_dict()
return _dict
Expand Down Expand Up @@ -10523,12 +10575,12 @@ class RuntimeResponseGenericRuntimeResponseTypeConnectToAgent(
specified response type must be supported by the client application or channel.
:attr str message_to_human_agent: (optional) A message to be sent to the human
agent who will be taking over the conversation.
:attr str agent_available: (optional) An optional message to be displayed to the
user to indicate that the conversation will be transferred to the next available
agent.
:attr str agent_unavailable: (optional) An optional message to be displayed to
the user to indicate that no online agent is available to take over the
conversation.
:attr AgentAvailabilityMessage agent_available: (optional) An optional message
to be displayed to the user to indicate that the conversation will be
transferred to the next available agent.
:attr AgentAvailabilityMessage agent_unavailable: (optional) An optional message
to be displayed to the user to indicate that no online agent is available to
take over the conversation.
:attr DialogNodeOutputConnectToAgentTransferInfo transfer_info: (optional)
Routing or other contextual information to be used by target service desk
systems.
Expand All @@ -10545,8 +10597,8 @@ def __init__(
response_type: str,
*,
message_to_human_agent: str = None,
agent_available: str = None,
agent_unavailable: str = None,
agent_available: 'AgentAvailabilityMessage' = None,
agent_unavailable: 'AgentAvailabilityMessage' = None,
transfer_info: 'DialogNodeOutputConnectToAgentTransferInfo' = None,
topic: str = None,
dialog_node: str = None) -> None:
Expand All @@ -10558,12 +10610,12 @@ def __init__(
channel.
:param str message_to_human_agent: (optional) A message to be sent to the
human agent who will be taking over the conversation.
:param str agent_available: (optional) An optional message to be displayed
to the user to indicate that the conversation will be transferred to the
next available agent.
:param str agent_unavailable: (optional) An optional message to be
displayed to the user to indicate that no online agent is available to take
over the conversation.
:param AgentAvailabilityMessage agent_available: (optional) An optional
message to be displayed to the user to indicate that the conversation will
be transferred to the next available agent.
:param AgentAvailabilityMessage agent_unavailable: (optional) An optional
message to be displayed to the user to indicate that no online agent is
available to take over the conversation.
:param DialogNodeOutputConnectToAgentTransferInfo transfer_info: (optional)
Routing or other contextual information to be used by target service desk
systems.
Expand Down Expand Up @@ -10598,9 +10650,11 @@ def from_dict(
if 'message_to_human_agent' in _dict:
args['message_to_human_agent'] = _dict.get('message_to_human_agent')
if 'agent_available' in _dict:
args['agent_available'] = _dict.get('agent_available')
args['agent_available'] = AgentAvailabilityMessage.from_dict(
_dict.get('agent_available'))
if 'agent_unavailable' in _dict:
args['agent_unavailable'] = _dict.get('agent_unavailable')
args['agent_unavailable'] = AgentAvailabilityMessage.from_dict(
_dict.get('agent_unavailable'))
if 'transfer_info' in _dict:
args[
'transfer_info'] = DialogNodeOutputConnectToAgentTransferInfo.from_dict(
Expand All @@ -10626,10 +10680,10 @@ def to_dict(self) -> Dict:
_dict['message_to_human_agent'] = self.message_to_human_agent
if hasattr(self,
'agent_available') and self.agent_available is not None:
_dict['agent_available'] = self.agent_available
_dict['agent_available'] = self.agent_available.to_dict()
if hasattr(self,
'agent_unavailable') and self.agent_unavailable is not None:
_dict['agent_unavailable'] = self.agent_unavailable
_dict['agent_unavailable'] = self.agent_unavailable.to_dict()
if hasattr(self, 'transfer_info') and self.transfer_info is not None:
_dict['transfer_info'] = self.transfer_info.to_dict()
if hasattr(self, 'topic') and self.topic is not None:
Expand Down
Loading

0 comments on commit 29568ee

Please sign in to comment.