ibm_watson.assistant_v2 module¶
The IBM Watson™ Assistant service combines machine learning, natural language understanding, and an integrated dialog editor to create conversation flows between your apps and your users. The Assistant v2 API provides runtime methods your client application can use to send user input to an assistant and receive a response.
-
class
AssistantV2
(version: str, authenticator: ibm_cloud_sdk_core.authenticators.authenticator.Authenticator = None, service_name: str = 'assistant')[source]¶ Bases:
ibm_cloud_sdk_core.base_service.BaseService
The Assistant V2 service.
-
DEFAULT_SERVICE_URL
= 'https://api.us-south.assistant.watson.cloud.ibm.com'¶
-
DEFAULT_SERVICE_NAME
= 'assistant'¶
-
create_session
(assistant_id: str, **kwargs) → ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]¶ Create a session.
Create a new session. A session is used to send user input to a skill and receive responses. It also maintains the state of the conversation. A session persists until it is deleted, or until it times out because of inactivity. (For more information, see the [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant-settings).
- Parameters
assistant_id (str) – Unique identifier of the assistant. To find the assistant ID in the Watson Assistant user interface, open the assistant settings and click API Details. For information about creating assistants, see the [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant-add#assistant-add-task). Note: Currently, the v2 API does not support creating assistants.
headers (dict) – A dict containing the request headers
- Returns
A DetailedResponse containing the result, headers and HTTP status code.
- Return type
DetailedResponse
-
delete_session
(assistant_id: str, session_id: str, **kwargs) → ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]¶ Delete session.
Deletes a session explicitly before it times out. (For more information about the session inactivity timeout, see the [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant-settings)).
- Parameters
assistant_id (str) – Unique identifier of the assistant. To find the assistant ID in the Watson Assistant user interface, open the assistant settings and click API Details. For information about creating assistants, see the [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant-add#assistant-add-task). Note: Currently, the v2 API does not support creating assistants.
session_id (str) – Unique identifier of the session.
headers (dict) – A dict containing the request headers
- Returns
A DetailedResponse containing the result, headers and HTTP status code.
- Return type
DetailedResponse
-
message
(assistant_id: str, session_id: str, *, input: Optional[ibm_watson.assistant_v2.MessageInput] = None, context: Optional[ibm_watson.assistant_v2.MessageContext] = None, **kwargs) → ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]¶ Send user input to assistant (stateful).
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.
- Parameters
assistant_id (str) – Unique identifier of the assistant. To find the assistant ID in the Watson Assistant user interface, open the assistant settings and click API Details. For information about creating assistants, see the [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant-add#assistant-add-task). Note: Currently, the v2 API does not support creating assistants.
session_id (str) – Unique identifier of the session.
input (MessageInput) – (optional) An input object that includes the input text.
context (MessageContext) – (optional) Context data for the conversation. You can use this property to set or modify context variables, which can also be accessed by dialog nodes. The context is stored by the assistant on a per-session basis. Note: The total size of the context data stored for a stateful session cannot exceed 100KB.
headers (dict) – A dict containing the request headers
- Returns
A DetailedResponse containing the result, headers and HTTP status code.
- Return type
DetailedResponse
-
message_stateless
(assistant_id: str, *, input: Optional[ibm_watson.assistant_v2.MessageInputStateless] = None, context: Optional[ibm_watson.assistant_v2.MessageContextStateless] = None, **kwargs) → ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]¶ Send user input to assistant (stateless).
Send user input to an assistant and receive a response, with conversation state (including context data) managed by your application.
- Parameters
assistant_id (str) – Unique identifier of the assistant. To find the assistant ID in the Watson Assistant user interface, open the assistant settings and click API Details. For information about creating assistants, see the [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant-add#assistant-add-task). Note: Currently, the v2 API does not support creating assistants.
input (MessageInputStateless) – (optional) An input object that includes the input text.
context (MessageContextStateless) – (optional) Context data for the conversation. You can use this property to set or modify context variables, which can also be accessed by dialog nodes. The context is not stored by the assistant. To maintain session state, include the context from the previous response. Note: The total size of the context data for a stateless session cannot exceed 250KB.
headers (dict) – A dict containing the request headers
- Returns
A DetailedResponse containing the result, headers and HTTP status code.
- Return type
DetailedResponse
-
list_logs
(assistant_id: str, *, sort: str = None, filter: str = None, page_limit: int = None, cursor: str = None, **kwargs) → ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]¶ List log events for an assistant.
List the events from the log of an assistant. This method is available only with Premium plans.
- Parameters
assistant_id (str) – Unique identifier of the assistant. To find the assistant ID in the Watson Assistant user interface, open the assistant settings and click API Details. For information about creating assistants, see the [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant-add#assistant-add-task). Note: Currently, the v2 API does not support creating assistants.
sort (str) – (optional) How to sort the returned log events. You can sort by request_timestamp. To reverse the sort order, prefix the parameter value with a minus sign (-).
filter (str) – (optional) A cacheable parameter that limits the results to those matching the specified filter. For more information, see the [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-filter-reference#filter-reference).
page_limit (int) – (optional) The number of records to return in each page of results.
cursor (str) – (optional) A token identifying the page of results to retrieve.
headers (dict) – A dict containing the request headers
- Returns
A DetailedResponse containing the result, headers and HTTP status code.
- Return type
DetailedResponse
-
delete_user_data
(customer_id: str, **kwargs) → ibm_cloud_sdk_core.detailed_response.DetailedResponse[source]¶ Delete labeled data.
Deletes all data associated with a specified customer ID. The method has no effect if no data is associated with the customer ID. You associate a customer ID with data by passing the X-Watson-Metadata header with a request that passes data. For more information about personal data and customer IDs, see [Information security](https://cloud.ibm.com/docs/assistant?topic=assistant-information-security#information-security). This operation is limited to 4 requests per minute. For more information, see Rate limiting.
-
-
class
CaptureGroup
(group: str, *, location: List[int] = None)[source]¶ Bases:
object
CaptureGroup.
- Attr str group
A recognized capture group for the entity.
- Attr List[int] location
(optional) Zero-based character offsets that indicate where the entity value begins and ends in the input text.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.CaptureGroup[source]¶ Initialize a CaptureGroup object from a json dictionary.
-
class
DialogLogMessage
(level: str, message: str)[source]¶ Bases:
object
Dialog log message details.
- Attr str level
The severity of the log message.
- Attr str message
The text of the log message.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.DialogLogMessage[source]¶ Initialize a DialogLogMessage object from a json dictionary.
-
class
DialogNodeAction
(name: str, result_variable: str, *, type: str = None, parameters: dict = None, credentials: str = None)[source]¶ Bases:
object
DialogNodeAction.
- Attr str name
The name of the action.
- Attr str type
(optional) The type of action to invoke.
- Attr dict parameters
(optional) A map of key/value pairs to be provided to the action.
- Attr str result_variable
The location in the dialog context where the result of the action is stored.
- Attr str credentials
(optional) The name of the context variable that the client application will use to pass in credentials for the action.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.DialogNodeAction[source]¶ Initialize a DialogNodeAction object from a json dictionary.
-
class
DialogNodeOutputOptionsElement
(label: str, value: ibm_watson.assistant_v2.DialogNodeOutputOptionsElementValue)[source]¶ Bases:
object
DialogNodeOutputOptionsElement.
- Attr str label
The user-facing label for the option.
- Attr DialogNodeOutputOptionsElementValue value
An object defining the message input to be sent to the assistant if the user selects the corresponding option.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.DialogNodeOutputOptionsElement[source]¶ Initialize a DialogNodeOutputOptionsElement object from a json dictionary.
-
class
DialogNodeOutputOptionsElementValue
(*, input: Optional[ibm_watson.assistant_v2.MessageInput] = None)[source]¶ Bases:
object
An object defining the message input to be sent to the assistant if the user selects the corresponding option.
- Attr MessageInput input
(optional) An input object that includes the input text.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.DialogNodeOutputOptionsElementValue[source]¶ Initialize a DialogNodeOutputOptionsElementValue object from a json dictionary.
-
class
DialogNodesVisited
(*, dialog_node: str = None, title: str = None, conditions: str = None)[source]¶ Bases:
object
DialogNodesVisited.
- Attr str dialog_node
(optional) A dialog node that was triggered during processing of the input message.
- Attr str title
(optional) The title of the dialog node.
- Attr str conditions
(optional) The conditions that trigger the dialog node.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.DialogNodesVisited[source]¶ Initialize a DialogNodesVisited object from a json dictionary.
-
class
DialogSuggestion
(label: str, value: ibm_watson.assistant_v2.DialogSuggestionValue, *, output: dict = None)[source]¶ Bases:
object
DialogSuggestion.
- Attr str label
The user-facing label for the suggestion. This label is taken from the title or user_label property of the corresponding dialog node, depending on the disambiguation options.
- Attr DialogSuggestionValue value
An object defining the message input to be sent to the assistant if the user selects the corresponding disambiguation option.
- Attr dict output
(optional) The dialog output that will be returned from the Watson Assistant service if the user selects the corresponding option.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.DialogSuggestion[source]¶ Initialize a DialogSuggestion object from a json dictionary.
-
class
DialogSuggestionValue
(*, input: Optional[ibm_watson.assistant_v2.MessageInput] = None)[source]¶ Bases:
object
An object defining the message input to be sent to the assistant if the user selects the corresponding disambiguation option.
- Attr MessageInput input
(optional) An input object that includes the input text.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.DialogSuggestionValue[source]¶ Initialize a DialogSuggestionValue object from a json dictionary.
-
class
Log
(log_id: str, request: ibm_watson.assistant_v2.MessageRequest, response: ibm_watson.assistant_v2.MessageResponse, assistant_id: str, session_id: str, skill_id: str, snapshot: str, request_timestamp: str, response_timestamp: str, language: str, *, customer_id: str = None)[source]¶ Bases:
object
Log.
- Attr str log_id
A unique identifier for the logged event.
- Attr MessageRequest request
A stateful message request formatted for the Watson Assistant service.
- Attr MessageResponse response
A response from the Watson Assistant service.
- Attr str assistant_id
Unique identifier of the assistant.
- Attr str session_id
The ID of the session the message was part of.
- Attr str skill_id
The unique identifier of the skill that responded to the message.
- Attr str snapshot
The name of the snapshot (dialog skill version) that responded to the message (for example, draft).
- Attr str request_timestamp
The timestamp for receipt of the message.
- Attr str response_timestamp
The timestamp for the system response to the message.
- Attr str language
The language of the assistant to which the message request was made.
- Attr str customer_id
(optional) The customer ID specified for the message, if any.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.Log[source]¶ Initialize a Log object from a json dictionary.
-
class
LogCollection
(logs: List[Log], pagination: ibm_watson.assistant_v2.LogPagination)[source]¶ Bases:
object
LogCollection.
- Attr List[Log] logs
An array of objects describing log events.
- Attr LogPagination pagination
The pagination data for the returned objects.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.LogCollection[source]¶ Initialize a LogCollection object from a json dictionary.
-
class
LogPagination
(*, next_url: str = None, matched: int = None, next_cursor: str = None)[source]¶ Bases:
object
The pagination data for the returned objects.
- Attr str next_url
(optional) The URL that will return the next page of results, if any.
- Attr int matched
(optional) Reserved for future use.
- Attr str next_cursor
(optional) A token identifying the next page of results.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.LogPagination[source]¶ Initialize a LogPagination object from a json dictionary.
-
class
MessageContext
(*, global_: Optional[ibm_watson.assistant_v2.MessageContextGlobal] = None, skills: Optional[ibm_watson.assistant_v2.MessageContextSkills] = None)[source]¶ Bases:
object
MessageContext.
- Attr MessageContextGlobal globalglobal_
(optional) Session context data that is shared by all skills used by the Assistant.
- Attr MessageContextSkills skills
(optional) Information specific to particular skills used by the assistant. Note: Currently, only a single child property is supported, containing variables that apply to the dialog skill used by the assistant.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.MessageContext[source]¶ Initialize a MessageContext object from a json dictionary.
-
class
MessageContextGlobal
(*, system: Optional[ibm_watson.assistant_v2.MessageContextGlobalSystem] = None, session_id: str = None)[source]¶ Bases:
object
Session context data that is shared by all skills used by the Assistant.
- Attr MessageContextGlobalSystem system
(optional) Built-in system properties that apply to all skills used by the assistant.
- Attr str session_id
(optional) The session ID.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.MessageContextGlobal[source]¶ Initialize a MessageContextGlobal object from a json dictionary.
-
class
MessageContextGlobalStateless
(*, system: Optional[ibm_watson.assistant_v2.MessageContextGlobalSystem] = None, session_id: str = None)[source]¶ Bases:
object
Session context data that is shared by all skills used by the Assistant.
- Attr MessageContextGlobalSystem system
(optional) Built-in system properties that apply to all skills used by the assistant.
- Attr str session_id
(optional) The unique identifier of the session.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.MessageContextGlobalStateless[source]¶ Initialize a MessageContextGlobalStateless object from a json dictionary.
-
class
MessageContextGlobalSystem
(*, timezone: str = None, user_id: str = None, turn_count: int = None, locale: str = None, reference_time: str = None)[source]¶ Bases:
object
Built-in system properties that apply to all skills used by the assistant.
- Attr str timezone
(optional) The user time zone. The assistant uses the time zone to correctly resolve relative time references.
- Attr str user_id
(optional) A string value that identifies the user who is interacting with the assistant. The client must provide a unique identifier for each individual end user who accesses the application. For Plus and Premium plans, this user ID is used to identify unique users for billing purposes. This string cannot contain carriage return, newline, or tab characters.
- Attr int turn_count
(optional) A counter that is automatically incremented with each turn of the conversation. A value of 1 indicates that this is the the first turn of a new conversation, which can affect the behavior of some skills (for example, triggering the start node of a dialog).
- Attr str locale
(optional) The language code for localization in the user input. The specified locale overrides the default for the assistant, and is used for interpreting entity values in user input such as date values. For example, 04/03/2018 might be interpreted either as April 3 or March 4, depending on the locale.
This property is included only if the new system entities are enabled for the
skill.
- Attr str reference_time
(optional) The base time for interpreting any relative time mentions in the user input. The specified time overrides the current server time, and is used to calculate times mentioned in relative terms such as now or tomorrow. This can be useful for simulating past or future times for testing purposes, or when analyzing documents such as news articles. This value must be a UTC time value formatted according to ISO 8601 (for example, 2019-06-26T12:00:00Z for noon on 26 June 2019. This property is included only if the new system entities are enabled for the skill.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.MessageContextGlobalSystem[source]¶ Initialize a MessageContextGlobalSystem object from a json dictionary.
-
class
LocaleEnum
(value)[source]¶ Bases:
enum.Enum
The language code for localization in the user input. The specified locale overrides the default for the assistant, and is used for interpreting entity values in user input such as date values. For example, 04/03/2018 might be interpreted either as April 3 or March 4, depending on the locale.
This property is included only if the new system entities are enabled for the
skill.
-
EN_US
= 'en-us'¶
-
EN_CA
= 'en-ca'¶
-
EN_GB
= 'en-gb'¶
-
AR_AR
= 'ar-ar'¶
-
CS_CZ
= 'cs-cz'¶
-
DE_DE
= 'de-de'¶
-
ES_ES
= 'es-es'¶
-
FR_FR
= 'fr-fr'¶
-
IT_IT
= 'it-it'¶
-
JA_JP
= 'ja-jp'¶
-
KO_KR
= 'ko-kr'¶
-
NL_NL
= 'nl-nl'¶
-
PT_BR
= 'pt-br'¶
-
ZH_CN
= 'zh-cn'¶
-
ZH_TW
= 'zh-tw'¶
-
-
class
MessageContextSkill
(*, user_defined: dict = None, system: dict = None)[source]¶ Bases:
object
Contains information specific to a particular skill used by the Assistant. The property name must be the same as the name of the skill (for example, main skill).
- Attr dict user_defined
(optional) Arbitrary variables that can be read and written by a particular skill.
- Attr dict system
(optional) System context data used by the skill.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.MessageContextSkill[source]¶ Initialize a MessageContextSkill object from a json dictionary.
-
class
MessageContextSkillSystem
(*, state: str = None, **kwargs)[source]¶ Bases:
object
System context data used by the skill.
- Attr str state
(optional) An encoded string representing the current conversation state. By saving this value and then sending it in the context of a subsequent message request, you can restore the conversation to the same state. This can be useful if you need to return to an earlier point in the conversation. If you are using stateful sessions, you can also use a stored state value to restore a paused conversation whose session has expired.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.MessageContextSkillSystem[source]¶ Initialize a MessageContextSkillSystem object from a json dictionary.
-
class
MessageContextSkills
(**kwargs)[source]¶ Bases:
object
Information specific to particular skills used by the assistant. Note: Currently, only a single child property is supported, containing variables that apply to the dialog skill used by the assistant.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.MessageContextSkills[source]¶ Initialize a MessageContextSkills object from a json dictionary.
-
classmethod
-
class
MessageContextStateless
(*, global_: Optional[ibm_watson.assistant_v2.MessageContextGlobalStateless] = None, skills: Optional[ibm_watson.assistant_v2.MessageContextSkills] = None)[source]¶ Bases:
object
MessageContextStateless.
- Attr MessageContextGlobalStateless globalglobal_
(optional) Session context data that is shared by all skills used by the Assistant.
- Attr MessageContextSkills skills
(optional) Information specific to particular skills used by the assistant. Note: Currently, only a single child property is supported, containing variables that apply to the dialog skill used by the assistant.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.MessageContextStateless[source]¶ Initialize a MessageContextStateless object from a json dictionary.
-
class
MessageInput
(*, message_type: str = None, text: str = None, intents: List[RuntimeIntent] = None, entities: List[RuntimeEntity] = None, suggestion_id: str = None, options: Optional[ibm_watson.assistant_v2.MessageInputOptions] = None)[source]¶ Bases:
object
An input object that includes the input text.
- Attr str message_type
(optional) The type of user input. Currently, only text input is supported.
- Attr str text
(optional) The text of the user input. This string cannot contain carriage return, newline, or tab characters.
- Attr List[RuntimeIntent] intents
(optional) Intents to use when evaluating the user input. Include intents from the previous response to continue using those intents rather than trying to recognize intents in the new input.
- Attr List[RuntimeEntity] entities
(optional) Entities to use when evaluating the message. Include entities from the previous response to continue using those entities rather than detecting entities in the new input.
- Attr str suggestion_id
(optional) For internal use only.
- Attr MessageInputOptions options
(optional) Optional properties that control how the assistant responds.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.MessageInput[source]¶ Initialize a MessageInput object from a json dictionary.
-
class
MessageInputOptions
(*, restart: bool = None, alternate_intents: bool = None, spelling: Optional[ibm_watson.assistant_v2.MessageInputOptionsSpelling] = None, debug: bool = None, return_context: bool = None, export: bool = None)[source]¶ Bases:
object
Optional properties that control how the assistant responds.
- Attr bool restart
(optional) Whether to restart dialog processing at the root of the dialog, regardless of any previously visited nodes. Note: This does not affect turn_count or any other context variables.
- Attr bool alternate_intents
(optional) Whether to return more than one intent. Set to true to return all matching intents.
- Attr MessageInputOptionsSpelling spelling
(optional) Spelling correction options for the message. Any options specified on an individual message override the settings configured for the skill.
- Attr bool debug
(optional) Whether to return additional diagnostic information. Set to true to return additional information in the output.debug property. If you also specify **return_context**=`true`, the returned skill context includes the system.state property.
- Attr bool return_context
(optional) Whether to return session context with the response. If you specify true, the response includes the context property. If you also specify **debug**=`true`, the returned skill context includes the system.state property.
- Attr bool export
(optional) Whether to return session context, including full conversation state. If you specify true, the response includes the context property, and the skill context includes the system.state property. Note: If export**=`true`, the context is returned regardless of the value of **return_context.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.MessageInputOptions[source]¶ Initialize a MessageInputOptions object from a json dictionary.
-
class
MessageInputOptionsSpelling
(*, suggestions: bool = None, auto_correct: bool = None)[source]¶ Bases:
object
Spelling correction options for the message. Any options specified on an individual message override the settings configured for the skill.
- Attr bool suggestions
(optional) Whether to use spelling correction when processing the input. If spelling correction is used and auto_correct is true, any spelling corrections are automatically applied to the user input. If auto_correct is false, any suggested corrections are returned in the output.spelling property. This property overrides the value of the spelling_suggestions property in the workspace settings for the skill.
- Attr bool auto_correct
(optional) Whether to use autocorrection when processing the input. If this property is true, any corrections are automatically applied to the user input, and the original text is returned in the output.spelling property of the message response. This property overrides the value of the spelling_auto_correct property in the workspace settings for the skill.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.MessageInputOptionsSpelling[source]¶ Initialize a MessageInputOptionsSpelling object from a json dictionary.
-
class
MessageInputOptionsStateless
(*, restart: bool = None, alternate_intents: bool = None, spelling: Optional[ibm_watson.assistant_v2.MessageInputOptionsSpelling] = None, debug: bool = None)[source]¶ Bases:
object
Optional properties that control how the assistant responds.
- Attr bool restart
(optional) Whether to restart dialog processing at the root of the dialog, regardless of any previously visited nodes. Note: This does not affect turn_count or any other context variables.
- Attr bool alternate_intents
(optional) Whether to return more than one intent. Set to true to return all matching intents.
- Attr MessageInputOptionsSpelling spelling
(optional) Spelling correction options for the message. Any options specified on an individual message override the settings configured for the skill.
- Attr bool debug
(optional) Whether to return additional diagnostic information. Set to true to return additional information in the output.debug property.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.MessageInputOptionsStateless[source]¶ Initialize a MessageInputOptionsStateless object from a json dictionary.
-
class
MessageInputStateless
(*, message_type: str = None, text: str = None, intents: List[RuntimeIntent] = None, entities: List[RuntimeEntity] = None, suggestion_id: str = None, options: Optional[ibm_watson.assistant_v2.MessageInputOptionsStateless] = None)[source]¶ Bases:
object
An input object that includes the input text.
- Attr str message_type
(optional) The type of user input. Currently, only text input is supported.
- Attr str text
(optional) The text of the user input. This string cannot contain carriage return, newline, or tab characters.
- Attr List[RuntimeIntent] intents
(optional) Intents to use when evaluating the user input. Include intents from the previous response to continue using those intents rather than trying to recognize intents in the new input.
- Attr List[RuntimeEntity] entities
(optional) Entities to use when evaluating the message. Include entities from the previous response to continue using those entities rather than detecting entities in the new input.
- Attr str suggestion_id
(optional) For internal use only.
- Attr MessageInputOptionsStateless options
(optional) Optional properties that control how the assistant responds.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.MessageInputStateless[source]¶ Initialize a MessageInputStateless object from a json dictionary.
-
class
MessageOutput
(*, generic: List[RuntimeResponseGeneric] = None, intents: List[RuntimeIntent] = None, entities: List[RuntimeEntity] = None, actions: List[DialogNodeAction] = None, debug: Optional[ibm_watson.assistant_v2.MessageOutputDebug] = None, user_defined: dict = None, spelling: Optional[ibm_watson.assistant_v2.MessageOutputSpelling] = None)[source]¶ Bases:
object
Assistant output to be rendered or processed by the client.
- Attr List[RuntimeResponseGeneric] generic
(optional) Output intended for any channel. It is the responsibility of the client application to implement the supported response types.
- Attr List[RuntimeIntent] intents
(optional) An array of intents recognized in the user input, sorted in descending order of confidence.
- Attr List[RuntimeEntity] entities
(optional) An array of entities identified in the user input.
- Attr List[DialogNodeAction] actions
(optional) An array of objects describing any actions requested by the dialog node.
- Attr MessageOutputDebug debug
(optional) Additional detailed information about a message response and how it was generated.
- Attr dict user_defined
(optional) An object containing any custom properties included in the response. This object includes any arbitrary properties defined in the dialog JSON editor as part of the dialog node output.
- Attr MessageOutputSpelling spelling
(optional) Properties describing any spelling corrections in the user input that was received.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.MessageOutput[source]¶ Initialize a MessageOutput object from a json dictionary.
-
class
MessageOutputDebug
(*, nodes_visited: List[DialogNodesVisited] = None, log_messages: List[DialogLogMessage] = None, branch_exited: bool = None, branch_exited_reason: str = None)[source]¶ Bases:
object
Additional detailed information about a message response and how it was generated.
- Attr List[DialogNodesVisited] nodes_visited
(optional) An array of objects containing detailed diagnostic information about the nodes that were triggered during processing of the input message.
- Attr List[DialogLogMessage] log_messages
(optional) An array of up to 50 messages logged with the request.
- Attr bool branch_exited
(optional) Assistant sets this to true when this message response concludes or interrupts a dialog.
- Attr str branch_exited_reason
(optional) When branch_exited is set to true by the Assistant, the branch_exited_reason specifies whether the dialog completed by itself or got interrupted.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.MessageOutputDebug[source]¶ Initialize a MessageOutputDebug object from a json dictionary.
-
class
MessageOutputSpelling
(*, text: str = None, original_text: str = None, suggested_text: str = None)[source]¶ Bases:
object
Properties describing any spelling corrections in the user input that was received.
- Attr str text
(optional) The user input text that was used to generate the response. If spelling autocorrection is enabled, this text reflects any spelling corrections that were applied.
- Attr str original_text
(optional) The original user input text. This property is returned only if autocorrection is enabled and the user input was corrected.
- Attr str suggested_text
(optional) Any suggested corrections of the input text. This property is returned only if spelling correction is enabled and autocorrection is disabled.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.MessageOutputSpelling[source]¶ Initialize a MessageOutputSpelling object from a json dictionary.
-
class
MessageRequest
(*, input: Optional[ibm_watson.assistant_v2.MessageInput] = None, context: Optional[ibm_watson.assistant_v2.MessageContext] = None)[source]¶ Bases:
object
A stateful message request formatted for the Watson Assistant service.
- Attr MessageInput input
(optional) An input object that includes the input text.
- Attr MessageContext context
(optional) Context data for the conversation. You can use this property to set or modify context variables, which can also be accessed by dialog nodes. The context is stored by the assistant on a per-session basis. Note: The total size of the context data stored for a stateful session cannot exceed 100KB.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.MessageRequest[source]¶ Initialize a MessageRequest object from a json dictionary.
-
class
MessageResponse
(output: ibm_watson.assistant_v2.MessageOutput, *, context: Optional[ibm_watson.assistant_v2.MessageContext] = None)[source]¶ Bases:
object
A response from the Watson Assistant service.
- Attr MessageOutput output
Assistant output to be rendered or processed by the client.
- Attr MessageContext context
(optional) Context data for the conversation. You can use this property to access context variables. The context is stored by the assistant on a per-session basis. Note: The context is included in message responses only if **return_context**=`true` in the message request. Full context is always included in logs.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.MessageResponse[source]¶ Initialize a MessageResponse object from a json dictionary.
-
class
MessageResponseStateless
(output: ibm_watson.assistant_v2.MessageOutput, context: ibm_watson.assistant_v2.MessageContextStateless)[source]¶ Bases:
object
A stateless response from the Watson Assistant service.
- Attr MessageOutput output
Assistant output to be rendered or processed by the client.
- Attr MessageContextStateless context
Context data for the conversation. You can use this property to access context variables. The context is not stored by the assistant; to maintain session state, include the context from the response in the next message.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.MessageResponseStateless[source]¶ Initialize a MessageResponseStateless object from a json dictionary.
-
class
RuntimeEntity
(entity: str, location: List[int], value: str, *, confidence: float = None, metadata: dict = None, groups: List[CaptureGroup] = None, interpretation: Optional[ibm_watson.assistant_v2.RuntimeEntityInterpretation] = None, alternatives: List[RuntimeEntityAlternative] = None, role: Optional[ibm_watson.assistant_v2.RuntimeEntityRole] = None)[source]¶ Bases:
object
The entity value that was recognized in the user input.
- Attr str entity
An entity detected in the input.
- Attr List[int] location
An array of zero-based character offsets that indicate where the detected entity values begin and end in the input text.
- Attr str value
The term in the input text that was recognized as an entity value.
- Attr float confidence
(optional) A decimal percentage that represents Watson’s confidence in the recognized entity.
- Attr dict metadata
(optional) Any metadata for the entity.
- Attr List[CaptureGroup] groups
(optional) The recognized capture groups for 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 skill. 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).
- 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 @sys-time and @sys-date entities when the user’s input is ambiguous. This property is included only if the new system entities are enabled for the skill.
- Attr RuntimeEntityRole role
(optional) An object describing the role played by a system entity that is specifies the beginning or end of a range recognized in the user input. This property is included only if the new system entities are enabled for the skill.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.RuntimeEntity[source]¶ Initialize a RuntimeEntity object from a json dictionary.
-
class
RuntimeEntityAlternative
(*, value: str = None, confidence: float = None)[source]¶ Bases:
object
An alternative value for the recognized entity.
- Attr str value
(optional) The entity value that was recognized in the user input.
- Attr float confidence
(optional) A decimal percentage that represents Watson’s confidence in the recognized entity.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.RuntimeEntityAlternative[source]¶ Initialize a RuntimeEntityAlternative object from a json dictionary.
-
class
RuntimeEntityInterpretation
(*, calendar_type: str = None, datetime_link: str = None, festival: str = None, granularity: str = None, range_link: str = None, range_modifier: str = None, relative_day: float = None, relative_month: float = None, relative_week: float = None, relative_weekend: float = None, relative_year: float = None, specific_day: float = None, specific_day_of_week: str = None, specific_month: float = None, specific_quarter: float = None, specific_year: float = None, numeric_value: float = None, subtype: str = None, part_of_day: str = None, relative_hour: float = None, relative_minute: float = None, relative_second: float = None, specific_hour: float = None, specific_minute: float = None, specific_second: float = None, timezone: str = None)[source]¶ Bases:
object
RuntimeEntityInterpretation.
- Attr str calendar_type
(optional) The calendar used to represent a recognized date (for example, Gregorian).
- Attr str datetime_link
(optional) A unique identifier used to associate a recognized time and date. If the user input contains a date and time that are mentioned together (for example, Today at 5, the same datetime_link value is returned for both the @sys-date and @sys-time entities).
- Attr str festival
(optional) A locale-specific holiday name (such as thanksgiving or christmas). This property is included when a @sys-date entity is recognized based on a holiday name in the user input.
- Attr str granularity
(optional) The precision or duration of a time range specified by a recognized @sys-time or @sys-date entity.
- Attr str range_link
(optional) A unique identifier used to associate multiple recognized @sys-date, @sys-time, or @sys-number entities that are recognized as a range of values in the user’s input (for example, from July 4 until July 14 or from 20 to 25).
- Attr str range_modifier
(optional) The word in the user input that indicates that a sys-date or sys-time entity is part of an implied range where only one date or time is specified (for example, since or until).
- Attr float relative_day
(optional) A recognized mention of a relative day, represented numerically as an offset from the current date (for example, -1 for yesterday or 10 for in ten days).
- Attr float relative_month
(optional) A recognized mention of a relative month, represented numerically as an offset from the current month (for example, 1 for next month or -3 for three months ago).
- Attr float relative_week
(optional) A recognized mention of a relative week, represented numerically as an offset from the current week (for example, 2 for in two weeks or -1 for `last week).
- Attr float relative_weekend
(optional) A recognized mention of a relative date range for a weekend, represented numerically as an offset from the current weekend (for example, 0 for this weekend or -1 for last weekend).
- Attr float relative_year
(optional) A recognized mention of a relative year, represented numerically as an offset from the current year (for example, 1 for next year or -5 for five years ago).
- Attr float specific_day
(optional) A recognized mention of a specific date, represented numerically as the date within the month (for example, 30 for June 30.).
- Attr str specific_day_of_week
(optional) A recognized mention of a specific day of the week as a lowercase string (for example, monday).
- Attr float specific_month
(optional) A recognized mention of a specific month, represented numerically (for example, 7 for July).
- Attr float specific_quarter
(optional) A recognized mention of a specific quarter, represented numerically (for example, 3 for the third quarter).
- Attr float specific_year
(optional) A recognized mention of a specific year (for example, 2016).
- Attr float numeric_value
(optional) A recognized numeric value, represented as an integer or double.
- Attr str subtype
(optional) The type of numeric value recognized in the user input (integer or rational).
- Attr str part_of_day
(optional) A recognized term for a time that was mentioned as a part of the day in the user’s input (for example, morning or afternoon).
- Attr float relative_hour
(optional) A recognized mention of a relative hour, represented numerically as an offset from the current hour (for example, 3 for in three hours or -1 for an hour ago).
- Attr float relative_minute
(optional) A recognized mention of a relative time, represented numerically as an offset in minutes from the current time (for example, 5 for in five minutes or -15 for fifteen minutes ago).
- Attr float relative_second
(optional) A recognized mention of a relative time, represented numerically as an offset in seconds from the current time (for example, 10 for in ten seconds or -30 for thirty seconds ago).
- Attr float specific_hour
(optional) A recognized specific hour mentioned as part of a time value (for example, 10 for 10:15 AM.).
- Attr float specific_minute
(optional) A recognized specific minute mentioned as part of a time value (for example, 15 for 10:15 AM.).
- Attr float specific_second
(optional) A recognized specific second mentioned as part of a time value (for example, 30 for 10:15:30 AM.).
- Attr str timezone
(optional) A recognized time zone mentioned as part of a time value (for example, EST).
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.RuntimeEntityInterpretation[source]¶ Initialize a RuntimeEntityInterpretation object from a json dictionary.
-
class
GranularityEnum
(value)[source]¶ Bases:
enum.Enum
The precision or duration of a time range specified by a recognized @sys-time or @sys-date entity.
-
DAY
= 'day'¶
-
FORTNIGHT
= 'fortnight'¶
-
HOUR
= 'hour'¶
-
INSTANT
= 'instant'¶
-
MINUTE
= 'minute'¶
-
MONTH
= 'month'¶
-
QUARTER
= 'quarter'¶
-
SECOND
= 'second'¶
-
WEEK
= 'week'¶
-
WEEKEND
= 'weekend'¶
-
YEAR
= 'year'¶
-
-
class
RuntimeEntityRole
(*, type: str = None)[source]¶ Bases:
object
An object describing the role played by a system entity that is specifies the beginning or end of a range recognized in the user input. This property is included only if the new system entities are enabled for the skill.
- Attr str type
(optional) The relationship of the entity to the range.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.RuntimeEntityRole[source]¶ Initialize a RuntimeEntityRole object from a json dictionary.
-
class
RuntimeIntent
(intent: str, confidence: float)[source]¶ Bases:
object
An intent identified in the user input.
- Attr str intent
The name of the recognized intent.
- Attr float confidence
A decimal percentage that represents Watson’s confidence in the intent.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.RuntimeIntent[source]¶ Initialize a RuntimeIntent object from a json dictionary.
-
class
RuntimeResponseGeneric
(response_type: str, *, text: str = None, time: int = None, typing: bool = None, source: str = None, title: str = None, description: str = None, preference: str = None, options: List[DialogNodeOutputOptionsElement] = None, message_to_human_agent: str = None, topic: str = None, suggestions: List[DialogSuggestion] = None, header: str = None, results: List[SearchResult] = None)[source]¶ Bases:
object
RuntimeResponseGeneric.
- Attr str response_type
The type of response returned by the dialog node. The specified response type must be supported by the client application or channel.
- Attr str text
(optional) The text of the response.
- Attr int time
(optional) How long to pause, in milliseconds.
- Attr bool typing
(optional) Whether to send a “user is typing” event during the pause.
- Attr str source
(optional) The URL of the image.
- Attr str title
(optional) The title or introductory text to show before the response.
- Attr str description
(optional) The description to show with the the response.
- Attr str preference
(optional) The preferred type of control to display.
- Attr List[DialogNodeOutputOptionsElement] options
(optional) An array of objects describing the options from which the user can choose.
- 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 topic
(optional) A label identifying the topic of the conversation, derived from the user_label property of the relevant node.
- Attr List[DialogSuggestion] suggestions
(optional) An array of objects describing the possible matching dialog nodes from which the user can choose.
- Attr str header
(optional) The title or introductory text to show before the response. This text is defined in the search skill configuration.
- Attr List[SearchResult] results
(optional) An array of objects containing search results.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.RuntimeResponseGeneric[source]¶ Initialize a RuntimeResponseGeneric object from a json dictionary.
-
class
ResponseTypeEnum
(value)[source]¶ Bases:
enum.Enum
The type of response returned by the dialog node. The specified response type must be supported by the client application or channel.
-
TEXT
= 'text'¶
-
PAUSE
= 'pause'¶
-
IMAGE
= 'image'¶
-
OPTION
= 'option'¶
-
CONNECT_TO_AGENT
= 'connect_to_agent'¶
-
SUGGESTION
= 'suggestion'¶
-
SEARCH
= 'search'¶
-
-
class
SearchResult
(id: str, result_metadata: ibm_watson.assistant_v2.SearchResultMetadata, *, body: str = None, title: str = None, url: str = None, highlight: Optional[ibm_watson.assistant_v2.SearchResultHighlight] = None)[source]¶ Bases:
object
SearchResult.
- Attr str id
The unique identifier of the document in the Discovery service collection. This property is included in responses from search skills, which are available only to Plus or Premium plan users.
- Attr SearchResultMetadata result_metadata
An object containing search result metadata from the Discovery service.
- Attr str body
(optional) A description of the search result. This is taken from an abstract, summary, or highlight field in the Discovery service response, as specified in the search skill configuration.
- Attr str title
(optional) The title of the search result. This is taken from a title or name field in the Discovery service response, as specified in the search skill configuration.
- Attr str url
(optional) The URL of the original data object in its native data source.
- Attr SearchResultHighlight highlight
(optional) An object containing segments of text from search results with query-matching text highlighted using HTML <em> tags.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.SearchResult[source]¶ Initialize a SearchResult object from a json dictionary.
-
class
SearchResultHighlight
(*, body: List[str] = None, title: List[str] = None, url: List[str] = None, **kwargs)[source]¶ Bases:
object
An object containing segments of text from search results with query-matching text highlighted using HTML <em> tags.
- Attr List[str] body
(optional) An array of strings containing segments taken from body text in the search results, with query-matching substrings highlighted.
- Attr List[str] title
(optional) An array of strings containing segments taken from title text in the search results, with query-matching substrings highlighted.
- Attr List[str] url
(optional) An array of strings containing segments taken from URLs in the search results, with query-matching substrings highlighted.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.SearchResultHighlight[source]¶ Initialize a SearchResultHighlight object from a json dictionary.
-
class
SearchResultMetadata
(*, confidence: float = None, score: float = None)[source]¶ Bases:
object
An object containing search result metadata from the Discovery service.
- Attr float confidence
(optional) The confidence score for the given result. For more information about how the confidence is calculated, see the Discovery service [documentation](../discovery#query-your-collection).
- Attr float score
(optional) An unbounded measure of the relevance of a particular result, dependent on the query and matching document. A higher score indicates a greater match to the query parameters.
-
classmethod
from_dict
(_dict: Dict) → ibm_watson.assistant_v2.SearchResultMetadata[source]¶ Initialize a SearchResultMetadata object from a json dictionary.