diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/__init__.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/__init__.py index 1b5232d238e3..d7ead4eb95b0 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/__init__.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/__init__.py @@ -9,10 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from .qn_amaker_client import QnAMakerClient +from .qn_amaker_runtime_client import QnAMakerRuntimeClient from .version import VERSION -__all__ = ['QnAMakerClient'] +__all__ = ['QnAMakerRuntimeClient'] __version__ = VERSION diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/__init__.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/__init__.py index 3c80f3606bea..eabcdb80fb07 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/__init__.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/__init__.py @@ -10,128 +10,65 @@ # -------------------------------------------------------------------------- try: - from .update_kb_operation_dto_add_py3 import UpdateKbOperationDTOAdd - from .update_kb_operation_dto_delete_py3 import UpdateKbOperationDTODelete - from .update_kb_operation_dto_update_py3 import UpdateKbOperationDTOUpdate - from .update_kb_operation_dto_py3 import UpdateKbOperationDTO - from .update_qna_dto_questions_py3 import UpdateQnaDTOQuestions - from .update_qna_dto_metadata_py3 import UpdateQnaDTOMetadata - from .update_qna_dto_context_py3 import UpdateQnaDTOContext - from .update_qna_dto_py3 import UpdateQnaDTO - from .update_kb_contents_dto_py3 import UpdateKbContentsDTO - from .update_questions_dto_py3 import UpdateQuestionsDTO from .metadata_dto_py3 import MetadataDTO - from .update_metadata_dto_py3 import UpdateMetadataDTO - from .prompt_dto_qna_py3 import PromptDTOQna - from .prompt_dto_py3 import PromptDTO - from .update_context_dto_py3 import UpdateContextDTO - from .delete_kb_contents_dto_py3 import DeleteKbContentsDTO from .qn_adto_context_py3 import QnADTOContext from .qn_adto_py3 import QnADTO - from .file_dto_py3 import FileDTO - from .create_kb_input_dto_py3 import CreateKbInputDTO - from .qn_adocuments_dto_py3 import QnADocumentsDTO - from .create_kb_dto_py3 import CreateKbDTO - from .replace_kb_dto_py3 import ReplaceKbDTO + from .prompt_dto_qna_py3 import PromptDTOQna + from .prompt_dto_py3 import PromptDTO from .context_dto_py3 import ContextDTO from .error_response_error_py3 import ErrorResponseError from .error_response_py3 import ErrorResponse, ErrorResponseException from .inner_error_model_py3 import InnerErrorModel from .error_py3 import Error - from .operation_py3 import Operation - from .knowledgebase_dto_py3 import KnowledgebaseDTO - from .knowledgebases_dto_py3 import KnowledgebasesDTO - from .endpoint_settings_dto_active_learning_py3 import EndpointSettingsDTOActiveLearning - from .endpoint_settings_dto_py3 import EndpointSettingsDTO - from .active_learning_settings_dto_py3 import ActiveLearningSettingsDTO - from .alterations_dto_py3 import AlterationsDTO - from .word_alterations_dto_py3 import WordAlterationsDTO - from .endpoint_keys_dto_py3 import EndpointKeysDTO + from .query_dto_context_py3 import QueryDTOContext + from .query_dto_py3 import QueryDTO + from .query_context_dto_py3 import QueryContextDTO + from .qn_asearch_result_context_py3 import QnASearchResultContext + from .qn_asearch_result_py3 import QnASearchResult + from .qn_asearch_result_list_py3 import QnASearchResultList + from .feedback_record_dto_py3 import FeedbackRecordDTO + from .feedback_records_dto_py3 import FeedbackRecordsDTO except (SyntaxError, ImportError): - from .update_kb_operation_dto_add import UpdateKbOperationDTOAdd - from .update_kb_operation_dto_delete import UpdateKbOperationDTODelete - from .update_kb_operation_dto_update import UpdateKbOperationDTOUpdate - from .update_kb_operation_dto import UpdateKbOperationDTO - from .update_qna_dto_questions import UpdateQnaDTOQuestions - from .update_qna_dto_metadata import UpdateQnaDTOMetadata - from .update_qna_dto_context import UpdateQnaDTOContext - from .update_qna_dto import UpdateQnaDTO - from .update_kb_contents_dto import UpdateKbContentsDTO - from .update_questions_dto import UpdateQuestionsDTO from .metadata_dto import MetadataDTO - from .update_metadata_dto import UpdateMetadataDTO - from .prompt_dto_qna import PromptDTOQna - from .prompt_dto import PromptDTO - from .update_context_dto import UpdateContextDTO - from .delete_kb_contents_dto import DeleteKbContentsDTO from .qn_adto_context import QnADTOContext from .qn_adto import QnADTO - from .file_dto import FileDTO - from .create_kb_input_dto import CreateKbInputDTO - from .qn_adocuments_dto import QnADocumentsDTO - from .create_kb_dto import CreateKbDTO - from .replace_kb_dto import ReplaceKbDTO + from .prompt_dto_qna import PromptDTOQna + from .prompt_dto import PromptDTO from .context_dto import ContextDTO from .error_response_error import ErrorResponseError from .error_response import ErrorResponse, ErrorResponseException from .inner_error_model import InnerErrorModel from .error import Error - from .operation import Operation - from .knowledgebase_dto import KnowledgebaseDTO - from .knowledgebases_dto import KnowledgebasesDTO - from .endpoint_settings_dto_active_learning import EndpointSettingsDTOActiveLearning - from .endpoint_settings_dto import EndpointSettingsDTO - from .active_learning_settings_dto import ActiveLearningSettingsDTO - from .alterations_dto import AlterationsDTO - from .word_alterations_dto import WordAlterationsDTO - from .endpoint_keys_dto import EndpointKeysDTO -from .qn_amaker_client_enums import ( - KnowledgebaseEnvironmentType, + from .query_dto_context import QueryDTOContext + from .query_dto import QueryDTO + from .query_context_dto import QueryContextDTO + from .qn_asearch_result_context import QnASearchResultContext + from .qn_asearch_result import QnASearchResult + from .qn_asearch_result_list import QnASearchResultList + from .feedback_record_dto import FeedbackRecordDTO + from .feedback_records_dto import FeedbackRecordsDTO +from .qn_amaker_runtime_client_enums import ( ErrorCodeType, - OperationStateType, - EnvironmentType, ) __all__ = [ - 'UpdateKbOperationDTOAdd', - 'UpdateKbOperationDTODelete', - 'UpdateKbOperationDTOUpdate', - 'UpdateKbOperationDTO', - 'UpdateQnaDTOQuestions', - 'UpdateQnaDTOMetadata', - 'UpdateQnaDTOContext', - 'UpdateQnaDTO', - 'UpdateKbContentsDTO', - 'UpdateQuestionsDTO', 'MetadataDTO', - 'UpdateMetadataDTO', - 'PromptDTOQna', - 'PromptDTO', - 'UpdateContextDTO', - 'DeleteKbContentsDTO', 'QnADTOContext', 'QnADTO', - 'FileDTO', - 'CreateKbInputDTO', - 'QnADocumentsDTO', - 'CreateKbDTO', - 'ReplaceKbDTO', + 'PromptDTOQna', + 'PromptDTO', 'ContextDTO', 'ErrorResponseError', 'ErrorResponse', 'ErrorResponseException', 'InnerErrorModel', 'Error', - 'Operation', - 'KnowledgebaseDTO', - 'KnowledgebasesDTO', - 'EndpointSettingsDTOActiveLearning', - 'EndpointSettingsDTO', - 'ActiveLearningSettingsDTO', - 'AlterationsDTO', - 'WordAlterationsDTO', - 'EndpointKeysDTO', - 'KnowledgebaseEnvironmentType', + 'QueryDTOContext', + 'QueryDTO', + 'QueryContextDTO', + 'QnASearchResultContext', + 'QnASearchResult', + 'QnASearchResultList', + 'FeedbackRecordDTO', + 'FeedbackRecordsDTO', 'ErrorCodeType', - 'OperationStateType', - 'EnvironmentType', ] diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/feedback_record_dto.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/feedback_record_dto.py new file mode 100644 index 000000000000..ed2a7142a20b --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/feedback_record_dto.py @@ -0,0 +1,41 @@ +# 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 FeedbackRecordDTO(Model): + """Active learning feedback record. + + :param user_id: Unique identifier for the user. + :type user_id: str + :param user_question: The suggested question being provided as feedback. + :type user_question: str + :param qna_id: The qnaId for which the suggested question is provided as + feedback. + :type qna_id: int + """ + + _validation = { + 'user_question': {'max_length': 1000}, + } + + _attribute_map = { + 'user_id': {'key': 'userId', 'type': 'str'}, + 'user_question': {'key': 'userQuestion', 'type': 'str'}, + 'qna_id': {'key': 'qnaId', 'type': 'int'}, + } + + def __init__(self, **kwargs): + super(FeedbackRecordDTO, self).__init__(**kwargs) + self.user_id = kwargs.get('user_id', None) + self.user_question = kwargs.get('user_question', None) + self.qna_id = kwargs.get('qna_id', None) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/feedback_record_dto_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/feedback_record_dto_py3.py new file mode 100644 index 000000000000..7b06ed84a63f --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/feedback_record_dto_py3.py @@ -0,0 +1,41 @@ +# 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 FeedbackRecordDTO(Model): + """Active learning feedback record. + + :param user_id: Unique identifier for the user. + :type user_id: str + :param user_question: The suggested question being provided as feedback. + :type user_question: str + :param qna_id: The qnaId for which the suggested question is provided as + feedback. + :type qna_id: int + """ + + _validation = { + 'user_question': {'max_length': 1000}, + } + + _attribute_map = { + 'user_id': {'key': 'userId', 'type': 'str'}, + 'user_question': {'key': 'userQuestion', 'type': 'str'}, + 'qna_id': {'key': 'qnaId', 'type': 'int'}, + } + + def __init__(self, *, user_id: str=None, user_question: str=None, qna_id: int=None, **kwargs) -> None: + super(FeedbackRecordDTO, self).__init__(**kwargs) + self.user_id = user_id + self.user_question = user_question + self.qna_id = qna_id diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/feedback_records_dto.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/feedback_records_dto.py new file mode 100644 index 000000000000..05b71ff0e084 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/feedback_records_dto.py @@ -0,0 +1,29 @@ +# 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 FeedbackRecordsDTO(Model): + """Active learning feedback records. + + :param feedback_records: List of feedback records. + :type feedback_records: + list[~azure.cognitiveservices.knowledge.qnamaker.models.FeedbackRecordDTO] + """ + + _attribute_map = { + 'feedback_records': {'key': 'feedbackRecords', 'type': '[FeedbackRecordDTO]'}, + } + + def __init__(self, **kwargs): + super(FeedbackRecordsDTO, self).__init__(**kwargs) + self.feedback_records = kwargs.get('feedback_records', None) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/feedback_records_dto_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/feedback_records_dto_py3.py new file mode 100644 index 000000000000..adc98c14d7bc --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/feedback_records_dto_py3.py @@ -0,0 +1,29 @@ +# 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 FeedbackRecordsDTO(Model): + """Active learning feedback records. + + :param feedback_records: List of feedback records. + :type feedback_records: + list[~azure.cognitiveservices.knowledge.qnamaker.models.FeedbackRecordDTO] + """ + + _attribute_map = { + 'feedback_records': {'key': 'feedbackRecords', 'type': '[FeedbackRecordDTO]'}, + } + + def __init__(self, *, feedback_records=None, **kwargs) -> None: + super(FeedbackRecordsDTO, self).__init__(**kwargs) + self.feedback_records = feedback_records diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/qn_amaker_runtime_client_enums.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/qn_amaker_runtime_client_enums.py new file mode 100644 index 000000000000..c523cb290231 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/qn_amaker_runtime_client_enums.py @@ -0,0 +1,30 @@ +# 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 enum import Enum + + +class ErrorCodeType(str, Enum): + + bad_argument = "BadArgument" + forbidden = "Forbidden" + not_found = "NotFound" + kb_not_found = "KbNotFound" + unauthorized = "Unauthorized" + unspecified = "Unspecified" + endpoint_keys_error = "EndpointKeysError" + quota_exceeded = "QuotaExceeded" + qna_runtime_error = "QnaRuntimeError" + sku_limit_exceeded = "SKULimitExceeded" + operation_not_found = "OperationNotFound" + service_error = "ServiceError" + validation_failure = "ValidationFailure" + extraction_failure = "ExtractionFailure" diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/qn_asearch_result.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/qn_asearch_result.py new file mode 100644 index 000000000000..97ecd13cd902 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/qn_asearch_result.py @@ -0,0 +1,54 @@ +# 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 QnASearchResult(Model): + """Represents Search Result. + + :param questions: List of questions. + :type questions: list[str] + :param answer: Answer. + :type answer: str + :param score: Search result score. + :type score: float + :param id: Id of the QnA result. + :type id: int + :param source: Source of QnA result. + :type source: str + :param metadata: List of metadata. + :type metadata: + list[~azure.cognitiveservices.knowledge.qnamaker.models.MetadataDTO] + :param context: Context object of the QnA + :type context: + ~azure.cognitiveservices.knowledge.qnamaker.models.QnASearchResultContext + """ + + _attribute_map = { + 'questions': {'key': 'questions', 'type': '[str]'}, + 'answer': {'key': 'answer', 'type': 'str'}, + 'score': {'key': 'score', 'type': 'float'}, + 'id': {'key': 'id', 'type': 'int'}, + 'source': {'key': 'source', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': '[MetadataDTO]'}, + 'context': {'key': 'context', 'type': 'QnASearchResultContext'}, + } + + def __init__(self, **kwargs): + super(QnASearchResult, self).__init__(**kwargs) + self.questions = kwargs.get('questions', None) + self.answer = kwargs.get('answer', None) + self.score = kwargs.get('score', None) + self.id = kwargs.get('id', None) + self.source = kwargs.get('source', None) + self.metadata = kwargs.get('metadata', None) + self.context = kwargs.get('context', None) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/qn_asearch_result_context.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/qn_asearch_result_context.py new file mode 100644 index 000000000000..a8389973ecb8 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/qn_asearch_result_context.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 .context_dto import ContextDTO + + +class QnASearchResultContext(ContextDTO): + """Context object of the QnA. + + :param is_context_only: To mark if a prompt is relevant only with a + previous question or not. + true - Do not include this QnA as search result for queries without + context + false - ignores context and includes this QnA in search result + :type is_context_only: bool + :param prompts: List of prompts associated with the answer. + :type prompts: + list[~azure.cognitiveservices.knowledge.qnamaker.models.PromptDTO] + """ + + _validation = { + 'prompts': {'max_items': 20}, + } + + _attribute_map = { + 'is_context_only': {'key': 'isContextOnly', 'type': 'bool'}, + 'prompts': {'key': 'prompts', 'type': '[PromptDTO]'}, + } + + def __init__(self, **kwargs): + super(QnASearchResultContext, self).__init__(**kwargs) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/qn_asearch_result_context_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/qn_asearch_result_context_py3.py new file mode 100644 index 000000000000..983fbc6f318a --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/qn_asearch_result_context_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 .context_dto_py3 import ContextDTO + + +class QnASearchResultContext(ContextDTO): + """Context object of the QnA. + + :param is_context_only: To mark if a prompt is relevant only with a + previous question or not. + true - Do not include this QnA as search result for queries without + context + false - ignores context and includes this QnA in search result + :type is_context_only: bool + :param prompts: List of prompts associated with the answer. + :type prompts: + list[~azure.cognitiveservices.knowledge.qnamaker.models.PromptDTO] + """ + + _validation = { + 'prompts': {'max_items': 20}, + } + + _attribute_map = { + 'is_context_only': {'key': 'isContextOnly', 'type': 'bool'}, + 'prompts': {'key': 'prompts', 'type': '[PromptDTO]'}, + } + + def __init__(self, *, is_context_only: bool=None, prompts=None, **kwargs) -> None: + super(QnASearchResultContext, self).__init__(is_context_only=is_context_only, prompts=prompts, **kwargs) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/qn_asearch_result_list.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/qn_asearch_result_list.py new file mode 100644 index 000000000000..35e78006da4f --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/qn_asearch_result_list.py @@ -0,0 +1,29 @@ +# 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 QnASearchResultList(Model): + """Represents List of Question Answers. + + :param answers: Represents Search Result list. + :type answers: + list[~azure.cognitiveservices.knowledge.qnamaker.models.QnASearchResult] + """ + + _attribute_map = { + 'answers': {'key': 'answers', 'type': '[QnASearchResult]'}, + } + + def __init__(self, **kwargs): + super(QnASearchResultList, self).__init__(**kwargs) + self.answers = kwargs.get('answers', None) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/qn_asearch_result_list_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/qn_asearch_result_list_py3.py new file mode 100644 index 000000000000..a15b5c08a8cf --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/qn_asearch_result_list_py3.py @@ -0,0 +1,29 @@ +# 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 QnASearchResultList(Model): + """Represents List of Question Answers. + + :param answers: Represents Search Result list. + :type answers: + list[~azure.cognitiveservices.knowledge.qnamaker.models.QnASearchResult] + """ + + _attribute_map = { + 'answers': {'key': 'answers', 'type': '[QnASearchResult]'}, + } + + def __init__(self, *, answers=None, **kwargs) -> None: + super(QnASearchResultList, self).__init__(**kwargs) + self.answers = answers diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/qn_asearch_result_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/qn_asearch_result_py3.py new file mode 100644 index 000000000000..179ce7417e3f --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/qn_asearch_result_py3.py @@ -0,0 +1,54 @@ +# 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 QnASearchResult(Model): + """Represents Search Result. + + :param questions: List of questions. + :type questions: list[str] + :param answer: Answer. + :type answer: str + :param score: Search result score. + :type score: float + :param id: Id of the QnA result. + :type id: int + :param source: Source of QnA result. + :type source: str + :param metadata: List of metadata. + :type metadata: + list[~azure.cognitiveservices.knowledge.qnamaker.models.MetadataDTO] + :param context: Context object of the QnA + :type context: + ~azure.cognitiveservices.knowledge.qnamaker.models.QnASearchResultContext + """ + + _attribute_map = { + 'questions': {'key': 'questions', 'type': '[str]'}, + 'answer': {'key': 'answer', 'type': 'str'}, + 'score': {'key': 'score', 'type': 'float'}, + 'id': {'key': 'id', 'type': 'int'}, + 'source': {'key': 'source', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': '[MetadataDTO]'}, + 'context': {'key': 'context', 'type': 'QnASearchResultContext'}, + } + + def __init__(self, *, questions=None, answer: str=None, score: float=None, id: int=None, source: str=None, metadata=None, context=None, **kwargs) -> None: + super(QnASearchResult, self).__init__(**kwargs) + self.questions = questions + self.answer = answer + self.score = score + self.id = id + self.source = source + self.metadata = metadata + self.context = context diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/query_context_dto.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/query_context_dto.py new file mode 100644 index 000000000000..5a96679211d0 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/query_context_dto.py @@ -0,0 +1,32 @@ +# 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 QueryContextDTO(Model): + """Context object with previous QnA's information. + + :param previous_qna_id: Previous QnA Id - qnaId of the top result. + :type previous_qna_id: str + :param previous_user_query: Previous user query. + :type previous_user_query: str + """ + + _attribute_map = { + 'previous_qna_id': {'key': 'previousQnaId', 'type': 'str'}, + 'previous_user_query': {'key': 'previousUserQuery', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(QueryContextDTO, self).__init__(**kwargs) + self.previous_qna_id = kwargs.get('previous_qna_id', None) + self.previous_user_query = kwargs.get('previous_user_query', None) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/query_context_dto_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/query_context_dto_py3.py new file mode 100644 index 000000000000..fe3b7c9b258b --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/query_context_dto_py3.py @@ -0,0 +1,32 @@ +# 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 QueryContextDTO(Model): + """Context object with previous QnA's information. + + :param previous_qna_id: Previous QnA Id - qnaId of the top result. + :type previous_qna_id: str + :param previous_user_query: Previous user query. + :type previous_user_query: str + """ + + _attribute_map = { + 'previous_qna_id': {'key': 'previousQnaId', 'type': 'str'}, + 'previous_user_query': {'key': 'previousUserQuery', 'type': 'str'}, + } + + def __init__(self, *, previous_qna_id: str=None, previous_user_query: str=None, **kwargs) -> None: + super(QueryContextDTO, self).__init__(**kwargs) + self.previous_qna_id = previous_qna_id + self.previous_user_query = previous_user_query diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/query_dto.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/query_dto.py new file mode 100644 index 000000000000..06341b405587 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/query_dto.py @@ -0,0 +1,59 @@ +# 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 QueryDTO(Model): + """POST body schema to query the knowledgebase. + + :param qna_id: Exact qnaId to fetch from the knowledgebase, this field + takes priority over question. + :type qna_id: str + :param question: User question to query against the knowledge base. + :type question: str + :param top: Max number of answers to be returned for the question. + :type top: int + :param user_id: Unique identifier for the user. + :type user_id: str + :param is_test: Query against the test index. + :type is_test: bool + :param score_threshold: Threshold for answers returned based on score. + :type score_threshold: float + :param context: Context object with previous QnA's information. + :type context: + ~azure.cognitiveservices.knowledge.qnamaker.models.QueryDTOContext + :param strict_filters: Find only answers that contain these metadata. + :type strict_filters: + list[~azure.cognitiveservices.knowledge.qnamaker.models.MetadataDTO] + """ + + _attribute_map = { + 'qna_id': {'key': 'qnaId', 'type': 'str'}, + 'question': {'key': 'question', 'type': 'str'}, + 'top': {'key': 'top', 'type': 'int'}, + 'user_id': {'key': 'userId', 'type': 'str'}, + 'is_test': {'key': 'isTest', 'type': 'bool'}, + 'score_threshold': {'key': 'scoreThreshold', 'type': 'float'}, + 'context': {'key': 'context', 'type': 'QueryDTOContext'}, + 'strict_filters': {'key': 'strictFilters', 'type': '[MetadataDTO]'}, + } + + def __init__(self, **kwargs): + super(QueryDTO, self).__init__(**kwargs) + self.qna_id = kwargs.get('qna_id', None) + self.question = kwargs.get('question', None) + self.top = kwargs.get('top', None) + self.user_id = kwargs.get('user_id', None) + self.is_test = kwargs.get('is_test', None) + self.score_threshold = kwargs.get('score_threshold', None) + self.context = kwargs.get('context', None) + self.strict_filters = kwargs.get('strict_filters', None) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/query_dto_context.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/query_dto_context.py new file mode 100644 index 000000000000..3886ef6aab75 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/query_dto_context.py @@ -0,0 +1,30 @@ +# 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 .query_context_dto import QueryContextDTO + + +class QueryDTOContext(QueryContextDTO): + """Context object with previous QnA's information. + + :param previous_qna_id: Previous QnA Id - qnaId of the top result. + :type previous_qna_id: str + :param previous_user_query: Previous user query. + :type previous_user_query: str + """ + + _attribute_map = { + 'previous_qna_id': {'key': 'previousQnaId', 'type': 'str'}, + 'previous_user_query': {'key': 'previousUserQuery', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(QueryDTOContext, self).__init__(**kwargs) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/query_dto_context_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/query_dto_context_py3.py new file mode 100644 index 000000000000..82ce5244d40d --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/query_dto_context_py3.py @@ -0,0 +1,30 @@ +# 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 .query_context_dto_py3 import QueryContextDTO + + +class QueryDTOContext(QueryContextDTO): + """Context object with previous QnA's information. + + :param previous_qna_id: Previous QnA Id - qnaId of the top result. + :type previous_qna_id: str + :param previous_user_query: Previous user query. + :type previous_user_query: str + """ + + _attribute_map = { + 'previous_qna_id': {'key': 'previousQnaId', 'type': 'str'}, + 'previous_user_query': {'key': 'previousUserQuery', 'type': 'str'}, + } + + def __init__(self, *, previous_qna_id: str=None, previous_user_query: str=None, **kwargs) -> None: + super(QueryDTOContext, self).__init__(previous_qna_id=previous_qna_id, previous_user_query=previous_user_query, **kwargs) diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/query_dto_py3.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/query_dto_py3.py new file mode 100644 index 000000000000..75d7ae478135 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/models/query_dto_py3.py @@ -0,0 +1,59 @@ +# 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 QueryDTO(Model): + """POST body schema to query the knowledgebase. + + :param qna_id: Exact qnaId to fetch from the knowledgebase, this field + takes priority over question. + :type qna_id: str + :param question: User question to query against the knowledge base. + :type question: str + :param top: Max number of answers to be returned for the question. + :type top: int + :param user_id: Unique identifier for the user. + :type user_id: str + :param is_test: Query against the test index. + :type is_test: bool + :param score_threshold: Threshold for answers returned based on score. + :type score_threshold: float + :param context: Context object with previous QnA's information. + :type context: + ~azure.cognitiveservices.knowledge.qnamaker.models.QueryDTOContext + :param strict_filters: Find only answers that contain these metadata. + :type strict_filters: + list[~azure.cognitiveservices.knowledge.qnamaker.models.MetadataDTO] + """ + + _attribute_map = { + 'qna_id': {'key': 'qnaId', 'type': 'str'}, + 'question': {'key': 'question', 'type': 'str'}, + 'top': {'key': 'top', 'type': 'int'}, + 'user_id': {'key': 'userId', 'type': 'str'}, + 'is_test': {'key': 'isTest', 'type': 'bool'}, + 'score_threshold': {'key': 'scoreThreshold', 'type': 'float'}, + 'context': {'key': 'context', 'type': 'QueryDTOContext'}, + 'strict_filters': {'key': 'strictFilters', 'type': '[MetadataDTO]'}, + } + + def __init__(self, *, qna_id: str=None, question: str=None, top: int=None, user_id: str=None, is_test: bool=None, score_threshold: float=None, context=None, strict_filters=None, **kwargs) -> None: + super(QueryDTO, self).__init__(**kwargs) + self.qna_id = qna_id + self.question = question + self.top = top + self.user_id = user_id + self.is_test = is_test + self.score_threshold = score_threshold + self.context = context + self.strict_filters = strict_filters diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/operations/__init__.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/operations/__init__.py index e89d051424b1..cf82a2663407 100644 --- a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/operations/__init__.py +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/operations/__init__.py @@ -9,16 +9,8 @@ # regenerated. # -------------------------------------------------------------------------- -from .endpoint_settings_operations import EndpointSettingsOperations -from .endpoint_keys_operations import EndpointKeysOperations -from .alterations_operations import AlterationsOperations -from .knowledgebase_operations import KnowledgebaseOperations -from .operations import Operations +from .runtime_operations import RuntimeOperations __all__ = [ - 'EndpointSettingsOperations', - 'EndpointKeysOperations', - 'AlterationsOperations', - 'KnowledgebaseOperations', - 'Operations', + 'RuntimeOperations', ] diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/operations/runtime_operations.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/operations/runtime_operations.py new file mode 100644 index 000000000000..9b0440077838 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/operations/runtime_operations.py @@ -0,0 +1,148 @@ +# 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 RuntimeOperations(object): + """RuntimeOperations 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 generate_answer( + self, kb_id, generate_answer_payload, custom_headers=None, raw=False, **operation_config): + """GenerateAnswer call to query the knowledgebase. + + :param kb_id: Knowledgebase id. + :type kb_id: str + :param generate_answer_payload: Post body of the request. + :type generate_answer_payload: + ~azure.cognitiveservices.knowledge.qnamaker.models.QueryDTO + :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: QnASearchResultList or ClientRawResponse if raw=true + :rtype: + ~azure.cognitiveservices.knowledge.qnamaker.models.QnASearchResultList + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.generate_answer.metadata['url'] + path_format_arguments = { + 'RuntimeEndpoint': self._serialize.url("self.config.runtime_endpoint", self.config.runtime_endpoint, 'str', skip_quote=True), + 'kbId': self._serialize.url("kb_id", kb_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # 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(generate_answer_payload, 'QueryDTO') + + # 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.ErrorResponseException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('QnASearchResultList', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + generate_answer.metadata = {'url': '/knowledgebases/{kbId}/generateAnswer'} + + def train( + self, kb_id, feedback_records=None, custom_headers=None, raw=False, **operation_config): + """Train call to add suggestions to the knowledgebase. + + :param kb_id: Knowledgebase id. + :type kb_id: str + :param feedback_records: List of feedback records. + :type feedback_records: + list[~azure.cognitiveservices.knowledge.qnamaker.models.FeedbackRecordDTO] + :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: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + train_payload = models.FeedbackRecordsDTO(feedback_records=feedback_records) + + # Construct URL + url = self.train.metadata['url'] + path_format_arguments = { + 'RuntimeEndpoint': self._serialize.url("self.config.runtime_endpoint", self.config.runtime_endpoint, 'str', skip_quote=True), + 'kbId': self._serialize.url("kb_id", kb_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if custom_headers: + header_parameters.update(custom_headers) + + # Construct body + body_content = self._serialize.body(train_payload, 'FeedbackRecordsDTO') + + # 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 [204]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + train.metadata = {'url': '/knowledgebases/{kbId}/train'} diff --git a/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/qn_amaker_runtime_client.py b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/qn_amaker_runtime_client.py new file mode 100644 index 000000000000..649044d4bf55 --- /dev/null +++ b/sdk/cognitiveservices/azure-cognitiveservices-knowledge-qnamaker/azure/cognitiveservices/knowledge/qnamaker/qn_amaker_runtime_client.py @@ -0,0 +1,78 @@ +# 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.runtime_operations import RuntimeOperations +from . import models + + +class QnAMakerRuntimeClientConfiguration(Configuration): + """Configuration for QnAMakerRuntimeClient + Note that all parameters used to create this instance are saved as instance + attributes. + + :param runtime_endpoint: QnA Maker App Service endpoint (for example: + https://{qnaservice-hostname}.azurewebsites.net). + :type runtime_endpoint: str + :param credentials: Subscription credentials which uniquely identify + client subscription. + :type credentials: None + """ + + def __init__( + self, runtime_endpoint, credentials): + + if runtime_endpoint is None: + raise ValueError("Parameter 'runtime_endpoint' must not be None.") + if credentials is None: + raise ValueError("Parameter 'credentials' must not be None.") + base_url = '{RuntimeEndpoint}/qnamaker' + + super(QnAMakerRuntimeClientConfiguration, self).__init__(base_url) + + self.add_user_agent('azure-cognitiveservices-knowledge-qnamaker/{}'.format(VERSION)) + + self.runtime_endpoint = runtime_endpoint + self.credentials = credentials + + +class QnAMakerRuntimeClient(SDKClient): + """An API for QnAMaker runtime + + :ivar config: Configuration for client. + :vartype config: QnAMakerRuntimeClientConfiguration + + :ivar runtime: Runtime operations + :vartype runtime: azure.cognitiveservices.knowledge.qnamaker.operations.RuntimeOperations + + :param runtime_endpoint: QnA Maker App Service endpoint (for example: + https://{qnaservice-hostname}.azurewebsites.net). + :type runtime_endpoint: str + :param credentials: Subscription credentials which uniquely identify + client subscription. + :type credentials: None + """ + + def __init__( + self, runtime_endpoint, credentials): + + self.config = QnAMakerRuntimeClientConfiguration(runtime_endpoint, credentials) + super(QnAMakerRuntimeClient, 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 = '4.0' + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.runtime = RuntimeOperations( + self._client, self.config, self._serialize, self._deserialize)