Skip to content

Commit 53e532e

Browse files
committed
fix(Assistant): node dialog response should have agent props
1 parent 84213a9 commit 53e532e

File tree

4 files changed

+579
-402
lines changed

4 files changed

+579
-402
lines changed

ibm_watson/assistant_v1.py

Lines changed: 160 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

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

179+
#########################
180+
# Bulk classify
181+
#########################
182+
183+
def bulk_classify(self,
184+
workspace_id: str,
185+
*,
186+
input: List['BulkClassifyUtterance'] = None,
187+
**kwargs) -> DetailedResponse:
188+
"""
189+
Identify intents and entities in multiple user utterances.
190+
191+
Send multiple user inputs to a workspace in a single request and receive
192+
information about the intents and entities recognized in each input. This method
193+
is useful for testing and comparing the performance of different workspaces.
194+
This method is available only with Premium plans.
195+
196+
:param str workspace_id: Unique identifier of the workspace.
197+
:param List[BulkClassifyUtterance] input: (optional) An array of input
198+
utterances to classify.
199+
:param dict headers: A `dict` containing the request headers
200+
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
201+
:rtype: DetailedResponse with `dict` result representing a `BulkClassifyResponse` object
202+
"""
203+
204+
if workspace_id is None:
205+
raise ValueError('workspace_id must be provided')
206+
if input is not None:
207+
input = [convert_model(x) for x in input]
208+
headers = {}
209+
sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME,
210+
service_version='V1',
211+
operation_id='bulk_classify')
212+
headers.update(sdk_headers)
213+
214+
params = {'version': self.version}
215+
216+
data = {'input': input}
217+
data = {k: v for (k, v) in data.items() if v is not None}
218+
data = json.dumps(data)
219+
headers['content-type'] = 'application/json'
220+
221+
if 'headers' in kwargs:
222+
headers.update(kwargs.get('headers'))
223+
headers['Accept'] = 'application/json'
224+
225+
path_param_keys = ['workspace_id']
226+
path_param_values = self.encode_path_vars(workspace_id)
227+
path_param_dict = dict(zip(path_param_keys, path_param_values))
228+
url = '/v1/workspaces/{workspace_id}/bulk_classify'.format(
229+
**path_param_dict)
230+
request = self.prepare_request(method='POST',
231+
url=url,
232+
headers=headers,
233+
params=params,
234+
data=data)
235+
236+
response = self.send(request)
237+
return response
238+
179239
#########################
180240
# Workspaces
181241
#########################
@@ -3255,66 +3315,6 @@ def delete_user_data(self, customer_id: str, **kwargs) -> DetailedResponse:
32553315
response = self.send(request)
32563316
return response
32573317

3258-
#########################
3259-
# bulkClassify
3260-
#########################
3261-
3262-
def bulk_classify(self,
3263-
workspace_id: str,
3264-
*,
3265-
input: List['BulkClassifyUtterance'] = None,
3266-
**kwargs) -> DetailedResponse:
3267-
"""
3268-
Identify intents and entities in multiple user utterances.
3269-
3270-
Send multiple user inputs to a workspace in a single request and receive
3271-
information about the intents and entities recognized in each input. This method
3272-
is useful for testing and comparing the performance of different workspaces.
3273-
This method is available only with Premium plans.
3274-
3275-
:param str workspace_id: Unique identifier of the workspace.
3276-
:param List[BulkClassifyUtterance] input: (optional) An array of input
3277-
utterances to classify.
3278-
:param dict headers: A `dict` containing the request headers
3279-
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
3280-
:rtype: DetailedResponse with `dict` result representing a `BulkClassifyResponse` object
3281-
"""
3282-
3283-
if workspace_id is None:
3284-
raise ValueError('workspace_id must be provided')
3285-
if input is not None:
3286-
input = [convert_model(x) for x in input]
3287-
headers = {}
3288-
sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME,
3289-
service_version='V1',
3290-
operation_id='bulk_classify')
3291-
headers.update(sdk_headers)
3292-
3293-
params = {'version': self.version}
3294-
3295-
data = {'input': input}
3296-
data = {k: v for (k, v) in data.items() if v is not None}
3297-
data = json.dumps(data)
3298-
headers['content-type'] = 'application/json'
3299-
3300-
if 'headers' in kwargs:
3301-
headers.update(kwargs.get('headers'))
3302-
headers['Accept'] = 'application/json'
3303-
3304-
path_param_keys = ['workspace_id']
3305-
path_param_values = self.encode_path_vars(workspace_id)
3306-
path_param_dict = dict(zip(path_param_keys, path_param_values))
3307-
url = '/v1/workspaces/{workspace_id}/bulk_classify'.format(
3308-
**path_param_dict)
3309-
request = self.prepare_request(method='POST',
3310-
url=url,
3311-
headers=headers,
3312-
params=params,
3313-
data=data)
3314-
3315-
response = self.send(request)
3316-
return response
3317-
33183318

33193319
class ListWorkspacesEnums:
33203320
"""
@@ -3447,6 +3447,60 @@ class Sort(str, Enum):
34473447
##############################################################################
34483448

34493449

3450+
class AgentAvailabilityMessage():
3451+
"""
3452+
AgentAvailabilityMessage.
3453+
3454+
:attr str message: (optional) The text of the message.
3455+
"""
3456+
3457+
def __init__(self, *, message: str = None) -> None:
3458+
"""
3459+
Initialize a AgentAvailabilityMessage object.
3460+
3461+
:param str message: (optional) The text of the message.
3462+
"""
3463+
self.message = message
3464+
3465+
@classmethod
3466+
def from_dict(cls, _dict: Dict) -> 'AgentAvailabilityMessage':
3467+
"""Initialize a AgentAvailabilityMessage object from a json dictionary."""
3468+
args = {}
3469+
if 'message' in _dict:
3470+
args['message'] = _dict.get('message')
3471+
return cls(**args)
3472+
3473+
@classmethod
3474+
def _from_dict(cls, _dict):
3475+
"""Initialize a AgentAvailabilityMessage object from a json dictionary."""
3476+
return cls.from_dict(_dict)
3477+
3478+
def to_dict(self) -> Dict:
3479+
"""Return a json dictionary representing this model."""
3480+
_dict = {}
3481+
if hasattr(self, 'message') and self.message is not None:
3482+
_dict['message'] = self.message
3483+
return _dict
3484+
3485+
def _to_dict(self):
3486+
"""Return a json dictionary representing this model."""
3487+
return self.to_dict()
3488+
3489+
def __str__(self) -> str:
3490+
"""Return a `str` version of this AgentAvailabilityMessage object."""
3491+
return json.dumps(self.to_dict(), indent=2)
3492+
3493+
def __eq__(self, other: 'AgentAvailabilityMessage') -> bool:
3494+
"""Return `true` when self and other are equal, false otherwise."""
3495+
if not isinstance(other, self.__class__):
3496+
return False
3497+
return self.__dict__ == other.__dict__
3498+
3499+
def __ne__(self, other: 'AgentAvailabilityMessage') -> bool:
3500+
"""Return `true` when self and other are not equal, false otherwise."""
3501+
return not self == other
3502+
3503+
34503504
class BulkClassifyOutput():
34513505
"""
34523506
BulkClassifyOutput.
@@ -7705,10 +7759,8 @@ class RuntimeEntity():
77057759
the entity, as defined by the entity pattern.
77067760
:attr RuntimeEntityInterpretation interpretation: (optional) An object
77077761
containing detailed information about the entity recognized in the user input.
7708-
This property is included only if the new system entities are enabled for the
7709-
workspace.
7710-
For more information about how the new system entities are interpreted, see the
7711-
[documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-beta-system-entities).
7762+
For more information about how system entities are interpreted, see the
7763+
[documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-system-entities).
77127764
:attr List[RuntimeEntityAlternative] alternatives: (optional) An array of
77137765
possible alternative values that the user might have intended instead of the
77147766
value returned in the **value** property. This property is returned only for
@@ -7746,11 +7798,9 @@ def __init__(self,
77467798
for the entity, as defined by the entity pattern.
77477799
:param RuntimeEntityInterpretation interpretation: (optional) An object
77487800
containing detailed information about the entity recognized in the user
7749-
input. This property is included only if the new system entities are
7750-
enabled for the workspace.
7751-
For more information about how the new system entities are interpreted, see
7752-
the
7753-
[documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-beta-system-entities).
7801+
input.
7802+
For more information about how system entities are interpreted, see the
7803+
[documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-system-entities).
77547804
:param List[RuntimeEntityAlternative] alternatives: (optional) An array of
77557805
possible alternative values that the user might have intended instead of
77567806
the value returned in the **value** property. This property is returned
@@ -9772,12 +9822,12 @@ class DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent(
97729822
specified response type must be supported by the client application or channel.
97739823
:attr str message_to_human_agent: (optional) An optional message to be sent to
97749824
the human agent who will be taking over the conversation.
9775-
:attr str agent_available: (optional) An optional message to be displayed to the
9776-
user to indicate that the conversation will be transferred to the next available
9777-
agent.
9778-
:attr str agent_unavailable: (optional) An optional message to be displayed to
9779-
the user to indicate that no online agent is available to take over the
9780-
conversation.
9825+
:attr AgentAvailabilityMessage agent_available: (optional) An optional message
9826+
to be displayed to the user to indicate that the conversation will be
9827+
transferred to the next available agent.
9828+
:attr AgentAvailabilityMessage agent_unavailable: (optional) An optional message
9829+
to be displayed to the user to indicate that no online agent is available to
9830+
take over the conversation.
97819831
:attr DialogNodeOutputConnectToAgentTransferInfo transfer_info: (optional)
97829832
Routing or other contextual information to be used by target service desk
97839833
systems.
@@ -9788,8 +9838,8 @@ def __init__(
97889838
response_type: str,
97899839
*,
97909840
message_to_human_agent: str = None,
9791-
agent_available: str = None,
9792-
agent_unavailable: str = None,
9841+
agent_available: 'AgentAvailabilityMessage' = None,
9842+
agent_unavailable: 'AgentAvailabilityMessage' = None,
97939843
transfer_info: 'DialogNodeOutputConnectToAgentTransferInfo' = None
97949844
) -> None:
97959845
"""
@@ -9800,12 +9850,12 @@ def __init__(
98009850
channel.
98019851
:param str message_to_human_agent: (optional) An optional message to be
98029852
sent to the human agent who will be taking over the conversation.
9803-
:param str agent_available: (optional) An optional message to be displayed
9804-
to the user to indicate that the conversation will be transferred to the
9805-
next available agent.
9806-
:param str agent_unavailable: (optional) An optional message to be
9807-
displayed to the user to indicate that no online agent is available to take
9808-
over the conversation.
9853+
:param AgentAvailabilityMessage agent_available: (optional) An optional
9854+
message to be displayed to the user to indicate that the conversation will
9855+
be transferred to the next available agent.
9856+
:param AgentAvailabilityMessage agent_unavailable: (optional) An optional
9857+
message to be displayed to the user to indicate that no online agent is
9858+
available to take over the conversation.
98099859
:param DialogNodeOutputConnectToAgentTransferInfo transfer_info: (optional)
98109860
Routing or other contextual information to be used by target service desk
98119861
systems.
@@ -9832,9 +9882,11 @@ def from_dict(
98329882
if 'message_to_human_agent' in _dict:
98339883
args['message_to_human_agent'] = _dict.get('message_to_human_agent')
98349884
if 'agent_available' in _dict:
9835-
args['agent_available'] = _dict.get('agent_available')
9885+
args['agent_available'] = AgentAvailabilityMessage.from_dict(
9886+
_dict.get('agent_available'))
98369887
if 'agent_unavailable' in _dict:
9837-
args['agent_unavailable'] = _dict.get('agent_unavailable')
9888+
args['agent_unavailable'] = AgentAvailabilityMessage.from_dict(
9889+
_dict.get('agent_unavailable'))
98389890
if 'transfer_info' in _dict:
98399891
args[
98409892
'transfer_info'] = DialogNodeOutputConnectToAgentTransferInfo.from_dict(
@@ -9856,10 +9908,10 @@ def to_dict(self) -> Dict:
98569908
_dict['message_to_human_agent'] = self.message_to_human_agent
98579909
if hasattr(self,
98589910
'agent_available') and self.agent_available is not None:
9859-
_dict['agent_available'] = self.agent_available
9911+
_dict['agent_available'] = self.agent_available.to_dict()
98609912
if hasattr(self,
98619913
'agent_unavailable') and self.agent_unavailable is not None:
9862-
_dict['agent_unavailable'] = self.agent_unavailable
9914+
_dict['agent_unavailable'] = self.agent_unavailable.to_dict()
98639915
if hasattr(self, 'transfer_info') and self.transfer_info is not None:
98649916
_dict['transfer_info'] = self.transfer_info.to_dict()
98659917
return _dict
@@ -10523,12 +10575,12 @@ class RuntimeResponseGenericRuntimeResponseTypeConnectToAgent(
1052310575
specified response type must be supported by the client application or channel.
1052410576
:attr str message_to_human_agent: (optional) A message to be sent to the human
1052510577
agent who will be taking over the conversation.
10526-
:attr str agent_available: (optional) An optional message to be displayed to the
10527-
user to indicate that the conversation will be transferred to the next available
10528-
agent.
10529-
:attr str agent_unavailable: (optional) An optional message to be displayed to
10530-
the user to indicate that no online agent is available to take over the
10531-
conversation.
10578+
:attr AgentAvailabilityMessage agent_available: (optional) An optional message
10579+
to be displayed to the user to indicate that the conversation will be
10580+
transferred to the next available agent.
10581+
:attr AgentAvailabilityMessage agent_unavailable: (optional) An optional message
10582+
to be displayed to the user to indicate that no online agent is available to
10583+
take over the conversation.
1053210584
:attr DialogNodeOutputConnectToAgentTransferInfo transfer_info: (optional)
1053310585
Routing or other contextual information to be used by target service desk
1053410586
systems.
@@ -10545,8 +10597,8 @@ def __init__(
1054510597
response_type: str,
1054610598
*,
1054710599
message_to_human_agent: str = None,
10548-
agent_available: str = None,
10549-
agent_unavailable: str = None,
10600+
agent_available: 'AgentAvailabilityMessage' = None,
10601+
agent_unavailable: 'AgentAvailabilityMessage' = None,
1055010602
transfer_info: 'DialogNodeOutputConnectToAgentTransferInfo' = None,
1055110603
topic: str = None,
1055210604
dialog_node: str = None) -> None:
@@ -10558,12 +10610,12 @@ def __init__(
1055810610
channel.
1055910611
:param str message_to_human_agent: (optional) A message to be sent to the
1056010612
human agent who will be taking over the conversation.
10561-
:param str agent_available: (optional) An optional message to be displayed
10562-
to the user to indicate that the conversation will be transferred to the
10563-
next available agent.
10564-
:param str agent_unavailable: (optional) An optional message to be
10565-
displayed to the user to indicate that no online agent is available to take
10566-
over the conversation.
10613+
:param AgentAvailabilityMessage agent_available: (optional) An optional
10614+
message to be displayed to the user to indicate that the conversation will
10615+
be transferred to the next available agent.
10616+
:param AgentAvailabilityMessage agent_unavailable: (optional) An optional
10617+
message to be displayed to the user to indicate that no online agent is
10618+
available to take over the conversation.
1056710619
:param DialogNodeOutputConnectToAgentTransferInfo transfer_info: (optional)
1056810620
Routing or other contextual information to be used by target service desk
1056910621
systems.
@@ -10598,9 +10650,11 @@ def from_dict(
1059810650
if 'message_to_human_agent' in _dict:
1059910651
args['message_to_human_agent'] = _dict.get('message_to_human_agent')
1060010652
if 'agent_available' in _dict:
10601-
args['agent_available'] = _dict.get('agent_available')
10653+
args['agent_available'] = AgentAvailabilityMessage.from_dict(
10654+
_dict.get('agent_available'))
1060210655
if 'agent_unavailable' in _dict:
10603-
args['agent_unavailable'] = _dict.get('agent_unavailable')
10656+
args['agent_unavailable'] = AgentAvailabilityMessage.from_dict(
10657+
_dict.get('agent_unavailable'))
1060410658
if 'transfer_info' in _dict:
1060510659
args[
1060610660
'transfer_info'] = DialogNodeOutputConnectToAgentTransferInfo.from_dict(
@@ -10626,10 +10680,10 @@ def to_dict(self) -> Dict:
1062610680
_dict['message_to_human_agent'] = self.message_to_human_agent
1062710681
if hasattr(self,
1062810682
'agent_available') and self.agent_available is not None:
10629-
_dict['agent_available'] = self.agent_available
10683+
_dict['agent_available'] = self.agent_available.to_dict()
1063010684
if hasattr(self,
1063110685
'agent_unavailable') and self.agent_unavailable is not None:
10632-
_dict['agent_unavailable'] = self.agent_unavailable
10686+
_dict['agent_unavailable'] = self.agent_unavailable.to_dict()
1063310687
if hasattr(self, 'transfer_info') and self.transfer_info is not None:
1063410688
_dict['transfer_info'] = self.transfer_info.to_dict()
1063510689
if hasattr(self, 'topic') and self.topic is not None:

0 commit comments

Comments
 (0)