diff --git a/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/__init__.py b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/__init__.py new file mode 100644 index 000000000000..7a3d74853c85 --- /dev/null +++ b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/__init__.py @@ -0,0 +1,18 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .luis_runtime_client import LUISRuntimeClient +from .version import VERSION + +__all__ = ['LUISRuntimeClient'] + +__version__ = VERSION + diff --git a/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/luis_runtime_client.py b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/luis_runtime_client.py new file mode 100644 index 000000000000..f7158cdf38d3 --- /dev/null +++ b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/luis_runtime_client.py @@ -0,0 +1,72 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.service_client import SDKClient +from msrest import Configuration, Serializer, Deserializer +from .version import VERSION +from .operations.prediction_operations import PredictionOperations +from . import models + + +class LUISRuntimeClientConfiguration(Configuration): + """Configuration for LUISRuntimeClient + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credentials: Subscription credentials which uniquely identify + client subscription. + :type credentials: None + :param str base_url: Service URL + """ + + def __init__( + self, credentials, base_url=None): + + if credentials is None: + raise ValueError("Parameter 'credentials' must not be None.") + if not base_url: + base_url = 'https://api.cognitive.microsoft.com/luis/v2.0' + + super(LUISRuntimeClientConfiguration, self).__init__(base_url) + + self.add_user_agent('azure-cognitiveservices-language-luis/{}'.format(VERSION)) + + self.credentials = credentials + + +class LUISRuntimeClient(SDKClient): + """LUISRuntimeClient + + :ivar config: Configuration for client. + :vartype config: LUISRuntimeClientConfiguration + + :ivar prediction: Prediction operations + :vartype prediction: azure.cognitiveservices.language.luis.runtime.operations.PredictionOperations + + :param credentials: Subscription credentials which uniquely identify + client subscription. + :type credentials: None + :param str base_url: Service URL + """ + + def __init__( + self, credentials, base_url=None): + + self.config = LUISRuntimeClientConfiguration(credentials, base_url) + super(LUISRuntimeClient, self).__init__(self.config.credentials, self.config) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self.api_version = '2.0' + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.prediction = PredictionOperations( + self._client, self.config, self._serialize, self._deserialize) diff --git a/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/__init__.py b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/__init__.py new file mode 100644 index 000000000000..a17c1378159c --- /dev/null +++ b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/__init__.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +try: + from .intent_model_py3 import IntentModel + from .entity_model_py3 import EntityModel + from .composite_child_model_py3 import CompositeChildModel + from .composite_entity_model_py3 import CompositeEntityModel + from .sentiment_py3 import Sentiment + from .luis_result_py3 import LuisResult + from .entity_with_score_py3 import EntityWithScore + from .entity_with_resolution_py3 import EntityWithResolution + from .api_error_py3 import APIError, APIErrorException +except (SyntaxError, ImportError): + from .intent_model import IntentModel + from .entity_model import EntityModel + from .composite_child_model import CompositeChildModel + from .composite_entity_model import CompositeEntityModel + from .sentiment import Sentiment + from .luis_result import LuisResult + from .entity_with_score import EntityWithScore + from .entity_with_resolution import EntityWithResolution + from .api_error import APIError, APIErrorException + +__all__ = [ + 'IntentModel', + 'EntityModel', + 'CompositeChildModel', + 'CompositeEntityModel', + 'Sentiment', + 'LuisResult', + 'EntityWithScore', + 'EntityWithResolution', + 'APIError', 'APIErrorException', +] diff --git a/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/api_error.py b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/api_error.py new file mode 100644 index 000000000000..13f85dd56829 --- /dev/null +++ b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/api_error.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class APIError(Model): + """Error information returned by the API. + + :param status_code: HTTP Status code + :type status_code: str + :param message: Cause of the error. + :type message: str + """ + + _attribute_map = { + 'status_code': {'key': 'statusCode', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(APIError, self).__init__(**kwargs) + self.status_code = kwargs.get('status_code', None) + self.message = kwargs.get('message', None) + + +class APIErrorException(HttpOperationError): + """Server responsed with exception of type: 'APIError'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(APIErrorException, self).__init__(deserialize, response, 'APIError', *args) diff --git a/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/api_error_py3.py b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/api_error_py3.py new file mode 100644 index 000000000000..cfde35f5288f --- /dev/null +++ b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/api_error_py3.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class APIError(Model): + """Error information returned by the API. + + :param status_code: HTTP Status code + :type status_code: str + :param message: Cause of the error. + :type message: str + """ + + _attribute_map = { + 'status_code': {'key': 'statusCode', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__(self, *, status_code: str=None, message: str=None, **kwargs) -> None: + super(APIError, self).__init__(**kwargs) + self.status_code = status_code + self.message = message + + +class APIErrorException(HttpOperationError): + """Server responsed with exception of type: 'APIError'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(APIErrorException, self).__init__(deserialize, response, 'APIError', *args) diff --git a/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/composite_child_model.py b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/composite_child_model.py new file mode 100644 index 000000000000..5ebd233ebcfd --- /dev/null +++ b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/composite_child_model.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class CompositeChildModel(Model): + """Child entity in a LUIS Composite Entity. + + All required parameters must be populated in order to send to Azure. + + :param type: Required. Type of child entity. + :type type: str + :param value: Required. Value extracted by LUIS. + :type value: str + """ + + _validation = { + 'type': {'required': True}, + 'value': {'required': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(CompositeChildModel, self).__init__(**kwargs) + self.type = kwargs.get('type', None) + self.value = kwargs.get('value', None) diff --git a/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/composite_child_model_py3.py b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/composite_child_model_py3.py new file mode 100644 index 000000000000..e02d60121c03 --- /dev/null +++ b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/composite_child_model_py3.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class CompositeChildModel(Model): + """Child entity in a LUIS Composite Entity. + + All required parameters must be populated in order to send to Azure. + + :param type: Required. Type of child entity. + :type type: str + :param value: Required. Value extracted by LUIS. + :type value: str + """ + + _validation = { + 'type': {'required': True}, + 'value': {'required': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + } + + def __init__(self, *, type: str, value: str, **kwargs) -> None: + super(CompositeChildModel, self).__init__(**kwargs) + self.type = type + self.value = value diff --git a/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/composite_entity_model.py b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/composite_entity_model.py new file mode 100644 index 000000000000..a41140ae6d3d --- /dev/null +++ b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/composite_entity_model.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class CompositeEntityModel(Model): + """LUIS Composite Entity. + + All required parameters must be populated in order to send to Azure. + + :param parent_type: Required. Type/name of parent entity. + :type parent_type: str + :param value: Required. Value for composite entity extracted by LUIS. + :type value: str + :param children: Required. Child entities. + :type children: + list[~azure.cognitiveservices.language.luis.runtime.models.CompositeChildModel] + """ + + _validation = { + 'parent_type': {'required': True}, + 'value': {'required': True}, + 'children': {'required': True}, + } + + _attribute_map = { + 'parent_type': {'key': 'parentType', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + 'children': {'key': 'children', 'type': '[CompositeChildModel]'}, + } + + def __init__(self, **kwargs): + super(CompositeEntityModel, self).__init__(**kwargs) + self.parent_type = kwargs.get('parent_type', None) + self.value = kwargs.get('value', None) + self.children = kwargs.get('children', None) diff --git a/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/composite_entity_model_py3.py b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/composite_entity_model_py3.py new file mode 100644 index 000000000000..45ac985fffc4 --- /dev/null +++ b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/composite_entity_model_py3.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class CompositeEntityModel(Model): + """LUIS Composite Entity. + + All required parameters must be populated in order to send to Azure. + + :param parent_type: Required. Type/name of parent entity. + :type parent_type: str + :param value: Required. Value for composite entity extracted by LUIS. + :type value: str + :param children: Required. Child entities. + :type children: + list[~azure.cognitiveservices.language.luis.runtime.models.CompositeChildModel] + """ + + _validation = { + 'parent_type': {'required': True}, + 'value': {'required': True}, + 'children': {'required': True}, + } + + _attribute_map = { + 'parent_type': {'key': 'parentType', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + 'children': {'key': 'children', 'type': '[CompositeChildModel]'}, + } + + def __init__(self, *, parent_type: str, value: str, children, **kwargs) -> None: + super(CompositeEntityModel, self).__init__(**kwargs) + self.parent_type = parent_type + self.value = value + self.children = children diff --git a/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/entity_model.py b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/entity_model.py new file mode 100644 index 000000000000..3c9ab0bea6bc --- /dev/null +++ b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/entity_model.py @@ -0,0 +1,56 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class EntityModel(Model): + """An entity extracted from the utterance. + + All required parameters must be populated in order to send to Azure. + + :param additional_properties: Unmatched properties from the message are + deserialized this collection + :type additional_properties: dict[str, object] + :param entity: Required. Name of the entity, as defined in LUIS. + :type entity: str + :param type: Required. Type of the entity, as defined in LUIS. + :type type: str + :param start_index: Required. The position of the first character of the + matched entity within the utterance. + :type start_index: int + :param end_index: Required. The position of the last character of the + matched entity within the utterance. + :type end_index: int + """ + + _validation = { + 'entity': {'required': True}, + 'type': {'required': True}, + 'start_index': {'required': True}, + 'end_index': {'required': True}, + } + + _attribute_map = { + 'additional_properties': {'key': '', 'type': '{object}'}, + 'entity': {'key': 'entity', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'start_index': {'key': 'startIndex', 'type': 'int'}, + 'end_index': {'key': 'endIndex', 'type': 'int'}, + } + + def __init__(self, **kwargs): + super(EntityModel, self).__init__(**kwargs) + self.additional_properties = kwargs.get('additional_properties', None) + self.entity = kwargs.get('entity', None) + self.type = kwargs.get('type', None) + self.start_index = kwargs.get('start_index', None) + self.end_index = kwargs.get('end_index', None) diff --git a/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/entity_model_py3.py b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/entity_model_py3.py new file mode 100644 index 000000000000..d66eda908ac1 --- /dev/null +++ b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/entity_model_py3.py @@ -0,0 +1,56 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class EntityModel(Model): + """An entity extracted from the utterance. + + All required parameters must be populated in order to send to Azure. + + :param additional_properties: Unmatched properties from the message are + deserialized this collection + :type additional_properties: dict[str, object] + :param entity: Required. Name of the entity, as defined in LUIS. + :type entity: str + :param type: Required. Type of the entity, as defined in LUIS. + :type type: str + :param start_index: Required. The position of the first character of the + matched entity within the utterance. + :type start_index: int + :param end_index: Required. The position of the last character of the + matched entity within the utterance. + :type end_index: int + """ + + _validation = { + 'entity': {'required': True}, + 'type': {'required': True}, + 'start_index': {'required': True}, + 'end_index': {'required': True}, + } + + _attribute_map = { + 'additional_properties': {'key': '', 'type': '{object}'}, + 'entity': {'key': 'entity', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'start_index': {'key': 'startIndex', 'type': 'int'}, + 'end_index': {'key': 'endIndex', 'type': 'int'}, + } + + def __init__(self, *, entity: str, type: str, start_index: int, end_index: int, additional_properties=None, **kwargs) -> None: + super(EntityModel, self).__init__(**kwargs) + self.additional_properties = additional_properties + self.entity = entity + self.type = type + self.start_index = start_index + self.end_index = end_index diff --git a/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/entity_with_resolution.py b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/entity_with_resolution.py new file mode 100644 index 000000000000..6218f437891d --- /dev/null +++ b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/entity_with_resolution.py @@ -0,0 +1,57 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .entity_model import EntityModel + + +class EntityWithResolution(EntityModel): + """EntityWithResolution. + + All required parameters must be populated in order to send to Azure. + + :param additional_properties: Unmatched properties from the message are + deserialized this collection + :type additional_properties: dict[str, object] + :param entity: Required. Name of the entity, as defined in LUIS. + :type entity: str + :param type: Required. Type of the entity, as defined in LUIS. + :type type: str + :param start_index: Required. The position of the first character of the + matched entity within the utterance. + :type start_index: int + :param end_index: Required. The position of the last character of the + matched entity within the utterance. + :type end_index: int + :param resolution: Required. Resolution values for pre-built LUIS + entities. + :type resolution: object + """ + + _validation = { + 'entity': {'required': True}, + 'type': {'required': True}, + 'start_index': {'required': True}, + 'end_index': {'required': True}, + 'resolution': {'required': True}, + } + + _attribute_map = { + 'additional_properties': {'key': '', 'type': '{object}'}, + 'entity': {'key': 'entity', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'start_index': {'key': 'startIndex', 'type': 'int'}, + 'end_index': {'key': 'endIndex', 'type': 'int'}, + 'resolution': {'key': 'resolution', 'type': 'object'}, + } + + def __init__(self, **kwargs): + super(EntityWithResolution, self).__init__(**kwargs) + self.resolution = kwargs.get('resolution', None) diff --git a/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/entity_with_resolution_py3.py b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/entity_with_resolution_py3.py new file mode 100644 index 000000000000..a78adecd6d35 --- /dev/null +++ b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/entity_with_resolution_py3.py @@ -0,0 +1,57 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .entity_model_py3 import EntityModel + + +class EntityWithResolution(EntityModel): + """EntityWithResolution. + + All required parameters must be populated in order to send to Azure. + + :param additional_properties: Unmatched properties from the message are + deserialized this collection + :type additional_properties: dict[str, object] + :param entity: Required. Name of the entity, as defined in LUIS. + :type entity: str + :param type: Required. Type of the entity, as defined in LUIS. + :type type: str + :param start_index: Required. The position of the first character of the + matched entity within the utterance. + :type start_index: int + :param end_index: Required. The position of the last character of the + matched entity within the utterance. + :type end_index: int + :param resolution: Required. Resolution values for pre-built LUIS + entities. + :type resolution: object + """ + + _validation = { + 'entity': {'required': True}, + 'type': {'required': True}, + 'start_index': {'required': True}, + 'end_index': {'required': True}, + 'resolution': {'required': True}, + } + + _attribute_map = { + 'additional_properties': {'key': '', 'type': '{object}'}, + 'entity': {'key': 'entity', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'start_index': {'key': 'startIndex', 'type': 'int'}, + 'end_index': {'key': 'endIndex', 'type': 'int'}, + 'resolution': {'key': 'resolution', 'type': 'object'}, + } + + def __init__(self, *, entity: str, type: str, start_index: int, end_index: int, resolution, additional_properties=None, **kwargs) -> None: + super(EntityWithResolution, self).__init__(additional_properties=additional_properties, entity=entity, type=type, start_index=start_index, end_index=end_index, **kwargs) + self.resolution = resolution diff --git a/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/entity_with_score.py b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/entity_with_score.py new file mode 100644 index 000000000000..a31e75109740 --- /dev/null +++ b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/entity_with_score.py @@ -0,0 +1,57 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .entity_model import EntityModel + + +class EntityWithScore(EntityModel): + """EntityWithScore. + + All required parameters must be populated in order to send to Azure. + + :param additional_properties: Unmatched properties from the message are + deserialized this collection + :type additional_properties: dict[str, object] + :param entity: Required. Name of the entity, as defined in LUIS. + :type entity: str + :param type: Required. Type of the entity, as defined in LUIS. + :type type: str + :param start_index: Required. The position of the first character of the + matched entity within the utterance. + :type start_index: int + :param end_index: Required. The position of the last character of the + matched entity within the utterance. + :type end_index: int + :param score: Required. Associated prediction score for the intent + (float). + :type score: float + """ + + _validation = { + 'entity': {'required': True}, + 'type': {'required': True}, + 'start_index': {'required': True}, + 'end_index': {'required': True}, + 'score': {'required': True, 'maximum': 1, 'minimum': 0}, + } + + _attribute_map = { + 'additional_properties': {'key': '', 'type': '{object}'}, + 'entity': {'key': 'entity', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'start_index': {'key': 'startIndex', 'type': 'int'}, + 'end_index': {'key': 'endIndex', 'type': 'int'}, + 'score': {'key': 'score', 'type': 'float'}, + } + + def __init__(self, **kwargs): + super(EntityWithScore, self).__init__(**kwargs) + self.score = kwargs.get('score', None) diff --git a/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/entity_with_score_py3.py b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/entity_with_score_py3.py new file mode 100644 index 000000000000..5193300a0938 --- /dev/null +++ b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/entity_with_score_py3.py @@ -0,0 +1,57 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .entity_model_py3 import EntityModel + + +class EntityWithScore(EntityModel): + """EntityWithScore. + + All required parameters must be populated in order to send to Azure. + + :param additional_properties: Unmatched properties from the message are + deserialized this collection + :type additional_properties: dict[str, object] + :param entity: Required. Name of the entity, as defined in LUIS. + :type entity: str + :param type: Required. Type of the entity, as defined in LUIS. + :type type: str + :param start_index: Required. The position of the first character of the + matched entity within the utterance. + :type start_index: int + :param end_index: Required. The position of the last character of the + matched entity within the utterance. + :type end_index: int + :param score: Required. Associated prediction score for the intent + (float). + :type score: float + """ + + _validation = { + 'entity': {'required': True}, + 'type': {'required': True}, + 'start_index': {'required': True}, + 'end_index': {'required': True}, + 'score': {'required': True, 'maximum': 1, 'minimum': 0}, + } + + _attribute_map = { + 'additional_properties': {'key': '', 'type': '{object}'}, + 'entity': {'key': 'entity', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'start_index': {'key': 'startIndex', 'type': 'int'}, + 'end_index': {'key': 'endIndex', 'type': 'int'}, + 'score': {'key': 'score', 'type': 'float'}, + } + + def __init__(self, *, entity: str, type: str, start_index: int, end_index: int, score: float, additional_properties=None, **kwargs) -> None: + super(EntityWithScore, self).__init__(additional_properties=additional_properties, entity=entity, type=type, start_index=start_index, end_index=end_index, **kwargs) + self.score = score diff --git a/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/intent_model.py b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/intent_model.py new file mode 100644 index 000000000000..dc2dc7e526b7 --- /dev/null +++ b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/intent_model.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class IntentModel(Model): + """An intent detected from the utterance. + + :param intent: Name of the intent, as defined in LUIS. + :type intent: str + :param score: Associated prediction score for the intent (float). + :type score: float + """ + + _validation = { + 'score': {'maximum': 1, 'minimum': 0}, + } + + _attribute_map = { + 'intent': {'key': 'intent', 'type': 'str'}, + 'score': {'key': 'score', 'type': 'float'}, + } + + def __init__(self, **kwargs): + super(IntentModel, self).__init__(**kwargs) + self.intent = kwargs.get('intent', None) + self.score = kwargs.get('score', None) diff --git a/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/intent_model_py3.py b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/intent_model_py3.py new file mode 100644 index 000000000000..48e48ec42a0e --- /dev/null +++ b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/intent_model_py3.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class IntentModel(Model): + """An intent detected from the utterance. + + :param intent: Name of the intent, as defined in LUIS. + :type intent: str + :param score: Associated prediction score for the intent (float). + :type score: float + """ + + _validation = { + 'score': {'maximum': 1, 'minimum': 0}, + } + + _attribute_map = { + 'intent': {'key': 'intent', 'type': 'str'}, + 'score': {'key': 'score', 'type': 'float'}, + } + + def __init__(self, *, intent: str=None, score: float=None, **kwargs) -> None: + super(IntentModel, self).__init__(**kwargs) + self.intent = intent + self.score = score diff --git a/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/luis_result.py b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/luis_result.py new file mode 100644 index 000000000000..15b9ac3de342 --- /dev/null +++ b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/luis_result.py @@ -0,0 +1,60 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class LuisResult(Model): + """Prediction, based on the input query, containing intent(s) and entities. + + :param query: The input utterance that was analized. + :type query: str + :param altered_query: The corrected utterance (when spell checking was + enabled). + :type altered_query: str + :param top_scoring_intent: + :type top_scoring_intent: + ~azure.cognitiveservices.language.luis.runtime.models.IntentModel + :param intents: All the intents (and their score) that were detected from + utterance. + :type intents: + list[~azure.cognitiveservices.language.luis.runtime.models.IntentModel] + :param entities: The entities extracted from the utterance. + :type entities: + list[~azure.cognitiveservices.language.luis.runtime.models.EntityModel] + :param composite_entities: The composite entities extracted from the + utterance. + :type composite_entities: + list[~azure.cognitiveservices.language.luis.runtime.models.CompositeEntityModel] + :param sentiment_analysis: + :type sentiment_analysis: + ~azure.cognitiveservices.language.luis.runtime.models.Sentiment + """ + + _attribute_map = { + 'query': {'key': 'query', 'type': 'str'}, + 'altered_query': {'key': 'alteredQuery', 'type': 'str'}, + 'top_scoring_intent': {'key': 'topScoringIntent', 'type': 'IntentModel'}, + 'intents': {'key': 'intents', 'type': '[IntentModel]'}, + 'entities': {'key': 'entities', 'type': '[EntityModel]'}, + 'composite_entities': {'key': 'compositeEntities', 'type': '[CompositeEntityModel]'}, + 'sentiment_analysis': {'key': 'sentimentAnalysis', 'type': 'Sentiment'}, + } + + def __init__(self, **kwargs): + super(LuisResult, self).__init__(**kwargs) + self.query = kwargs.get('query', None) + self.altered_query = kwargs.get('altered_query', None) + self.top_scoring_intent = kwargs.get('top_scoring_intent', None) + self.intents = kwargs.get('intents', None) + self.entities = kwargs.get('entities', None) + self.composite_entities = kwargs.get('composite_entities', None) + self.sentiment_analysis = kwargs.get('sentiment_analysis', None) diff --git a/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/luis_result_py3.py b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/luis_result_py3.py new file mode 100644 index 000000000000..180a2aaf6114 --- /dev/null +++ b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/luis_result_py3.py @@ -0,0 +1,60 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class LuisResult(Model): + """Prediction, based on the input query, containing intent(s) and entities. + + :param query: The input utterance that was analized. + :type query: str + :param altered_query: The corrected utterance (when spell checking was + enabled). + :type altered_query: str + :param top_scoring_intent: + :type top_scoring_intent: + ~azure.cognitiveservices.language.luis.runtime.models.IntentModel + :param intents: All the intents (and their score) that were detected from + utterance. + :type intents: + list[~azure.cognitiveservices.language.luis.runtime.models.IntentModel] + :param entities: The entities extracted from the utterance. + :type entities: + list[~azure.cognitiveservices.language.luis.runtime.models.EntityModel] + :param composite_entities: The composite entities extracted from the + utterance. + :type composite_entities: + list[~azure.cognitiveservices.language.luis.runtime.models.CompositeEntityModel] + :param sentiment_analysis: + :type sentiment_analysis: + ~azure.cognitiveservices.language.luis.runtime.models.Sentiment + """ + + _attribute_map = { + 'query': {'key': 'query', 'type': 'str'}, + 'altered_query': {'key': 'alteredQuery', 'type': 'str'}, + 'top_scoring_intent': {'key': 'topScoringIntent', 'type': 'IntentModel'}, + 'intents': {'key': 'intents', 'type': '[IntentModel]'}, + 'entities': {'key': 'entities', 'type': '[EntityModel]'}, + 'composite_entities': {'key': 'compositeEntities', 'type': '[CompositeEntityModel]'}, + 'sentiment_analysis': {'key': 'sentimentAnalysis', 'type': 'Sentiment'}, + } + + def __init__(self, *, query: str=None, altered_query: str=None, top_scoring_intent=None, intents=None, entities=None, composite_entities=None, sentiment_analysis=None, **kwargs) -> None: + super(LuisResult, self).__init__(**kwargs) + self.query = query + self.altered_query = altered_query + self.top_scoring_intent = top_scoring_intent + self.intents = intents + self.entities = entities + self.composite_entities = composite_entities + self.sentiment_analysis = sentiment_analysis diff --git a/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/sentiment.py b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/sentiment.py new file mode 100644 index 000000000000..55c1442e35fa --- /dev/null +++ b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/sentiment.py @@ -0,0 +1,34 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Sentiment(Model): + """Sentiment of the input utterance. + + :param label: The polarity of the sentiment, can be positive, neutral or + negative. + :type label: str + :param score: Score of the sentiment, ranges from 0 (most negative) to 1 + (most positive). + :type score: float + """ + + _attribute_map = { + 'label': {'key': 'label', 'type': 'str'}, + 'score': {'key': 'score', 'type': 'float'}, + } + + def __init__(self, **kwargs): + super(Sentiment, self).__init__(**kwargs) + self.label = kwargs.get('label', None) + self.score = kwargs.get('score', None) diff --git a/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/sentiment_py3.py b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/sentiment_py3.py new file mode 100644 index 000000000000..fd92f4706e71 --- /dev/null +++ b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/models/sentiment_py3.py @@ -0,0 +1,34 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Sentiment(Model): + """Sentiment of the input utterance. + + :param label: The polarity of the sentiment, can be positive, neutral or + negative. + :type label: str + :param score: Score of the sentiment, ranges from 0 (most negative) to 1 + (most positive). + :type score: float + """ + + _attribute_map = { + 'label': {'key': 'label', 'type': 'str'}, + 'score': {'key': 'score', 'type': 'float'}, + } + + def __init__(self, *, label: str=None, score: float=None, **kwargs) -> None: + super(Sentiment, self).__init__(**kwargs) + self.label = label + self.score = score diff --git a/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/operations/__init__.py b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/operations/__init__.py new file mode 100644 index 000000000000..5d73b7e5f993 --- /dev/null +++ b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/operations/__init__.py @@ -0,0 +1,16 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .prediction_operations import PredictionOperations + +__all__ = [ + 'PredictionOperations', +] diff --git a/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/operations/prediction_operations.py b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/operations/prediction_operations.py new file mode 100644 index 000000000000..fc742ff05f8c --- /dev/null +++ b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/operations/prediction_operations.py @@ -0,0 +1,121 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class PredictionOperations(object): + """PredictionOperations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + + self.config = config + + def resolve( + self, app_id, query, timezone_offset=None, verbose=None, staging=None, spell_check=None, bing_spell_check_subscription_key=None, log=None, custom_headers=None, raw=False, **operation_config): + """Gets predictions for a given utterance, in the form of intents and + entities. The current maximum query size is 500 characters. + + :param app_id: The LUIS application ID (Guid). + :type app_id: str + :param query: The utterance to predict. + :type query: str + :param timezone_offset: The timezone offset for the location of the + request. + :type timezone_offset: float + :param verbose: If true, return all intents instead of just the top + scoring intent. + :type verbose: bool + :param staging: Use the staging endpoint slot. + :type staging: bool + :param spell_check: Enable spell checking. + :type spell_check: bool + :param bing_spell_check_subscription_key: The subscription key to use + when enabling bing spell check + :type bing_spell_check_subscription_key: str + :param log: Log query (default is true) + :type log: bool + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: LuisResult or ClientRawResponse if raw=true + :rtype: + ~azure.cognitiveservices.language.luis.runtime.models.LuisResult or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`APIErrorException` + """ + # Construct URL + url = self.resolve.metadata['url'] + path_format_arguments = { + 'appId': self._serialize.url("app_id", app_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if timezone_offset is not None: + query_parameters['timezoneOffset'] = self._serialize.query("timezone_offset", timezone_offset, 'float') + if verbose is not None: + query_parameters['verbose'] = self._serialize.query("verbose", verbose, 'bool') + if staging is not None: + query_parameters['staging'] = self._serialize.query("staging", staging, 'bool') + if spell_check is not None: + query_parameters['spellCheck'] = self._serialize.query("spell_check", spell_check, 'bool') + if bing_spell_check_subscription_key is not None: + query_parameters['bing-spell-check-subscription-key'] = self._serialize.query("bing_spell_check_subscription_key", bing_spell_check_subscription_key, 'str') + if log is not None: + query_parameters['log'] = self._serialize.query("log", log, 'bool') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(query, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.APIErrorException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('LuisResult', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + resolve.metadata = {'url': '/apps/{appId}'} diff --git a/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/version.py b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/version.py new file mode 100644 index 000000000000..63f83465c874 --- /dev/null +++ b/azure-cognitiveservices-language-luis/azure/cognitiveservices/language/luis/runtime/version.py @@ -0,0 +1,13 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +VERSION = "2.0" +