Skip to content

Commit 9b7e56e

Browse files
committed
feat(assistantv2): New params locale and reference_time in MessageContextGlobalSystem
1 parent c62e27c commit 9b7e56e

File tree

1 file changed

+49
-2
lines changed

1 file changed

+49
-2
lines changed

ibm_watson/assistant_v2.py

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,13 +1059,31 @@ class MessageContextGlobalSystem():
10591059
with each turn of the conversation. A value of 1 indicates that this is the the
10601060
first turn of a new conversation, which can affect the behavior of some skills
10611061
(for example, triggering the start node of a dialog).
1062+
:attr str locale: (optional) The language code for localization in the user
1063+
input. The specified locale overrides the default for the assistant, and is used
1064+
for interpreting entity values in user input such as date values. For example,
1065+
`04/03/2018` might be interpreted either as April 3 or March 4, depending on the
1066+
locale.
1067+
This property is included only if the new system entities are enabled for the
1068+
skill.
1069+
:attr str reference_time: (optional) The base time for interpreting any relative
1070+
time mentions in the user input. The specified time overrides the current server
1071+
time, and is used to calculate times mentioned in relative terms such as `now`
1072+
or `tomorrow`. This can be useful for simulating past or future times for
1073+
testing purposes, or when analyzing documents such as news articles.
1074+
This value must be a UTC time value formatted according to ISO 8601 (for
1075+
example, `2019-06-26T12:00:00Z` for noon on 26 June 2019.
1076+
This property is included only if the new system entities are enabled for the
1077+
skill.
10621078
"""
10631079

10641080
def __init__(self,
10651081
*,
10661082
timezone: str = None,
10671083
user_id: str = None,
1068-
turn_count: int = None) -> None:
1084+
turn_count: int = None,
1085+
locale: str = None,
1086+
reference_time: str = None) -> None:
10691087
"""
10701088
Initialize a MessageContextGlobalSystem object.
10711089
@@ -1082,16 +1100,37 @@ def __init__(self,
10821100
this is the the first turn of a new conversation, which can affect the
10831101
behavior of some skills (for example, triggering the start node of a
10841102
dialog).
1103+
:param str locale: (optional) The language code for localization in the
1104+
user input. The specified locale overrides the default for the assistant,
1105+
and is used for interpreting entity values in user input such as date
1106+
values. For example, `04/03/2018` might be interpreted either as April 3 or
1107+
March 4, depending on the locale.
1108+
This property is included only if the new system entities are enabled for
1109+
the skill.
1110+
:param str reference_time: (optional) The base time for interpreting any
1111+
relative time mentions in the user input. The specified time overrides the
1112+
current server time, and is used to calculate times mentioned in relative
1113+
terms such as `now` or `tomorrow`. This can be useful for simulating past
1114+
or future times for testing purposes, or when analyzing documents such as
1115+
news articles.
1116+
This value must be a UTC time value formatted according to ISO 8601 (for
1117+
example, `2019-06-26T12:00:00Z` for noon on 26 June 2019.
1118+
This property is included only if the new system entities are enabled for
1119+
the skill.
10851120
"""
10861121
self.timezone = timezone
10871122
self.user_id = user_id
10881123
self.turn_count = turn_count
1124+
self.locale = locale
1125+
self.reference_time = reference_time
10891126

10901127
@classmethod
10911128
def from_dict(cls, _dict: Dict) -> 'MessageContextGlobalSystem':
10921129
"""Initialize a MessageContextGlobalSystem object from a json dictionary."""
10931130
args = {}
1094-
valid_keys = ['timezone', 'user_id', 'turn_count']
1131+
valid_keys = [
1132+
'timezone', 'user_id', 'turn_count', 'locale', 'reference_time'
1133+
]
10951134
bad_keys = set(_dict.keys()) - set(valid_keys)
10961135
if bad_keys:
10971136
raise ValueError(
@@ -1103,6 +1142,10 @@ def from_dict(cls, _dict: Dict) -> 'MessageContextGlobalSystem':
11031142
args['user_id'] = _dict.get('user_id')
11041143
if 'turn_count' in _dict:
11051144
args['turn_count'] = _dict.get('turn_count')
1145+
if 'locale' in _dict:
1146+
args['locale'] = _dict.get('locale')
1147+
if 'reference_time' in _dict:
1148+
args['reference_time'] = _dict.get('reference_time')
11061149
return cls(**args)
11071150

11081151
@classmethod
@@ -1119,6 +1162,10 @@ def to_dict(self) -> Dict:
11191162
_dict['user_id'] = self.user_id
11201163
if hasattr(self, 'turn_count') and self.turn_count is not None:
11211164
_dict['turn_count'] = self.turn_count
1165+
if hasattr(self, 'locale') and self.locale is not None:
1166+
_dict['locale'] = self.locale
1167+
if hasattr(self, 'reference_time') and self.reference_time is not None:
1168+
_dict['reference_time'] = self.reference_time
11221169
return _dict
11231170

11241171
def _to_dict(self):

0 commit comments

Comments
 (0)