From 5a31f59cf1d35b6a076e2f9ce37523d8ffe432aa Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Wed, 29 Sep 2021 14:26:14 -0400 Subject: [PATCH 01/20] regenerate --- .../aio/operations/_operations.py | 35 +- .../questionanswering/models/__init__.py | 13 +- .../questionanswering/models/_models.py | 512 ++++++++++++----- .../questionanswering/models/_models_py3.py | 520 ++++++++++++------ .../_question_answering_client_enums.py | 14 +- .../operations/_operations.py | 31 +- 6 files changed, 768 insertions(+), 357 deletions(-) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py index 6775164a54ba..3efce7a78e61 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py @@ -35,7 +35,7 @@ async def query_knowledge_base( knowledge_base_query_options: "_models.KnowledgeBaseQueryOptions", *, project_name: str, - deployment_name: Optional[str] = None, + deployment_name: str, **kwargs: Any ) -> "_models.KnowledgeBaseAnswers": """Answers the specified question using your knowledge base. @@ -47,8 +47,7 @@ async def query_knowledge_base( :paramtype project_name: str :keyword deployment_name: The name of the specific deployment of the project to use. :paramtype deployment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: KnowledgeBaseAnswers, or the result of cls(response) + :return: KnowledgeBaseAnswers :rtype: ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswers :raises: ~azure.core.exceptions.HttpResponseError """ @@ -59,7 +58,7 @@ async def query_knowledge_base( self, *, project_name: str, - deployment_name: Optional[str] = None, + deployment_name: str, qna_id: Optional[int] = None, question: Optional[str] = None, top: Optional[int] = None, @@ -101,8 +100,6 @@ async def query_knowledge_base( :paramtype answer_span_request: ~azure.ai.language.questionanswering.models.AnswerSpanRequest :keyword include_unstructured_sources: (Optional) Flag to enable Query over Unstructured Sources. :paramtype include_unstructured_sources: bool - :keyword callable cls: A custom type or function that will be passed the direct response - :return: KnowledgeBaseAnswers, or the result of cls(response) :rtype: ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswers :raises: ~azure.core.exceptions.HttpResponseError """ @@ -145,8 +142,7 @@ async def query_knowledge_base( :paramtype answer_span_request: ~azure.ai.language.questionanswering.models.AnswerSpanRequest :keyword include_unstructured_sources: (Optional) Flag to enable Query over Unstructured Sources. :paramtype include_unstructured_sources: bool - :keyword callable cls: A custom type or function that will be passed the direct response - :return: KnowledgeBaseAnswers, or the result of cls(response) + :return: KnowledgeBaseAnswers :rtype: ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswers :raises: ~azure.core.exceptions.HttpResponseError """ @@ -170,7 +166,7 @@ async def query_knowledge_base( error_map.update(kwargs.pop("error_map", {})) content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] project_name = kwargs.pop("project_name") # type: str - deployment_name = kwargs.pop("deployment_name", None) # type: Optional[str] + deployment_name = kwargs.pop("deployment_name") # type: str json = self._serialize.body(knowledge_base_query_options, "KnowledgeBaseQueryOptions") @@ -186,9 +182,7 @@ async def query_knowledge_base( } request.url = self._client.format_url(request.url, **path_format_arguments) - pipeline_response = await self._client.send_request( - request, stream=False, _return_pipeline_response=True, **kwargs - ) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -206,15 +200,12 @@ async def query_knowledge_base( query_knowledge_base.metadata = {"url": "/:query-knowledgebases"} # type: ignore @overload - async def query_text( - self, text_query_options: "_models.TextQueryOptions", **kwargs: Any - ) -> "_models.TextAnswers": + async def query_text(self, text_query_options: "_models.TextQueryOptions", **kwargs: Any) -> "_models.TextAnswers": """Answers the specified question using the provided text in the body. :param text_query_options: Post body of the request. :type text_query_options: ~azure.ai.language.questionanswering.models.TextQueryOptions - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TextAnswers, or the result of cls(response) + :return: TextAnswers :rtype: ~azure.ai.language.questionanswering.models.TextAnswers :raises: ~azure.core.exceptions.HttpResponseError """ @@ -245,8 +236,7 @@ async def query_text( https://aka.ms/text-analytics-offsets. Possible values include: "TextElements_v8", "UnicodeCodePoint", "Utf16CodeUnit". Default value: "TextElements_v8". :paramtype string_index_type: str or ~azure.ai.language.questionanswering.models.StringIndexType - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TextAnswers, or the result of cls(response) + :return: TextAnswers :rtype: ~azure.ai.language.questionanswering.models.TextAnswers :raises: ~azure.core.exceptions.HttpResponseError """ @@ -274,8 +264,7 @@ async def query_text( https://aka.ms/text-analytics-offsets. Possible values include: "TextElements_v8", "UnicodeCodePoint", "Utf16CodeUnit". Default value: "TextElements_v8". :paramtype string_index_type: str or ~azure.ai.language.questionanswering.models.StringIndexType - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TextAnswers, or the result of cls(response) + :return: TextAnswers :rtype: ~azure.ai.language.questionanswering.models.TextAnswers :raises: ~azure.core.exceptions.HttpResponseError """ @@ -310,9 +299,7 @@ async def query_text( } request.url = self._client.format_url(request.url, **path_format_arguments) - pipeline_response = await self._client.send_request( - request, stream=False, _return_pipeline_response=True, **kwargs - ) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/__init__.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/__init__.py index 55d25e6fff0c..f6b186f02536 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/__init__.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/__init__.py @@ -19,7 +19,8 @@ from ._models_py3 import KnowledgeBaseAnswers from ._models_py3 import KnowledgeBaseQueryOptions from ._models_py3 import MetadataFilter - from ._models_py3 import StrictFilters + from ._models_py3 import MetadataRecord + from ._models_py3 import QueryFilters from ._models_py3 import TextAnswer from ._models_py3 import TextAnswers from ._models_py3 import TextQueryOptions @@ -37,16 +38,17 @@ from ._models import KnowledgeBaseAnswers # type: ignore from ._models import KnowledgeBaseQueryOptions # type: ignore from ._models import MetadataFilter # type: ignore - from ._models import StrictFilters # type: ignore + from ._models import MetadataRecord # type: ignore + from ._models import QueryFilters # type: ignore from ._models import TextAnswer # type: ignore from ._models import TextAnswers # type: ignore from ._models import TextQueryOptions # type: ignore from ._models import TextRecord # type: ignore from ._question_answering_client_enums import ( - CompoundOperationKind, ErrorCode, InnerErrorCode, + LogicalOperationKind, RankerType, StringIndexType, ) @@ -64,14 +66,15 @@ "KnowledgeBaseAnswers", "KnowledgeBaseQueryOptions", "MetadataFilter", - "StrictFilters", + "MetadataRecord", + "QueryFilters", "TextAnswer", "TextAnswers", "TextQueryOptions", "TextRecord", - "CompoundOperationKind", "ErrorCode", "InnerErrorCode", + "LogicalOperationKind", "RankerType", "StringIndexType", ] diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models.py index e16ad163e9fe..2ca14b4f2b6c 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models.py @@ -13,14 +13,14 @@ class AnswerSpan(msrest.serialization.Model): """Answer span object of QnA. - :keyword text: Predicted text of answer span. - :paramtype text: str - :keyword confidence_score: Predicted score of answer span, value ranges from 0 to 1. - :paramtype confidence_score: float - :keyword offset: The answer span offset from the start of answer. - :paramtype offset: int - :keyword length: The length of the answer span. - :paramtype length: int + :ivar text: Predicted text of answer span. + :vartype text: str + :ivar confidence_score: Predicted score of answer span, value ranges from 0 to 1. + :vartype confidence_score: float + :ivar offset: The answer span offset from the start of answer. + :vartype offset: int + :ivar length: The length of the answer span. + :vartype length: int """ _validation = { @@ -35,6 +35,16 @@ class AnswerSpan(msrest.serialization.Model): } def __init__(self, **kwargs): + """ + :keyword text: Predicted text of answer span. + :paramtype text: str + :keyword confidence_score: Predicted score of answer span, value ranges from 0 to 1. + :paramtype confidence_score: float + :keyword offset: The answer span offset from the start of answer. + :paramtype offset: int + :keyword length: The length of the answer span. + :paramtype length: int + """ super(AnswerSpan, self).__init__(**kwargs) self.text = kwargs.get("text", None) self.confidence_score = kwargs.get("confidence_score", None) @@ -45,14 +55,14 @@ def __init__(self, **kwargs): class AnswerSpanRequest(msrest.serialization.Model): """To configure Answer span prediction feature. - :keyword enable: Enable or disable Answer Span prediction. - :paramtype enable: bool - :keyword confidence_score_threshold: Minimum threshold score required to include an answer - span, value ranges from 0 to 1. - :paramtype confidence_score_threshold: float - :keyword top_answers_with_span: Number of Top answers to be considered for span prediction from - 1 to 10. - :paramtype top_answers_with_span: int + :ivar enable: Enable or disable Answer Span prediction. + :vartype enable: bool + :ivar confidence_score_threshold: Minimum threshold score required to include an answer span, + value ranges from 0 to 1. + :vartype confidence_score_threshold: float + :ivar top_answers_with_span: Number of Top answers to be considered for span prediction from 1 + to 10. + :vartype top_answers_with_span: int """ _validation = { @@ -67,6 +77,16 @@ class AnswerSpanRequest(msrest.serialization.Model): } def __init__(self, **kwargs): + """ + :keyword enable: Enable or disable Answer Span prediction. + :paramtype enable: bool + :keyword confidence_score_threshold: Minimum threshold score required to include an answer + span, value ranges from 0 to 1. + :paramtype confidence_score_threshold: float + :keyword top_answers_with_span: Number of Top answers to be considered for span prediction from + 1 to 10. + :paramtype top_answers_with_span: int + """ super(AnswerSpanRequest, self).__init__(**kwargs) self.enable = kwargs.get("enable", None) self.confidence_score_threshold = kwargs.get("confidence_score_threshold", None) @@ -78,19 +98,19 @@ class Error(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :keyword code: Required. One of a server-defined set of error codes. Possible values include: + :ivar code: Required. One of a server-defined set of error codes. Possible values include: "InvalidRequest", "InvalidArgument", "Unauthorized", "Forbidden", "NotFound", "TooManyRequests", "InternalServerError", "ServiceUnavailable". - :paramtype code: str or ~azure.ai.language.questionanswering.models.ErrorCode - :keyword message: Required. A human-readable representation of the error. - :paramtype message: str - :keyword target: The target of the error. - :paramtype target: str - :keyword details: An array of details about specific errors that led to this reported error. - :paramtype details: list[~azure.ai.language.questionanswering.models.Error] - :keyword innererror: An object containing more specific information than the current object - about the error. - :paramtype innererror: ~azure.ai.language.questionanswering.models.InnerErrorModel + :vartype code: str or ~azure.ai.language.questionanswering.models.ErrorCode + :ivar message: Required. A human-readable representation of the error. + :vartype message: str + :ivar target: The target of the error. + :vartype target: str + :ivar details: An array of details about specific errors that led to this reported error. + :vartype details: list[~azure.ai.language.questionanswering.models.Error] + :ivar innererror: An object containing more specific information than the current object about + the error. + :vartype innererror: ~azure.ai.language.questionanswering.models.InnerErrorModel """ _validation = { @@ -107,6 +127,21 @@ class Error(msrest.serialization.Model): } def __init__(self, **kwargs): + """ + :keyword code: Required. One of a server-defined set of error codes. Possible values include: + "InvalidRequest", "InvalidArgument", "Unauthorized", "Forbidden", "NotFound", + "TooManyRequests", "InternalServerError", "ServiceUnavailable". + :paramtype code: str or ~azure.ai.language.questionanswering.models.ErrorCode + :keyword message: Required. A human-readable representation of the error. + :paramtype message: str + :keyword target: The target of the error. + :paramtype target: str + :keyword details: An array of details about specific errors that led to this reported error. + :paramtype details: list[~azure.ai.language.questionanswering.models.Error] + :keyword innererror: An object containing more specific information than the current object + about the error. + :paramtype innererror: ~azure.ai.language.questionanswering.models.InnerErrorModel + """ super(Error, self).__init__(**kwargs) self.code = kwargs["code"] self.message = kwargs["message"] @@ -118,8 +153,8 @@ def __init__(self, **kwargs): class ErrorResponse(msrest.serialization.Model): """Error response. - :keyword error: The error object. - :paramtype error: ~azure.ai.language.questionanswering.models.Error + :ivar error: The error object. + :vartype error: ~azure.ai.language.questionanswering.models.Error """ _attribute_map = { @@ -127,6 +162,10 @@ class ErrorResponse(msrest.serialization.Model): } def __init__(self, **kwargs): + """ + :keyword error: The error object. + :paramtype error: ~azure.ai.language.questionanswering.models.Error + """ super(ErrorResponse, self).__init__(**kwargs) self.error = kwargs.get("error", None) @@ -136,19 +175,19 @@ class InnerErrorModel(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :keyword code: Required. One of a server-defined set of error codes. Possible values include: + :ivar code: Required. One of a server-defined set of error codes. Possible values include: "InvalidRequest", "InvalidParameterValue", "KnowledgeBaseNotFound", "AzureCognitiveSearchNotFound", "AzureCognitiveSearchThrottling", "ExtractionFailure". - :paramtype code: str or ~azure.ai.language.questionanswering.models.InnerErrorCode - :keyword message: Required. Error message. - :paramtype message: str - :keyword details: Error details. - :paramtype details: dict[str, str] - :keyword target: Error target. - :paramtype target: str - :keyword innererror: An object containing more specific information than the current object - about the error. - :paramtype innererror: ~azure.ai.language.questionanswering.models.InnerErrorModel + :vartype code: str or ~azure.ai.language.questionanswering.models.InnerErrorCode + :ivar message: Required. Error message. + :vartype message: str + :ivar details: Error details. + :vartype details: dict[str, str] + :ivar target: Error target. + :vartype target: str + :ivar innererror: An object containing more specific information than the current object about + the error. + :vartype innererror: ~azure.ai.language.questionanswering.models.InnerErrorModel """ _validation = { @@ -165,6 +204,21 @@ class InnerErrorModel(msrest.serialization.Model): } def __init__(self, **kwargs): + """ + :keyword code: Required. One of a server-defined set of error codes. Possible values include: + "InvalidRequest", "InvalidParameterValue", "KnowledgeBaseNotFound", + "AzureCognitiveSearchNotFound", "AzureCognitiveSearchThrottling", "ExtractionFailure". + :paramtype code: str or ~azure.ai.language.questionanswering.models.InnerErrorCode + :keyword message: Required. Error message. + :paramtype message: str + :keyword details: Error details. + :paramtype details: dict[str, str] + :keyword target: Error target. + :paramtype target: str + :keyword innererror: An object containing more specific information than the current object + about the error. + :paramtype innererror: ~azure.ai.language.questionanswering.models.InnerErrorModel + """ super(InnerErrorModel, self).__init__(**kwargs) self.code = kwargs["code"] self.message = kwargs["message"] @@ -176,23 +230,23 @@ def __init__(self, **kwargs): class KnowledgeBaseAnswer(msrest.serialization.Model): """Represents knowledge base answer. - :keyword questions: List of questions. - :paramtype questions: list[str] - :keyword answer: The Answer. - :paramtype answer: str - :keyword confidence_score: Answer confidence score, value ranges from 0 to 1. - :paramtype confidence_score: float - :keyword id: ID of the QnA result. - :paramtype id: int - :keyword source: Source of QnA result. - :paramtype source: str - :keyword metadata: Metadata associated with the answer, useful to categorize or filter question + :ivar questions: List of questions. + :vartype questions: list[str] + :ivar answer: The Answer. + :vartype answer: str + :ivar confidence_score: Answer confidence score, value ranges from 0 to 1. + :vartype confidence_score: float + :ivar id: ID of the QnA result. + :vartype id: int + :ivar source: Source of QnA result. + :vartype source: str + :ivar metadata: Metadata associated with the answer, useful to categorize or filter question answers. - :paramtype metadata: dict[str, str] - :keyword dialog: Dialog associated with Answer. - :paramtype dialog: ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswerDialog - :keyword answer_span: Answer span object of QnA with respect to user's question. - :paramtype answer_span: ~azure.ai.language.questionanswering.models.AnswerSpan + :vartype metadata: dict[str, str] + :ivar dialog: Dialog associated with Answer. + :vartype dialog: ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswerDialog + :ivar answer_span: Answer span object of QnA with respect to user's question. + :vartype answer_span: ~azure.ai.language.questionanswering.models.AnswerSpan """ _validation = { @@ -211,6 +265,25 @@ class KnowledgeBaseAnswer(msrest.serialization.Model): } def __init__(self, **kwargs): + """ + :keyword questions: List of questions. + :paramtype questions: list[str] + :keyword answer: The Answer. + :paramtype answer: str + :keyword confidence_score: Answer confidence score, value ranges from 0 to 1. + :paramtype confidence_score: float + :keyword id: ID of the QnA result. + :paramtype id: int + :keyword source: Source of QnA result. + :paramtype source: str + :keyword metadata: Metadata associated with the answer, useful to categorize or filter question + answers. + :paramtype metadata: dict[str, str] + :keyword dialog: Dialog associated with Answer. + :paramtype dialog: ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswerDialog + :keyword answer_span: Answer span object of QnA with respect to user's question. + :paramtype answer_span: ~azure.ai.language.questionanswering.models.AnswerSpan + """ super(KnowledgeBaseAnswer, self).__init__(**kwargs) self.questions = kwargs.get("questions", None) self.answer = kwargs.get("answer", None) @@ -225,12 +298,12 @@ def __init__(self, **kwargs): class KnowledgeBaseAnswerDialog(msrest.serialization.Model): """Dialog associated with Answer. - :keyword is_context_only: To mark if a prompt is relevant only with a previous question or not. - If true, do not include this QnA as search result for queries without context; otherwise, if + :ivar is_context_only: To mark if a prompt is relevant only with a previous question or not. If + true, do not include this QnA as search result for queries without context; otherwise, if false, ignores context and includes this QnA in search result. - :paramtype is_context_only: bool - :keyword prompts: List of 0 to 20 prompts associated with the answer. - :paramtype prompts: list[~azure.ai.language.questionanswering.models.KnowledgeBaseAnswerPrompt] + :vartype is_context_only: bool + :ivar prompts: List of 0 to 20 prompts associated with the answer. + :vartype prompts: list[~azure.ai.language.questionanswering.models.KnowledgeBaseAnswerPrompt] """ _validation = { @@ -243,6 +316,14 @@ class KnowledgeBaseAnswerDialog(msrest.serialization.Model): } def __init__(self, **kwargs): + """ + :keyword is_context_only: To mark if a prompt is relevant only with a previous question or not. + If true, do not include this QnA as search result for queries without context; otherwise, if + false, ignores context and includes this QnA in search result. + :paramtype is_context_only: bool + :keyword prompts: List of 0 to 20 prompts associated with the answer. + :paramtype prompts: list[~azure.ai.language.questionanswering.models.KnowledgeBaseAnswerPrompt] + """ super(KnowledgeBaseAnswerDialog, self).__init__(**kwargs) self.is_context_only = kwargs.get("is_context_only", None) self.prompts = kwargs.get("prompts", None) @@ -251,12 +332,12 @@ def __init__(self, **kwargs): class KnowledgeBaseAnswerPrompt(msrest.serialization.Model): """Prompt for an answer. - :keyword display_order: Index of the prompt - used in ordering of the prompts. - :paramtype display_order: int - :keyword qna_id: QnA ID corresponding to the prompt. - :paramtype qna_id: int - :keyword display_text: Text displayed to represent a follow up question prompt. - :paramtype display_text: str + :ivar display_order: Index of the prompt - used in ordering of the prompts. + :vartype display_order: int + :ivar qna_id: QnA ID corresponding to the prompt. + :vartype qna_id: int + :ivar display_text: Text displayed to represent a follow up question prompt. + :vartype display_text: str """ _validation = { @@ -270,6 +351,14 @@ class KnowledgeBaseAnswerPrompt(msrest.serialization.Model): } def __init__(self, **kwargs): + """ + :keyword display_order: Index of the prompt - used in ordering of the prompts. + :paramtype display_order: int + :keyword qna_id: QnA ID corresponding to the prompt. + :paramtype qna_id: int + :keyword display_text: Text displayed to represent a follow up question prompt. + :paramtype display_text: str + """ super(KnowledgeBaseAnswerPrompt, self).__init__(**kwargs) self.display_order = kwargs.get("display_order", None) self.qna_id = kwargs.get("qna_id", None) @@ -281,10 +370,10 @@ class KnowledgeBaseAnswerRequestContext(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :keyword previous_qna_id: Required. Previous turn top answer result QnA ID. - :paramtype previous_qna_id: int - :keyword previous_user_query: Previous user query. - :paramtype previous_user_query: str + :ivar previous_qna_id: Required. Previous turn top answer result QnA ID. + :vartype previous_qna_id: int + :ivar previous_user_query: Previous user query. + :vartype previous_user_query: str """ _validation = { @@ -297,6 +386,12 @@ class KnowledgeBaseAnswerRequestContext(msrest.serialization.Model): } def __init__(self, **kwargs): + """ + :keyword previous_qna_id: Required. Previous turn top answer result QnA ID. + :paramtype previous_qna_id: int + :keyword previous_user_query: Previous user query. + :paramtype previous_user_query: str + """ super(KnowledgeBaseAnswerRequestContext, self).__init__(**kwargs) self.previous_qna_id = kwargs["previous_qna_id"] self.previous_user_query = kwargs.get("previous_user_query", None) @@ -305,8 +400,8 @@ def __init__(self, **kwargs): class KnowledgeBaseAnswers(msrest.serialization.Model): """Represents List of Question Answers. - :keyword answers: Represents Answer Result list. - :paramtype answers: list[~azure.ai.language.questionanswering.models.KnowledgeBaseAnswer] + :ivar answers: Represents Answer Result list. + :vartype answers: list[~azure.ai.language.questionanswering.models.KnowledgeBaseAnswer] """ _attribute_map = { @@ -314,6 +409,10 @@ class KnowledgeBaseAnswers(msrest.serialization.Model): } def __init__(self, **kwargs): + """ + :keyword answers: Represents Answer Result list. + :paramtype answers: list[~azure.ai.language.questionanswering.models.KnowledgeBaseAnswer] + """ super(KnowledgeBaseAnswers, self).__init__(**kwargs) self.answers = kwargs.get("answers", None) @@ -321,32 +420,29 @@ def __init__(self, **kwargs): class KnowledgeBaseQueryOptions(msrest.serialization.Model): """The question parameters to answer using a knowledge base. - :keyword qna_id: Exact QnA ID to fetch from the knowledge base, this field takes priority over + :ivar qna_id: Exact QnA ID to fetch from the knowledge base, this field takes priority over question. - :paramtype qna_id: int - :keyword question: User question to query against the knowledge base. - :paramtype question: str - :keyword top: Max number of answers to be returned for the question. - :paramtype top: int - :keyword user_id: Unique identifier for the user. - :paramtype user_id: str - :keyword confidence_score_threshold: Minimum threshold score for answers, value ranges from 0 - to 1. - :paramtype confidence_score_threshold: float - :keyword context: Context object with previous QnA's information. - :paramtype context: - ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswerRequestContext - :keyword ranker_type: (Optional) Set to 'QuestionOnly' for using a question only Ranker. - Possible values include: "Default", "QuestionOnly". - :paramtype ranker_type: str or ~azure.ai.language.questionanswering.models.RankerType - :keyword strict_filters: Filter QnAs based on give metadata list and knowledge base source - names. - :paramtype strict_filters: ~azure.ai.language.questionanswering.models.StrictFilters - :keyword answer_span_request: To configure Answer span prediction feature. - :paramtype answer_span_request: ~azure.ai.language.questionanswering.models.AnswerSpanRequest - :keyword include_unstructured_sources: (Optional) Flag to enable Query over Unstructured - Sources. - :paramtype include_unstructured_sources: bool + :vartype qna_id: int + :ivar question: User question to query against the knowledge base. + :vartype question: str + :ivar top: Max number of answers to be returned for the question. + :vartype top: int + :ivar user_id: Unique identifier for the user. + :vartype user_id: str + :ivar confidence_score_threshold: Minimum threshold score for answers, value ranges from 0 to + 1. + :vartype confidence_score_threshold: float + :ivar context: Context object with previous QnA's information. + :vartype context: ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswerRequestContext + :ivar ranker_type: (Optional) Set to 'QuestionOnly' for using a question only Ranker. Possible + values include: "Default", "QuestionOnly". + :vartype ranker_type: str or ~azure.ai.language.questionanswering.models.RankerType + :ivar filters: Filter QnAs based on give metadata list and knowledge base source names. + :vartype filters: ~azure.ai.language.questionanswering.models.QueryFilters + :ivar answer_span_request: To configure Answer span prediction feature. + :vartype answer_span_request: ~azure.ai.language.questionanswering.models.AnswerSpanRequest + :ivar include_unstructured_sources: (Optional) Flag to enable Query over Unstructured Sources. + :vartype include_unstructured_sources: bool """ _validation = { @@ -361,12 +457,39 @@ class KnowledgeBaseQueryOptions(msrest.serialization.Model): "confidence_score_threshold": {"key": "confidenceScoreThreshold", "type": "float"}, "context": {"key": "context", "type": "KnowledgeBaseAnswerRequestContext"}, "ranker_type": {"key": "rankerType", "type": "str"}, - "strict_filters": {"key": "strictFilters", "type": "StrictFilters"}, + "filters": {"key": "filters", "type": "QueryFilters"}, "answer_span_request": {"key": "answerSpanRequest", "type": "AnswerSpanRequest"}, "include_unstructured_sources": {"key": "includeUnstructuredSources", "type": "bool"}, } def __init__(self, **kwargs): + """ + :keyword qna_id: Exact QnA ID to fetch from the knowledge base, this field takes priority over + question. + :paramtype qna_id: int + :keyword question: User question to query against the knowledge base. + :paramtype question: str + :keyword top: Max number of answers to be returned for the question. + :paramtype top: int + :keyword user_id: Unique identifier for the user. + :paramtype user_id: str + :keyword confidence_score_threshold: Minimum threshold score for answers, value ranges from 0 + to 1. + :paramtype confidence_score_threshold: float + :keyword context: Context object with previous QnA's information. + :paramtype context: + ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswerRequestContext + :keyword ranker_type: (Optional) Set to 'QuestionOnly' for using a question only Ranker. + Possible values include: "Default", "QuestionOnly". + :paramtype ranker_type: str or ~azure.ai.language.questionanswering.models.RankerType + :keyword filters: Filter QnAs based on give metadata list and knowledge base source names. + :paramtype filters: ~azure.ai.language.questionanswering.models.QueryFilters + :keyword answer_span_request: To configure Answer span prediction feature. + :paramtype answer_span_request: ~azure.ai.language.questionanswering.models.AnswerSpanRequest + :keyword include_unstructured_sources: (Optional) Flag to enable Query over Unstructured + Sources. + :paramtype include_unstructured_sources: bool + """ super(KnowledgeBaseQueryOptions, self).__init__(**kwargs) self.qna_id = kwargs.get("qna_id", None) self.question = kwargs.get("question", None) @@ -375,7 +498,7 @@ def __init__(self, **kwargs): self.confidence_score_threshold = kwargs.get("confidence_score_threshold", None) self.context = kwargs.get("context", None) self.ranker_type = kwargs.get("ranker_type", None) - self.strict_filters = kwargs.get("strict_filters", None) + self.filters = kwargs.get("filters", None) self.answer_span_request = kwargs.get("answer_span_request", None) self.include_unstructured_sources = kwargs.get("include_unstructured_sources", None) @@ -383,67 +506,119 @@ def __init__(self, **kwargs): class MetadataFilter(msrest.serialization.Model): """Find QnAs that are associated with the given list of metadata. - :keyword metadata: Dictionary of :code:``. - :paramtype metadata: dict[str, str] - :keyword compound_operation: (Optional) Set to 'OR' for joining metadata using 'OR' operation. - Possible values include: "AND", "OR". - :paramtype compound_operation: str or - ~azure.ai.language.questionanswering.models.CompoundOperationKind + :ivar metadata: + :vartype metadata: list[~azure.ai.language.questionanswering.models.MetadataRecord] + :ivar logical_operation: Operation used to join metadata filters. Possible values include: + "AND", "OR". + :vartype logical_operation: str or + ~azure.ai.language.questionanswering.models.LogicalOperationKind """ _attribute_map = { - "metadata": {"key": "metadata", "type": "{str}"}, - "compound_operation": {"key": "compoundOperation", "type": "str"}, + "metadata": {"key": "metadata", "type": "[MetadataRecord]"}, + "logical_operation": {"key": "logicalOperation", "type": "str"}, } def __init__(self, **kwargs): + """ + :keyword metadata: + :paramtype metadata: list[~azure.ai.language.questionanswering.models.MetadataRecord] + :keyword logical_operation: Operation used to join metadata filters. Possible values include: + "AND", "OR". + :paramtype logical_operation: str or + ~azure.ai.language.questionanswering.models.LogicalOperationKind + """ super(MetadataFilter, self).__init__(**kwargs) self.metadata = kwargs.get("metadata", None) - self.compound_operation = kwargs.get("compound_operation", None) + self.logical_operation = kwargs.get("logical_operation", None) + + +class MetadataRecord(msrest.serialization.Model): + """Object to provide the key value pair for each metadata. + + All required parameters must be populated in order to send to Azure. + + :ivar key: Required. Metadata Key from Metadata dictionary used in the QnA. + :vartype key: str + :ivar value: Required. Metadata Value from Metadata dictionary used in the QnA. + :vartype value: str + """ + _validation = { + "key": {"required": True}, + "value": {"required": True}, + } -class StrictFilters(msrest.serialization.Model): + _attribute_map = { + "key": {"key": "key", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__(self, **kwargs): + """ + :keyword key: Required. Metadata Key from Metadata dictionary used in the QnA. + :paramtype key: str + :keyword value: Required. Metadata Value from Metadata dictionary used in the QnA. + :paramtype value: str + """ + super(MetadataRecord, self).__init__(**kwargs) + self.key = kwargs["key"] + self.value = kwargs["value"] + + +class QueryFilters(msrest.serialization.Model): """filters over knowledge base. - :keyword metadata_filter: Find QnAs that are associated with the given list of metadata. - :paramtype metadata_filter: ~azure.ai.language.questionanswering.models.MetadataFilter - :keyword source_filter: Find QnAs that are associated with the given list of sources in - knowledge base. - :paramtype source_filter: list[str] - :keyword compound_operation: (Optional) Set to 'OR' for joining metadata using 'OR' operation. + :ivar metadata_filter: Find QnAs that are associated with the given list of metadata. + :vartype metadata_filter: ~azure.ai.language.questionanswering.models.MetadataFilter + :ivar source_filter: Find QnAs that are associated with the given list of sources in knowledge + base. + :vartype source_filter: list[str] + :ivar logical_operation: Logical operation used to join metadata filters with source filters. Possible values include: "AND", "OR". - :paramtype compound_operation: str or - ~azure.ai.language.questionanswering.models.CompoundOperationKind + :vartype logical_operation: str or + ~azure.ai.language.questionanswering.models.LogicalOperationKind """ _attribute_map = { "metadata_filter": {"key": "metadataFilter", "type": "MetadataFilter"}, "source_filter": {"key": "sourceFilter", "type": "[str]"}, - "compound_operation": {"key": "compoundOperation", "type": "str"}, + "logical_operation": {"key": "logicalOperation", "type": "str"}, } def __init__(self, **kwargs): - super(StrictFilters, self).__init__(**kwargs) + """ + :keyword metadata_filter: Find QnAs that are associated with the given list of metadata. + :paramtype metadata_filter: ~azure.ai.language.questionanswering.models.MetadataFilter + :keyword source_filter: Find QnAs that are associated with the given list of sources in + knowledge base. + :paramtype source_filter: list[str] + :keyword logical_operation: Logical operation used to join metadata filters with source + filters. Possible values include: "AND", "OR". + :paramtype logical_operation: str or + ~azure.ai.language.questionanswering.models.LogicalOperationKind + """ + super(QueryFilters, self).__init__(**kwargs) self.metadata_filter = kwargs.get("metadata_filter", None) self.source_filter = kwargs.get("source_filter", None) - self.compound_operation = kwargs.get("compound_operation", None) + self.logical_operation = kwargs.get("logical_operation", None) class TextAnswer(msrest.serialization.Model): """Represents answer result. - :keyword answer: Answer. - :paramtype answer: str - :keyword confidence_score: answer confidence score, value ranges from 0 to 1. - :paramtype confidence_score: float - :keyword id: record ID. - :paramtype id: str - :keyword answer_span: Answer span object with respect to user's question. - :paramtype answer_span: ~azure.ai.language.questionanswering.models.AnswerSpan - :keyword offset: The sentence offset from the start of the document. - :paramtype offset: int - :keyword length: The length of the sentence. - :paramtype length: int + :ivar answer: Answer. + :vartype answer: str + :ivar confidence_score: answer confidence score, value ranges from 0 to 1. + :vartype confidence_score: float + :ivar id: record ID. + :vartype id: str + :ivar answer_span: Answer span object with respect to user's question. + :vartype answer_span: ~azure.ai.language.questionanswering.models.AnswerSpan + :ivar offset: The sentence offset from the start of the document. + :vartype offset: int + :ivar length: The length of the sentence. + :vartype length: int """ _validation = { @@ -460,6 +635,20 @@ class TextAnswer(msrest.serialization.Model): } def __init__(self, **kwargs): + """ + :keyword answer: Answer. + :paramtype answer: str + :keyword confidence_score: answer confidence score, value ranges from 0 to 1. + :paramtype confidence_score: float + :keyword id: record ID. + :paramtype id: str + :keyword answer_span: Answer span object with respect to user's question. + :paramtype answer_span: ~azure.ai.language.questionanswering.models.AnswerSpan + :keyword offset: The sentence offset from the start of the document. + :paramtype offset: int + :keyword length: The length of the sentence. + :paramtype length: int + """ super(TextAnswer, self).__init__(**kwargs) self.answer = kwargs.get("answer", None) self.confidence_score = kwargs.get("confidence_score", None) @@ -472,8 +661,8 @@ def __init__(self, **kwargs): class TextAnswers(msrest.serialization.Model): """Represents the answer results. - :keyword answers: Represents the answer results. - :paramtype answers: list[~azure.ai.language.questionanswering.models.TextAnswer] + :ivar answers: Represents the answer results. + :vartype answers: list[~azure.ai.language.questionanswering.models.TextAnswer] """ _attribute_map = { @@ -481,6 +670,10 @@ class TextAnswers(msrest.serialization.Model): } def __init__(self, **kwargs): + """ + :keyword answers: Represents the answer results. + :paramtype answers: list[~azure.ai.language.questionanswering.models.TextAnswer] + """ super(TextAnswers, self).__init__(**kwargs) self.answers = kwargs.get("answers", None) @@ -490,20 +683,19 @@ class TextQueryOptions(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :keyword question: Required. User question to query against the given text records. - :paramtype question: str - :keyword records: Required. Text records to be searched for given question. - :paramtype records: list[~azure.ai.language.questionanswering.models.TextRecord] - :keyword language: Language of the text records. This is BCP-47 representation of a language. - For example, use "en" for English; "es" for Spanish etc. If not set, use "en" for English as + :ivar question: Required. User question to query against the given text records. + :vartype question: str + :ivar records: Required. Text records to be searched for given question. + :vartype records: list[~azure.ai.language.questionanswering.models.TextRecord] + :ivar language: Language of the text records. This is BCP-47 representation of a language. For + example, use "en" for English; "es" for Spanish etc. If not set, use "en" for English as default. - :paramtype language: str - :keyword string_index_type: Specifies the method used to interpret string offsets. Defaults to + :vartype language: str + :ivar string_index_type: Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets. Possible values include: "TextElements_v8", "UnicodeCodePoint", "Utf16CodeUnit". Default value: "TextElements_v8". - :paramtype string_index_type: str or - ~azure.ai.language.questionanswering.models.StringIndexType + :vartype string_index_type: str or ~azure.ai.language.questionanswering.models.StringIndexType """ _validation = { @@ -519,6 +711,22 @@ class TextQueryOptions(msrest.serialization.Model): } def __init__(self, **kwargs): + """ + :keyword question: Required. User question to query against the given text records. + :paramtype question: str + :keyword records: Required. Text records to be searched for given question. + :paramtype records: list[~azure.ai.language.questionanswering.models.TextRecord] + :keyword language: Language of the text records. This is BCP-47 representation of a language. + For example, use "en" for English; "es" for Spanish etc. If not set, use "en" for English as + default. + :paramtype language: str + :keyword string_index_type: Specifies the method used to interpret string offsets. Defaults to + Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see + https://aka.ms/text-analytics-offsets. Possible values include: "TextElements_v8", + "UnicodeCodePoint", "Utf16CodeUnit". Default value: "TextElements_v8". + :paramtype string_index_type: str or + ~azure.ai.language.questionanswering.models.StringIndexType + """ super(TextQueryOptions, self).__init__(**kwargs) self.question = kwargs["question"] self.records = kwargs["records"] @@ -531,10 +739,10 @@ class TextRecord(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :keyword id: Required. Unique identifier for the text record. - :paramtype id: str - :keyword text: Required. Text contents of the record. - :paramtype text: str + :ivar id: Required. Unique identifier for the text record. + :vartype id: str + :ivar text: Required. Text contents of the record. + :vartype text: str """ _validation = { @@ -548,6 +756,12 @@ class TextRecord(msrest.serialization.Model): } def __init__(self, **kwargs): + """ + :keyword id: Required. Unique identifier for the text record. + :paramtype id: str + :keyword text: Required. Text contents of the record. + :paramtype text: str + """ super(TextRecord, self).__init__(**kwargs) self.id = kwargs["id"] self.text = kwargs["text"] diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models_py3.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models_py3.py index e7b7507de720..3602c5d022f8 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models_py3.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models_py3.py @@ -17,14 +17,14 @@ class AnswerSpan(msrest.serialization.Model): """Answer span object of QnA. - :keyword text: Predicted text of answer span. - :paramtype text: str - :keyword confidence_score: Predicted score of answer span, value ranges from 0 to 1. - :paramtype confidence_score: float - :keyword offset: The answer span offset from the start of answer. - :paramtype offset: int - :keyword length: The length of the answer span. - :paramtype length: int + :ivar text: Predicted text of answer span. + :vartype text: str + :ivar confidence_score: Predicted score of answer span, value ranges from 0 to 1. + :vartype confidence_score: float + :ivar offset: The answer span offset from the start of answer. + :vartype offset: int + :ivar length: The length of the answer span. + :vartype length: int """ _validation = { @@ -47,6 +47,16 @@ def __init__( length: Optional[int] = None, **kwargs ): + """ + :keyword text: Predicted text of answer span. + :paramtype text: str + :keyword confidence_score: Predicted score of answer span, value ranges from 0 to 1. + :paramtype confidence_score: float + :keyword offset: The answer span offset from the start of answer. + :paramtype offset: int + :keyword length: The length of the answer span. + :paramtype length: int + """ super(AnswerSpan, self).__init__(**kwargs) self.text = text self.confidence_score = confidence_score @@ -57,14 +67,14 @@ def __init__( class AnswerSpanRequest(msrest.serialization.Model): """To configure Answer span prediction feature. - :keyword enable: Enable or disable Answer Span prediction. - :paramtype enable: bool - :keyword confidence_score_threshold: Minimum threshold score required to include an answer - span, value ranges from 0 to 1. - :paramtype confidence_score_threshold: float - :keyword top_answers_with_span: Number of Top answers to be considered for span prediction from - 1 to 10. - :paramtype top_answers_with_span: int + :ivar enable: Enable or disable Answer Span prediction. + :vartype enable: bool + :ivar confidence_score_threshold: Minimum threshold score required to include an answer span, + value ranges from 0 to 1. + :vartype confidence_score_threshold: float + :ivar top_answers_with_span: Number of Top answers to be considered for span prediction from 1 + to 10. + :vartype top_answers_with_span: int """ _validation = { @@ -86,6 +96,16 @@ def __init__( top_answers_with_span: Optional[int] = None, **kwargs ): + """ + :keyword enable: Enable or disable Answer Span prediction. + :paramtype enable: bool + :keyword confidence_score_threshold: Minimum threshold score required to include an answer + span, value ranges from 0 to 1. + :paramtype confidence_score_threshold: float + :keyword top_answers_with_span: Number of Top answers to be considered for span prediction from + 1 to 10. + :paramtype top_answers_with_span: int + """ super(AnswerSpanRequest, self).__init__(**kwargs) self.enable = enable self.confidence_score_threshold = confidence_score_threshold @@ -97,19 +117,19 @@ class Error(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :keyword code: Required. One of a server-defined set of error codes. Possible values include: + :ivar code: Required. One of a server-defined set of error codes. Possible values include: "InvalidRequest", "InvalidArgument", "Unauthorized", "Forbidden", "NotFound", "TooManyRequests", "InternalServerError", "ServiceUnavailable". - :paramtype code: str or ~azure.ai.language.questionanswering.models.ErrorCode - :keyword message: Required. A human-readable representation of the error. - :paramtype message: str - :keyword target: The target of the error. - :paramtype target: str - :keyword details: An array of details about specific errors that led to this reported error. - :paramtype details: list[~azure.ai.language.questionanswering.models.Error] - :keyword innererror: An object containing more specific information than the current object - about the error. - :paramtype innererror: ~azure.ai.language.questionanswering.models.InnerErrorModel + :vartype code: str or ~azure.ai.language.questionanswering.models.ErrorCode + :ivar message: Required. A human-readable representation of the error. + :vartype message: str + :ivar target: The target of the error. + :vartype target: str + :ivar details: An array of details about specific errors that led to this reported error. + :vartype details: list[~azure.ai.language.questionanswering.models.Error] + :ivar innererror: An object containing more specific information than the current object about + the error. + :vartype innererror: ~azure.ai.language.questionanswering.models.InnerErrorModel """ _validation = { @@ -135,6 +155,21 @@ def __init__( innererror: Optional["InnerErrorModel"] = None, **kwargs ): + """ + :keyword code: Required. One of a server-defined set of error codes. Possible values include: + "InvalidRequest", "InvalidArgument", "Unauthorized", "Forbidden", "NotFound", + "TooManyRequests", "InternalServerError", "ServiceUnavailable". + :paramtype code: str or ~azure.ai.language.questionanswering.models.ErrorCode + :keyword message: Required. A human-readable representation of the error. + :paramtype message: str + :keyword target: The target of the error. + :paramtype target: str + :keyword details: An array of details about specific errors that led to this reported error. + :paramtype details: list[~azure.ai.language.questionanswering.models.Error] + :keyword innererror: An object containing more specific information than the current object + about the error. + :paramtype innererror: ~azure.ai.language.questionanswering.models.InnerErrorModel + """ super(Error, self).__init__(**kwargs) self.code = code self.message = message @@ -146,8 +181,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Error response. - :keyword error: The error object. - :paramtype error: ~azure.ai.language.questionanswering.models.Error + :ivar error: The error object. + :vartype error: ~azure.ai.language.questionanswering.models.Error """ _attribute_map = { @@ -155,6 +190,10 @@ class ErrorResponse(msrest.serialization.Model): } def __init__(self, *, error: Optional["Error"] = None, **kwargs): + """ + :keyword error: The error object. + :paramtype error: ~azure.ai.language.questionanswering.models.Error + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -164,19 +203,19 @@ class InnerErrorModel(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :keyword code: Required. One of a server-defined set of error codes. Possible values include: + :ivar code: Required. One of a server-defined set of error codes. Possible values include: "InvalidRequest", "InvalidParameterValue", "KnowledgeBaseNotFound", "AzureCognitiveSearchNotFound", "AzureCognitiveSearchThrottling", "ExtractionFailure". - :paramtype code: str or ~azure.ai.language.questionanswering.models.InnerErrorCode - :keyword message: Required. Error message. - :paramtype message: str - :keyword details: Error details. - :paramtype details: dict[str, str] - :keyword target: Error target. - :paramtype target: str - :keyword innererror: An object containing more specific information than the current object - about the error. - :paramtype innererror: ~azure.ai.language.questionanswering.models.InnerErrorModel + :vartype code: str or ~azure.ai.language.questionanswering.models.InnerErrorCode + :ivar message: Required. Error message. + :vartype message: str + :ivar details: Error details. + :vartype details: dict[str, str] + :ivar target: Error target. + :vartype target: str + :ivar innererror: An object containing more specific information than the current object about + the error. + :vartype innererror: ~azure.ai.language.questionanswering.models.InnerErrorModel """ _validation = { @@ -202,6 +241,21 @@ def __init__( innererror: Optional["InnerErrorModel"] = None, **kwargs ): + """ + :keyword code: Required. One of a server-defined set of error codes. Possible values include: + "InvalidRequest", "InvalidParameterValue", "KnowledgeBaseNotFound", + "AzureCognitiveSearchNotFound", "AzureCognitiveSearchThrottling", "ExtractionFailure". + :paramtype code: str or ~azure.ai.language.questionanswering.models.InnerErrorCode + :keyword message: Required. Error message. + :paramtype message: str + :keyword details: Error details. + :paramtype details: dict[str, str] + :keyword target: Error target. + :paramtype target: str + :keyword innererror: An object containing more specific information than the current object + about the error. + :paramtype innererror: ~azure.ai.language.questionanswering.models.InnerErrorModel + """ super(InnerErrorModel, self).__init__(**kwargs) self.code = code self.message = message @@ -213,23 +267,23 @@ def __init__( class KnowledgeBaseAnswer(msrest.serialization.Model): """Represents knowledge base answer. - :keyword questions: List of questions. - :paramtype questions: list[str] - :keyword answer: The Answer. - :paramtype answer: str - :keyword confidence_score: Answer confidence score, value ranges from 0 to 1. - :paramtype confidence_score: float - :keyword id: ID of the QnA result. - :paramtype id: int - :keyword source: Source of QnA result. - :paramtype source: str - :keyword metadata: Metadata associated with the answer, useful to categorize or filter question + :ivar questions: List of questions. + :vartype questions: list[str] + :ivar answer: The Answer. + :vartype answer: str + :ivar confidence_score: Answer confidence score, value ranges from 0 to 1. + :vartype confidence_score: float + :ivar id: ID of the QnA result. + :vartype id: int + :ivar source: Source of QnA result. + :vartype source: str + :ivar metadata: Metadata associated with the answer, useful to categorize or filter question answers. - :paramtype metadata: dict[str, str] - :keyword dialog: Dialog associated with Answer. - :paramtype dialog: ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswerDialog - :keyword answer_span: Answer span object of QnA with respect to user's question. - :paramtype answer_span: ~azure.ai.language.questionanswering.models.AnswerSpan + :vartype metadata: dict[str, str] + :ivar dialog: Dialog associated with Answer. + :vartype dialog: ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswerDialog + :ivar answer_span: Answer span object of QnA with respect to user's question. + :vartype answer_span: ~azure.ai.language.questionanswering.models.AnswerSpan """ _validation = { @@ -260,6 +314,25 @@ def __init__( answer_span: Optional["AnswerSpan"] = None, **kwargs ): + """ + :keyword questions: List of questions. + :paramtype questions: list[str] + :keyword answer: The Answer. + :paramtype answer: str + :keyword confidence_score: Answer confidence score, value ranges from 0 to 1. + :paramtype confidence_score: float + :keyword id: ID of the QnA result. + :paramtype id: int + :keyword source: Source of QnA result. + :paramtype source: str + :keyword metadata: Metadata associated with the answer, useful to categorize or filter question + answers. + :paramtype metadata: dict[str, str] + :keyword dialog: Dialog associated with Answer. + :paramtype dialog: ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswerDialog + :keyword answer_span: Answer span object of QnA with respect to user's question. + :paramtype answer_span: ~azure.ai.language.questionanswering.models.AnswerSpan + """ super(KnowledgeBaseAnswer, self).__init__(**kwargs) self.questions = questions self.answer = answer @@ -274,12 +347,12 @@ def __init__( class KnowledgeBaseAnswerDialog(msrest.serialization.Model): """Dialog associated with Answer. - :keyword is_context_only: To mark if a prompt is relevant only with a previous question or not. - If true, do not include this QnA as search result for queries without context; otherwise, if + :ivar is_context_only: To mark if a prompt is relevant only with a previous question or not. If + true, do not include this QnA as search result for queries without context; otherwise, if false, ignores context and includes this QnA in search result. - :paramtype is_context_only: bool - :keyword prompts: List of 0 to 20 prompts associated with the answer. - :paramtype prompts: list[~azure.ai.language.questionanswering.models.KnowledgeBaseAnswerPrompt] + :vartype is_context_only: bool + :ivar prompts: List of 0 to 20 prompts associated with the answer. + :vartype prompts: list[~azure.ai.language.questionanswering.models.KnowledgeBaseAnswerPrompt] """ _validation = { @@ -298,6 +371,14 @@ def __init__( prompts: Optional[List["KnowledgeBaseAnswerPrompt"]] = None, **kwargs ): + """ + :keyword is_context_only: To mark if a prompt is relevant only with a previous question or not. + If true, do not include this QnA as search result for queries without context; otherwise, if + false, ignores context and includes this QnA in search result. + :paramtype is_context_only: bool + :keyword prompts: List of 0 to 20 prompts associated with the answer. + :paramtype prompts: list[~azure.ai.language.questionanswering.models.KnowledgeBaseAnswerPrompt] + """ super(KnowledgeBaseAnswerDialog, self).__init__(**kwargs) self.is_context_only = is_context_only self.prompts = prompts @@ -306,12 +387,12 @@ def __init__( class KnowledgeBaseAnswerPrompt(msrest.serialization.Model): """Prompt for an answer. - :keyword display_order: Index of the prompt - used in ordering of the prompts. - :paramtype display_order: int - :keyword qna_id: QnA ID corresponding to the prompt. - :paramtype qna_id: int - :keyword display_text: Text displayed to represent a follow up question prompt. - :paramtype display_text: str + :ivar display_order: Index of the prompt - used in ordering of the prompts. + :vartype display_order: int + :ivar qna_id: QnA ID corresponding to the prompt. + :vartype qna_id: int + :ivar display_text: Text displayed to represent a follow up question prompt. + :vartype display_text: str """ _validation = { @@ -332,6 +413,14 @@ def __init__( display_text: Optional[str] = None, **kwargs ): + """ + :keyword display_order: Index of the prompt - used in ordering of the prompts. + :paramtype display_order: int + :keyword qna_id: QnA ID corresponding to the prompt. + :paramtype qna_id: int + :keyword display_text: Text displayed to represent a follow up question prompt. + :paramtype display_text: str + """ super(KnowledgeBaseAnswerPrompt, self).__init__(**kwargs) self.display_order = display_order self.qna_id = qna_id @@ -343,10 +432,10 @@ class KnowledgeBaseAnswerRequestContext(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :keyword previous_qna_id: Required. Previous turn top answer result QnA ID. - :paramtype previous_qna_id: int - :keyword previous_user_query: Previous user query. - :paramtype previous_user_query: str + :ivar previous_qna_id: Required. Previous turn top answer result QnA ID. + :vartype previous_qna_id: int + :ivar previous_user_query: Previous user query. + :vartype previous_user_query: str """ _validation = { @@ -359,6 +448,12 @@ class KnowledgeBaseAnswerRequestContext(msrest.serialization.Model): } def __init__(self, *, previous_qna_id: int, previous_user_query: Optional[str] = None, **kwargs): + """ + :keyword previous_qna_id: Required. Previous turn top answer result QnA ID. + :paramtype previous_qna_id: int + :keyword previous_user_query: Previous user query. + :paramtype previous_user_query: str + """ super(KnowledgeBaseAnswerRequestContext, self).__init__(**kwargs) self.previous_qna_id = previous_qna_id self.previous_user_query = previous_user_query @@ -367,8 +462,8 @@ def __init__(self, *, previous_qna_id: int, previous_user_query: Optional[str] = class KnowledgeBaseAnswers(msrest.serialization.Model): """Represents List of Question Answers. - :keyword answers: Represents Answer Result list. - :paramtype answers: list[~azure.ai.language.questionanswering.models.KnowledgeBaseAnswer] + :ivar answers: Represents Answer Result list. + :vartype answers: list[~azure.ai.language.questionanswering.models.KnowledgeBaseAnswer] """ _attribute_map = { @@ -376,6 +471,10 @@ class KnowledgeBaseAnswers(msrest.serialization.Model): } def __init__(self, *, answers: Optional[List["KnowledgeBaseAnswer"]] = None, **kwargs): + """ + :keyword answers: Represents Answer Result list. + :paramtype answers: list[~azure.ai.language.questionanswering.models.KnowledgeBaseAnswer] + """ super(KnowledgeBaseAnswers, self).__init__(**kwargs) self.answers = answers @@ -383,32 +482,29 @@ def __init__(self, *, answers: Optional[List["KnowledgeBaseAnswer"]] = None, **k class KnowledgeBaseQueryOptions(msrest.serialization.Model): """The question parameters to answer using a knowledge base. - :keyword qna_id: Exact QnA ID to fetch from the knowledge base, this field takes priority over + :ivar qna_id: Exact QnA ID to fetch from the knowledge base, this field takes priority over question. - :paramtype qna_id: int - :keyword question: User question to query against the knowledge base. - :paramtype question: str - :keyword top: Max number of answers to be returned for the question. - :paramtype top: int - :keyword user_id: Unique identifier for the user. - :paramtype user_id: str - :keyword confidence_score_threshold: Minimum threshold score for answers, value ranges from 0 - to 1. - :paramtype confidence_score_threshold: float - :keyword context: Context object with previous QnA's information. - :paramtype context: - ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswerRequestContext - :keyword ranker_type: (Optional) Set to 'QuestionOnly' for using a question only Ranker. - Possible values include: "Default", "QuestionOnly". - :paramtype ranker_type: str or ~azure.ai.language.questionanswering.models.RankerType - :keyword strict_filters: Filter QnAs based on give metadata list and knowledge base source - names. - :paramtype strict_filters: ~azure.ai.language.questionanswering.models.StrictFilters - :keyword answer_span_request: To configure Answer span prediction feature. - :paramtype answer_span_request: ~azure.ai.language.questionanswering.models.AnswerSpanRequest - :keyword include_unstructured_sources: (Optional) Flag to enable Query over Unstructured - Sources. - :paramtype include_unstructured_sources: bool + :vartype qna_id: int + :ivar question: User question to query against the knowledge base. + :vartype question: str + :ivar top: Max number of answers to be returned for the question. + :vartype top: int + :ivar user_id: Unique identifier for the user. + :vartype user_id: str + :ivar confidence_score_threshold: Minimum threshold score for answers, value ranges from 0 to + 1. + :vartype confidence_score_threshold: float + :ivar context: Context object with previous QnA's information. + :vartype context: ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswerRequestContext + :ivar ranker_type: (Optional) Set to 'QuestionOnly' for using a question only Ranker. Possible + values include: "Default", "QuestionOnly". + :vartype ranker_type: str or ~azure.ai.language.questionanswering.models.RankerType + :ivar filters: Filter QnAs based on give metadata list and knowledge base source names. + :vartype filters: ~azure.ai.language.questionanswering.models.QueryFilters + :ivar answer_span_request: To configure Answer span prediction feature. + :vartype answer_span_request: ~azure.ai.language.questionanswering.models.AnswerSpanRequest + :ivar include_unstructured_sources: (Optional) Flag to enable Query over Unstructured Sources. + :vartype include_unstructured_sources: bool """ _validation = { @@ -423,7 +519,7 @@ class KnowledgeBaseQueryOptions(msrest.serialization.Model): "confidence_score_threshold": {"key": "confidenceScoreThreshold", "type": "float"}, "context": {"key": "context", "type": "KnowledgeBaseAnswerRequestContext"}, "ranker_type": {"key": "rankerType", "type": "str"}, - "strict_filters": {"key": "strictFilters", "type": "StrictFilters"}, + "filters": {"key": "filters", "type": "QueryFilters"}, "answer_span_request": {"key": "answerSpanRequest", "type": "AnswerSpanRequest"}, "include_unstructured_sources": {"key": "includeUnstructuredSources", "type": "bool"}, } @@ -438,11 +534,38 @@ def __init__( confidence_score_threshold: Optional[float] = None, context: Optional["KnowledgeBaseAnswerRequestContext"] = None, ranker_type: Optional[Union[str, "RankerType"]] = None, - strict_filters: Optional["StrictFilters"] = None, + filters: Optional["QueryFilters"] = None, answer_span_request: Optional["AnswerSpanRequest"] = None, include_unstructured_sources: Optional[bool] = None, **kwargs ): + """ + :keyword qna_id: Exact QnA ID to fetch from the knowledge base, this field takes priority over + question. + :paramtype qna_id: int + :keyword question: User question to query against the knowledge base. + :paramtype question: str + :keyword top: Max number of answers to be returned for the question. + :paramtype top: int + :keyword user_id: Unique identifier for the user. + :paramtype user_id: str + :keyword confidence_score_threshold: Minimum threshold score for answers, value ranges from 0 + to 1. + :paramtype confidence_score_threshold: float + :keyword context: Context object with previous QnA's information. + :paramtype context: + ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswerRequestContext + :keyword ranker_type: (Optional) Set to 'QuestionOnly' for using a question only Ranker. + Possible values include: "Default", "QuestionOnly". + :paramtype ranker_type: str or ~azure.ai.language.questionanswering.models.RankerType + :keyword filters: Filter QnAs based on give metadata list and knowledge base source names. + :paramtype filters: ~azure.ai.language.questionanswering.models.QueryFilters + :keyword answer_span_request: To configure Answer span prediction feature. + :paramtype answer_span_request: ~azure.ai.language.questionanswering.models.AnswerSpanRequest + :keyword include_unstructured_sources: (Optional) Flag to enable Query over Unstructured + Sources. + :paramtype include_unstructured_sources: bool + """ super(KnowledgeBaseQueryOptions, self).__init__(**kwargs) self.qna_id = qna_id self.question = question @@ -451,7 +574,7 @@ def __init__( self.confidence_score_threshold = confidence_score_threshold self.context = context self.ranker_type = ranker_type - self.strict_filters = strict_filters + self.filters = filters self.answer_span_request = answer_span_request self.include_unstructured_sources = include_unstructured_sources @@ -459,49 +582,90 @@ def __init__( class MetadataFilter(msrest.serialization.Model): """Find QnAs that are associated with the given list of metadata. - :keyword metadata: Dictionary of :code:``. - :paramtype metadata: dict[str, str] - :keyword compound_operation: (Optional) Set to 'OR' for joining metadata using 'OR' operation. - Possible values include: "AND", "OR". - :paramtype compound_operation: str or - ~azure.ai.language.questionanswering.models.CompoundOperationKind + :ivar metadata: + :vartype metadata: list[~azure.ai.language.questionanswering.models.MetadataRecord] + :ivar logical_operation: Operation used to join metadata filters. Possible values include: + "AND", "OR". + :vartype logical_operation: str or + ~azure.ai.language.questionanswering.models.LogicalOperationKind """ _attribute_map = { - "metadata": {"key": "metadata", "type": "{str}"}, - "compound_operation": {"key": "compoundOperation", "type": "str"}, + "metadata": {"key": "metadata", "type": "[MetadataRecord]"}, + "logical_operation": {"key": "logicalOperation", "type": "str"}, } def __init__( self, *, - metadata: Optional[Dict[str, str]] = None, - compound_operation: Optional[Union[str, "CompoundOperationKind"]] = None, + metadata: Optional[List["MetadataRecord"]] = None, + logical_operation: Optional[Union[str, "LogicalOperationKind"]] = None, **kwargs ): + """ + :keyword metadata: + :paramtype metadata: list[~azure.ai.language.questionanswering.models.MetadataRecord] + :keyword logical_operation: Operation used to join metadata filters. Possible values include: + "AND", "OR". + :paramtype logical_operation: str or + ~azure.ai.language.questionanswering.models.LogicalOperationKind + """ super(MetadataFilter, self).__init__(**kwargs) self.metadata = metadata - self.compound_operation = compound_operation + self.logical_operation = logical_operation + + +class MetadataRecord(msrest.serialization.Model): + """Object to provide the key value pair for each metadata. + + All required parameters must be populated in order to send to Azure. + + :ivar key: Required. Metadata Key from Metadata dictionary used in the QnA. + :vartype key: str + :ivar value: Required. Metadata Value from Metadata dictionary used in the QnA. + :vartype value: str + """ + + _validation = { + "key": {"required": True}, + "value": {"required": True}, + } + + _attribute_map = { + "key": {"key": "key", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__(self, *, key: str, value: str, **kwargs): + """ + :keyword key: Required. Metadata Key from Metadata dictionary used in the QnA. + :paramtype key: str + :keyword value: Required. Metadata Value from Metadata dictionary used in the QnA. + :paramtype value: str + """ + super(MetadataRecord, self).__init__(**kwargs) + self.key = key + self.value = value -class StrictFilters(msrest.serialization.Model): +class QueryFilters(msrest.serialization.Model): """filters over knowledge base. - :keyword metadata_filter: Find QnAs that are associated with the given list of metadata. - :paramtype metadata_filter: ~azure.ai.language.questionanswering.models.MetadataFilter - :keyword source_filter: Find QnAs that are associated with the given list of sources in - knowledge base. - :paramtype source_filter: list[str] - :keyword compound_operation: (Optional) Set to 'OR' for joining metadata using 'OR' operation. + :ivar metadata_filter: Find QnAs that are associated with the given list of metadata. + :vartype metadata_filter: ~azure.ai.language.questionanswering.models.MetadataFilter + :ivar source_filter: Find QnAs that are associated with the given list of sources in knowledge + base. + :vartype source_filter: list[str] + :ivar logical_operation: Logical operation used to join metadata filters with source filters. Possible values include: "AND", "OR". - :paramtype compound_operation: str or - ~azure.ai.language.questionanswering.models.CompoundOperationKind + :vartype logical_operation: str or + ~azure.ai.language.questionanswering.models.LogicalOperationKind """ _attribute_map = { "metadata_filter": {"key": "metadataFilter", "type": "MetadataFilter"}, "source_filter": {"key": "sourceFilter", "type": "[str]"}, - "compound_operation": {"key": "compoundOperation", "type": "str"}, + "logical_operation": {"key": "logicalOperation", "type": "str"}, } def __init__( @@ -509,30 +673,41 @@ def __init__( *, metadata_filter: Optional["MetadataFilter"] = None, source_filter: Optional[List[str]] = None, - compound_operation: Optional[Union[str, "CompoundOperationKind"]] = None, + logical_operation: Optional[Union[str, "LogicalOperationKind"]] = None, **kwargs ): - super(StrictFilters, self).__init__(**kwargs) + """ + :keyword metadata_filter: Find QnAs that are associated with the given list of metadata. + :paramtype metadata_filter: ~azure.ai.language.questionanswering.models.MetadataFilter + :keyword source_filter: Find QnAs that are associated with the given list of sources in + knowledge base. + :paramtype source_filter: list[str] + :keyword logical_operation: Logical operation used to join metadata filters with source + filters. Possible values include: "AND", "OR". + :paramtype logical_operation: str or + ~azure.ai.language.questionanswering.models.LogicalOperationKind + """ + super(QueryFilters, self).__init__(**kwargs) self.metadata_filter = metadata_filter self.source_filter = source_filter - self.compound_operation = compound_operation + self.logical_operation = logical_operation class TextAnswer(msrest.serialization.Model): """Represents answer result. - :keyword answer: Answer. - :paramtype answer: str - :keyword confidence_score: answer confidence score, value ranges from 0 to 1. - :paramtype confidence_score: float - :keyword id: record ID. - :paramtype id: str - :keyword answer_span: Answer span object with respect to user's question. - :paramtype answer_span: ~azure.ai.language.questionanswering.models.AnswerSpan - :keyword offset: The sentence offset from the start of the document. - :paramtype offset: int - :keyword length: The length of the sentence. - :paramtype length: int + :ivar answer: Answer. + :vartype answer: str + :ivar confidence_score: answer confidence score, value ranges from 0 to 1. + :vartype confidence_score: float + :ivar id: record ID. + :vartype id: str + :ivar answer_span: Answer span object with respect to user's question. + :vartype answer_span: ~azure.ai.language.questionanswering.models.AnswerSpan + :ivar offset: The sentence offset from the start of the document. + :vartype offset: int + :ivar length: The length of the sentence. + :vartype length: int """ _validation = { @@ -559,6 +734,20 @@ def __init__( length: Optional[int] = None, **kwargs ): + """ + :keyword answer: Answer. + :paramtype answer: str + :keyword confidence_score: answer confidence score, value ranges from 0 to 1. + :paramtype confidence_score: float + :keyword id: record ID. + :paramtype id: str + :keyword answer_span: Answer span object with respect to user's question. + :paramtype answer_span: ~azure.ai.language.questionanswering.models.AnswerSpan + :keyword offset: The sentence offset from the start of the document. + :paramtype offset: int + :keyword length: The length of the sentence. + :paramtype length: int + """ super(TextAnswer, self).__init__(**kwargs) self.answer = answer self.confidence_score = confidence_score @@ -571,8 +760,8 @@ def __init__( class TextAnswers(msrest.serialization.Model): """Represents the answer results. - :keyword answers: Represents the answer results. - :paramtype answers: list[~azure.ai.language.questionanswering.models.TextAnswer] + :ivar answers: Represents the answer results. + :vartype answers: list[~azure.ai.language.questionanswering.models.TextAnswer] """ _attribute_map = { @@ -580,6 +769,10 @@ class TextAnswers(msrest.serialization.Model): } def __init__(self, *, answers: Optional[List["TextAnswer"]] = None, **kwargs): + """ + :keyword answers: Represents the answer results. + :paramtype answers: list[~azure.ai.language.questionanswering.models.TextAnswer] + """ super(TextAnswers, self).__init__(**kwargs) self.answers = answers @@ -589,20 +782,19 @@ class TextQueryOptions(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :keyword question: Required. User question to query against the given text records. - :paramtype question: str - :keyword records: Required. Text records to be searched for given question. - :paramtype records: list[~azure.ai.language.questionanswering.models.TextRecord] - :keyword language: Language of the text records. This is BCP-47 representation of a language. - For example, use "en" for English; "es" for Spanish etc. If not set, use "en" for English as + :ivar question: Required. User question to query against the given text records. + :vartype question: str + :ivar records: Required. Text records to be searched for given question. + :vartype records: list[~azure.ai.language.questionanswering.models.TextRecord] + :ivar language: Language of the text records. This is BCP-47 representation of a language. For + example, use "en" for English; "es" for Spanish etc. If not set, use "en" for English as default. - :paramtype language: str - :keyword string_index_type: Specifies the method used to interpret string offsets. Defaults to + :vartype language: str + :ivar string_index_type: Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see https://aka.ms/text-analytics-offsets. Possible values include: "TextElements_v8", "UnicodeCodePoint", "Utf16CodeUnit". Default value: "TextElements_v8". - :paramtype string_index_type: str or - ~azure.ai.language.questionanswering.models.StringIndexType + :vartype string_index_type: str or ~azure.ai.language.questionanswering.models.StringIndexType """ _validation = { @@ -626,6 +818,22 @@ def __init__( string_index_type: Optional[Union[str, "StringIndexType"]] = "TextElements_v8", **kwargs ): + """ + :keyword question: Required. User question to query against the given text records. + :paramtype question: str + :keyword records: Required. Text records to be searched for given question. + :paramtype records: list[~azure.ai.language.questionanswering.models.TextRecord] + :keyword language: Language of the text records. This is BCP-47 representation of a language. + For example, use "en" for English; "es" for Spanish etc. If not set, use "en" for English as + default. + :paramtype language: str + :keyword string_index_type: Specifies the method used to interpret string offsets. Defaults to + Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see + https://aka.ms/text-analytics-offsets. Possible values include: "TextElements_v8", + "UnicodeCodePoint", "Utf16CodeUnit". Default value: "TextElements_v8". + :paramtype string_index_type: str or + ~azure.ai.language.questionanswering.models.StringIndexType + """ super(TextQueryOptions, self).__init__(**kwargs) self.question = question self.records = records @@ -638,10 +846,10 @@ class TextRecord(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :keyword id: Required. Unique identifier for the text record. - :paramtype id: str - :keyword text: Required. Text contents of the record. - :paramtype text: str + :ivar id: Required. Unique identifier for the text record. + :vartype id: str + :ivar text: Required. Text contents of the record. + :vartype text: str """ _validation = { @@ -655,6 +863,12 @@ class TextRecord(msrest.serialization.Model): } def __init__(self, *, id: str, text: str, **kwargs): + """ + :keyword id: Required. Unique identifier for the text record. + :paramtype id: str + :keyword text: Required. Text contents of the record. + :paramtype text: str + """ super(TextRecord, self).__init__(**kwargs) self.id = id self.text = text diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_question_answering_client_enums.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_question_answering_client_enums.py index 869e123dc112..d8fa5d884ed3 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_question_answering_client_enums.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_question_answering_client_enums.py @@ -11,13 +11,6 @@ from azure.core import CaseInsensitiveEnumMeta -class CompoundOperationKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """(Optional) Set to 'OR' for joining metadata using 'OR' operation.""" - - AND_ENUM = "AND" - OR_ENUM = "OR" - - class ErrorCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Human-readable error code.""" @@ -42,6 +35,13 @@ class InnerErrorCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): EXTRACTION_FAILURE = "ExtractionFailure" +class LogicalOperationKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Set to 'OR' or 'AND' for using corresponding logical operation.""" + + AND_ENUM = "AND" + OR_ENUM = "OR" + + class RankerType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """(Optional) Set to 'QuestionOnly' for using a question only Ranker.""" diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py index 4f8f585e2a7e..1e43384a3598 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py @@ -40,7 +40,7 @@ def build_query_knowledge_base_request( # type: (...) -> HttpRequest content_type = kwargs.pop('content_type', None) # type: Optional[str] project_name = kwargs.pop('project_name') # type: str - deployment_name = kwargs.pop('deployment_name', None) # type: Optional[str] + deployment_name = kwargs.pop('deployment_name') # type: str api_version = "2021-07-15-preview" accept = "application/json" @@ -50,8 +50,7 @@ def build_query_knowledge_base_request( # Construct parameters query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] query_parameters['projectName'] = _SERIALIZER.query("project_name", project_name, 'str') - if deployment_name is not None: - query_parameters['deploymentName'] = _SERIALIZER.query("deployment_name", deployment_name, 'str') + query_parameters['deploymentName'] = _SERIALIZER.query("deployment_name", deployment_name, 'str') query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers @@ -116,8 +115,7 @@ def query_knowledge_base( :paramtype project_name: str :keyword deployment_name: The name of the specific deployment of the project to use. :paramtype deployment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: KnowledgeBaseAnswers, or the result of cls(response) + :return: KnowledgeBaseAnswers :rtype: ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswers :raises: ~azure.core.exceptions.HttpResponseError """ @@ -158,8 +156,7 @@ def query_knowledge_base( :paramtype answer_span_request: ~azure.ai.language.questionanswering.models.AnswerSpanRequest :keyword include_unstructured_sources: (Optional) Flag to enable Query over Unstructured Sources. :paramtype include_unstructured_sources: bool - :keyword callable cls: A custom type or function that will be passed the direct response - :return: KnowledgeBaseAnswers, or the result of cls(response) + :return: KnowledgeBaseAnswers :rtype: ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswers :raises: ~azure.core.exceptions.HttpResponseError """ @@ -203,8 +200,7 @@ def query_knowledge_base( :paramtype answer_span_request: ~azure.ai.language.questionanswering.models.AnswerSpanRequest :keyword include_unstructured_sources: (Optional) Flag to enable Query over Unstructured Sources. :paramtype include_unstructured_sources: bool - :keyword callable cls: A custom type or function that will be passed the direct response - :return: KnowledgeBaseAnswers, or the result of cls(response) + :return: KnowledgeBaseAnswers :rtype: ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswers :raises: ~azure.core.exceptions.HttpResponseError """ @@ -228,7 +224,7 @@ def query_knowledge_base( error_map.update(kwargs.pop("error_map", {})) content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] project_name = kwargs.pop("project_name") # type: str - deployment_name = kwargs.pop("deployment_name", None) # type: Optional[str] + deployment_name = kwargs.pop("deployment_name") # type: str json = self._serialize.body(knowledge_base_query_options, "KnowledgeBaseQueryOptions") @@ -244,7 +240,7 @@ def query_knowledge_base( } request.url = self._client.format_url(request.url, **path_format_arguments) - pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -272,8 +268,7 @@ def query_text( :param text_query_options: Post body of the request. :type text_query_options: ~azure.ai.language.questionanswering.models.TextQueryOptions - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TextAnswers, or the result of cls(response) + :return: TextAnswers :rtype: ~azure.ai.language.questionanswering.models.TextAnswers :raises: ~azure.core.exceptions.HttpResponseError """ @@ -300,8 +295,7 @@ def query_text( https://aka.ms/text-analytics-offsets. Possible values include: "TextElements_v8", "UnicodeCodePoint", "Utf16CodeUnit". Default value: "TextElements_v8". :paramtype string_index_type: str or ~azure.ai.language.questionanswering.models.StringIndexType - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TextAnswers, or the result of cls(response) + :return: TextAnswers :rtype: ~azure.ai.language.questionanswering.models.TextAnswers :raises: ~azure.core.exceptions.HttpResponseError """ @@ -318,7 +312,7 @@ def query_text( :param text_query_options: Post body of the request. Provide either `text_query_options`, OR individual keyword arguments. If both are provided, only the options object will be used. :type text_query_options: ~azure.ai.language.questionanswering.models.TextQueryOptions - :keyword question: User question to query against the given text records. Provide either `text_query_options`, + :keyword question: User question to query against the given text records. Provide either `text_query_options`, OR individual keyword arguments. If both are provided, only the options object will be used. :paramtype question: str :keyword records: Text records to be searched for given question. Provide either `text_query_options`, OR @@ -332,8 +326,7 @@ def query_text( https://aka.ms/text-analytics-offsets. Possible values include: "TextElements_v8", "UnicodeCodePoint", "Utf16CodeUnit". Default value: "TextElements_v8". :paramtype string_index_type: str or ~azure.ai.language.questionanswering.models.StringIndexType - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TextAnswers, or the result of cls(response) + :return: TextAnswers :rtype: ~azure.ai.language.questionanswering.models.TextAnswers :raises: ~azure.core.exceptions.HttpResponseError """ @@ -368,7 +361,7 @@ def query_text( } request.url = self._client.format_url(request.url, **path_format_arguments) - pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: From 78d730947b757815bd6069109e120b88e70678a3 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Wed, 29 Sep 2021 14:34:01 -0400 Subject: [PATCH 02/20] add directives to change param names -> options --- .../aio/operations/_operations.py | 42 +++++++++---------- .../operations/_operations.py | 42 +++++++++---------- .../swagger/README.md | 19 +++++++++ 3 files changed, 61 insertions(+), 42 deletions(-) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py index 3efce7a78e61..80cac61ca064 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py @@ -32,7 +32,7 @@ class QuestionAnsweringClientOperationsMixin: @overload async def query_knowledge_base( self, - knowledge_base_query_options: "_models.KnowledgeBaseQueryOptions", + options: "_models.KnowledgeBaseQueryOptions", *, project_name: str, deployment_name: str, @@ -40,8 +40,8 @@ async def query_knowledge_base( ) -> "_models.KnowledgeBaseAnswers": """Answers the specified question using your knowledge base. - :param knowledge_base_query_options: Post body of the request. - :type knowledge_base_query_options: + :param options: Post body of the request. + :type options: ~azure.ai.language.questionanswering.models.KnowledgeBaseQueryOptions :keyword project_name: The name of the project to use. :paramtype project_name: str @@ -112,9 +112,9 @@ async def query_knowledge_base( ) -> "_models.KnowledgeBaseAnswers": """Answers the specified question using your knowledge base. - :param knowledge_base_query_options: Post body of the request. Provide either `knowledge_base_query_options`, OR + :param options: Post body of the request. Provide either `options`, OR individual keyword arguments. If both are provided, only the options object will be used. - :type knowledge_base_query_options: + :type options: ~azure.ai.language.questionanswering.models.KnowledgeBaseQueryOptions :keyword project_name: The name of the project to use. :paramtype project_name: str @@ -122,7 +122,7 @@ async def query_knowledge_base( :paramtype deployment_name: str :keyword qna_id: Exact QnA ID to fetch from the knowledge base, this field takes priority over question. :paramtype qna_id: int - :keyword question: User question to query against the knowledge base. Provide either `knowledge_base_query_options`, OR + :keyword question: User question to query against the knowledge base. Provide either `options`, OR individual keyword arguments. If both are provided, only the options object will be used. :paramtype question: str :keyword top: Max number of answers to be returned for the question. @@ -147,9 +147,9 @@ async def query_knowledge_base( :raises: ~azure.core.exceptions.HttpResponseError """ if args: - knowledge_base_query_options = args[0] + options = args[0] else: - knowledge_base_query_options = _models.KnowledgeBaseQueryOptions( + options = _models.KnowledgeBaseQueryOptions( qna_id=kwargs.pop("qna_id", None), question=kwargs.pop("question", None), top=kwargs.pop("top", None), @@ -168,7 +168,7 @@ async def query_knowledge_base( project_name = kwargs.pop("project_name") # type: str deployment_name = kwargs.pop("deployment_name") # type: str - json = self._serialize.body(knowledge_base_query_options, "KnowledgeBaseQueryOptions") + json = self._serialize.body(options, "KnowledgeBaseQueryOptions") request = build_query_knowledge_base_request( content_type=content_type, @@ -200,11 +200,11 @@ async def query_knowledge_base( query_knowledge_base.metadata = {"url": "/:query-knowledgebases"} # type: ignore @overload - async def query_text(self, text_query_options: "_models.TextQueryOptions", **kwargs: Any) -> "_models.TextAnswers": + async def query_text(self, options: "_models.TextQueryOptions", **kwargs: Any) -> "_models.TextAnswers": """Answers the specified question using the provided text in the body. - :param text_query_options: Post body of the request. - :type text_query_options: ~azure.ai.language.questionanswering.models.TextQueryOptions + :param options: Post body of the request. + :type options: ~azure.ai.language.questionanswering.models.TextQueryOptions :return: TextAnswers :rtype: ~azure.ai.language.questionanswering.models.TextAnswers :raises: ~azure.core.exceptions.HttpResponseError @@ -247,13 +247,13 @@ async def query_text( ) -> "_models.TextAnswers": """Answers the specified question using the provided text in the body. - :param text_query_options: Post body of the request. Provide either `text_query_options`, OR + :param options: Post body of the request. Provide either `options`, OR individual keyword arguments. If both are provided, only the options object will be used. - :type text_query_options: ~azure.ai.language.questionanswering.models.TextQueryOptions - :keyword question: User question to query against the given text records. Provide either `text_query_options`, OR + :type options: ~azure.ai.language.questionanswering.models.TextQueryOptions + :keyword question: User question to query against the given text records. Provide either `options`, OR individual keyword arguments. If both are provided, only the options object will be used. :paramtype question: str - :keyword records: Text records to be searched for given question. Provide either `text_query_options`, OR + :keyword records: Text records to be searched for given question. Provide either `options`, OR individual keyword arguments. If both are provided, only the options object will be used. :paramtype records: list[~azure.ai.language.questionanswering.models.TextRecord] :keyword language: Language of the text records. This is BCP-47 representation of a language. For @@ -269,25 +269,25 @@ async def query_text( :raises: ~azure.core.exceptions.HttpResponseError """ if args: - text_query_options = args[0] + options = args[0] else: - text_query_options = _models.TextQueryOptions( + options = _models.TextQueryOptions( question=kwargs.pop("question"), records=kwargs.pop("records"), language=kwargs.pop("language", None), string_index_type=kwargs.pop("string_index_type", "TextElements_v8") ) try: - text_query_options['records'] = _validate_text_records(text_query_options['records']) + options['records'] = _validate_text_records(options['records']) except TypeError: - text_query_options.records = _validate_text_records(text_query_options.records) + options.records = _validate_text_records(options.records) cls = kwargs.pop("cls", None) # type: ClsType["_models.TextAnswers"] error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop("error_map", {})) content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] - json = self._serialize.body(text_query_options, "TextQueryOptions") + json = self._serialize.body(options, "TextQueryOptions") request = build_query_text_request( content_type=content_type, diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py index 1e43384a3598..c8ffd9515ccb 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py @@ -102,14 +102,14 @@ class QuestionAnsweringClientOperationsMixin(object): @overload def query_knowledge_base( self, - knowledge_base_query_options, # type: "_models.KnowledgeBaseQueryOptions" + options, # type: "_models.KnowledgeBaseQueryOptions" **kwargs # type: Any ): # type: (...) -> "_models.KnowledgeBaseAnswers" """Answers the specified question using your knowledge base. - :param knowledge_base_query_options: Post body of the request. - :type knowledge_base_query_options: + :param options: Post body of the request. + :type options: ~azure.ai.language.questionanswering.models.KnowledgeBaseQueryOptions :keyword project_name: The name of the project to use. :paramtype project_name: str @@ -170,15 +170,15 @@ def query_knowledge_base( # type: (...) -> "_models.KnowledgeBaseAnswers" """Answers the specified question using your knowledge base. - :param knowledge_base_query_options: Post body of the request. Provide either `knowledge_base_query_options`, OR + :param options: Post body of the request. Provide either `options`, OR individual keyword arguments. If both are provided, only the options object will be used. - :type knowledge_base_query_options: + :type options: ~azure.ai.language.questionanswering.models.KnowledgeBaseQueryOptions :keyword project_name: The name of the project to use. :paramtype project_name: str :keyword deployment_name: The name of the specific deployment of the project to use. :paramtype deployment_name: str - :keyword question: User question to query against the knowledge base. Provide either `knowledge_base_query_options`, OR + :keyword question: User question to query against the knowledge base. Provide either `options`, OR individual keyword arguments. If both are provided, only the options object will be used. :paramtype question: str :keyword qna_id: Exact QnA ID to fetch from the knowledge base, this field takes priority over question. @@ -205,9 +205,9 @@ def query_knowledge_base( :raises: ~azure.core.exceptions.HttpResponseError """ if args: - knowledge_base_query_options = args[0] + options = args[0] else: - knowledge_base_query_options = _models.KnowledgeBaseQueryOptions( + options = _models.KnowledgeBaseQueryOptions( qna_id=kwargs.pop("qna_id", None), question=kwargs.pop("question", None), top=kwargs.pop("top", None), @@ -226,7 +226,7 @@ def query_knowledge_base( project_name = kwargs.pop("project_name") # type: str deployment_name = kwargs.pop("deployment_name") # type: str - json = self._serialize.body(knowledge_base_query_options, "KnowledgeBaseQueryOptions") + json = self._serialize.body(options, "KnowledgeBaseQueryOptions") request = build_query_knowledge_base_request( content_type=content_type, @@ -260,14 +260,14 @@ def query_knowledge_base( @overload def query_text( self, - text_query_options, # type: "_models.TextQueryOptions" + options, # type: "_models.TextQueryOptions" **kwargs # type: Any ): # type: (...) -> "_models.TextAnswers" """Answers the specified question using the provided text in the body. - :param text_query_options: Post body of the request. - :type text_query_options: ~azure.ai.language.questionanswering.models.TextQueryOptions + :param options: Post body of the request. + :type options: ~azure.ai.language.questionanswering.models.TextQueryOptions :return: TextAnswers :rtype: ~azure.ai.language.questionanswering.models.TextAnswers :raises: ~azure.core.exceptions.HttpResponseError @@ -309,13 +309,13 @@ def query_text( # type: (...) -> "_models.TextAnswers" """Answers the specified question using the provided text in the body. - :param text_query_options: Post body of the request. Provide either `text_query_options`, OR + :param options: Post body of the request. Provide either `options`, OR individual keyword arguments. If both are provided, only the options object will be used. - :type text_query_options: ~azure.ai.language.questionanswering.models.TextQueryOptions - :keyword question: User question to query against the given text records. Provide either `text_query_options`, + :type options: ~azure.ai.language.questionanswering.models.TextQueryOptions + :keyword question: User question to query against the given text records. Provide either `options`, OR individual keyword arguments. If both are provided, only the options object will be used. :paramtype question: str - :keyword records: Text records to be searched for given question. Provide either `text_query_options`, OR + :keyword records: Text records to be searched for given question. Provide either `options`, OR individual keyword arguments. If both are provided, only the options object will be used. :paramtype records: list[str or ~azure.ai.language.questionanswering.models.TextRecord] :keyword language: Language of the text records. This is BCP-47 representation of a language. For @@ -331,25 +331,25 @@ def query_text( :raises: ~azure.core.exceptions.HttpResponseError """ if args: - text_query_options = args[0] + options = args[0] else: - text_query_options = _models.TextQueryOptions( + options = _models.TextQueryOptions( question=kwargs.pop("question"), records=kwargs.pop("records"), language=kwargs.pop("language", None), string_index_type=kwargs.pop("string_index_type", "TextElements_v8") ) try: - text_query_options['records'] = _validate_text_records(text_query_options['records']) + options['records'] = _validate_text_records(options['records']) except TypeError: - text_query_options.records = _validate_text_records(text_query_options.records) + options.records = _validate_text_records(options.records) cls = kwargs.pop("cls", None) # type: ClsType["_models.TextAnswers"] error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop("error_map", {})) content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] - json = self._serialize.body(text_query_options, "TextQueryOptions") + json = self._serialize.body(options, "TextQueryOptions") request = build_query_text_request( content_type=content_type, diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/swagger/README.md b/sdk/cognitivelanguage/azure-ai-language-questionanswering/swagger/README.md index 631ff0b2fbb5..882e7f00f690 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/swagger/README.md +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/swagger/README.md @@ -58,3 +58,22 @@ directive: $["operationId"] = "queryText"; ``` +### Rename `KnowledgeBasedQueryOptions` -> `Options` + +```yaml +directive: + - from: swagger-document + where: $["parameters"]["KnowledgeBaseQueryOptions"] + transform: > + $["x-ms-client-name"] = "Options"; +``` + +### Rename `TextQueryOptions` -> `Options` + +```yaml +directive: + - from: swagger-document + where: $["parameters"]["TextQueryOptions"] + transform: > + $["x-ms-client-name"] = "Options"; +``` From f7d3727b2157b69836f5cd131eda8b0928acdec5 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Wed, 29 Sep 2021 16:34:52 -0400 Subject: [PATCH 03/20] make options bags positional only --- .../ai/language/questionanswering/_patch.py | 9 ++++ .../aio/operations/_operations.py | 48 ++++++++----------- .../operations/_operations.py | 48 ++++++++----------- .../tests/test_query_knowledgebase.py | 11 ++++- .../tests/test_query_knowledgebase_async.py | 7 +++ .../tests/test_query_text.py | 8 ++++ .../tests/test_query_text_async.py | 7 +++ 7 files changed, 82 insertions(+), 56 deletions(-) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_patch.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_patch.py index 7308492dcdab..d637ad8ff20f 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_patch.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_patch.py @@ -36,3 +36,12 @@ def _validate_text_records(records): else: request_batch.append(doc) return request_batch + +def _get_positional_body(*args, **kwargs): + if len(args) > 1: + raise TypeError("There can only be one positional argument, which is the post body of this request.") + if args and "options" in kwargs: + raise TypeError( + "You have already supplied the request body as a positional parameter, you can not supply it as a kwarg as well." + ) + return args[0] if args else None diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py index 80cac61ca064..586897f0ead3 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py @@ -22,7 +22,7 @@ from ... import models as _models from ...operations._operations import build_query_knowledge_base_request, build_query_text_request -from ..._patch import _validate_text_records +from ..._patch import _validate_text_records, _get_positional_body T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +40,7 @@ async def query_knowledge_base( ) -> "_models.KnowledgeBaseAnswers": """Answers the specified question using your knowledge base. - :param options: Post body of the request. + :param options: Positional-only post body of the request. :type options: ~azure.ai.language.questionanswering.models.KnowledgeBaseQueryOptions :keyword project_name: The name of the project to use. @@ -146,21 +146,18 @@ async def query_knowledge_base( :rtype: ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswers :raises: ~azure.core.exceptions.HttpResponseError """ - if args: - options = args[0] - else: - options = _models.KnowledgeBaseQueryOptions( - qna_id=kwargs.pop("qna_id", None), - question=kwargs.pop("question", None), - top=kwargs.pop("top", None), - user_id=kwargs.pop("user_id", None), - confidence_score_threshold=kwargs.pop("confidence_score_threshold", None), - context=kwargs.pop("context", None), - ranker_type=kwargs.pop("ranker_type", None), - strict_filters=kwargs.pop("strict_filters", None), - answer_span_request=kwargs.pop("answer_span_request", None), - include_unstructured_sources=kwargs.pop("include_unstructured_sources", None) - ) + options = _get_positional_body(*args, **kwargs) or _models.KnowledgeBaseQueryOptions( + qna_id=kwargs.pop("qna_id", None), + question=kwargs.pop("question", None), + top=kwargs.pop("top", None), + user_id=kwargs.pop("user_id", None), + confidence_score_threshold=kwargs.pop("confidence_score_threshold", None), + context=kwargs.pop("context", None), + ranker_type=kwargs.pop("ranker_type", None), + strict_filters=kwargs.pop("strict_filters", None), + answer_span_request=kwargs.pop("answer_span_request", None), + include_unstructured_sources=kwargs.pop("include_unstructured_sources", None) + ) cls = kwargs.pop("cls", None) # type: ClsType["_models.KnowledgeBaseAnswers"] error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop("error_map", {})) @@ -203,7 +200,7 @@ async def query_knowledge_base( async def query_text(self, options: "_models.TextQueryOptions", **kwargs: Any) -> "_models.TextAnswers": """Answers the specified question using the provided text in the body. - :param options: Post body of the request. + :param options: Positional-only post body of the request. :type options: ~azure.ai.language.questionanswering.models.TextQueryOptions :return: TextAnswers :rtype: ~azure.ai.language.questionanswering.models.TextAnswers @@ -268,15 +265,12 @@ async def query_text( :rtype: ~azure.ai.language.questionanswering.models.TextAnswers :raises: ~azure.core.exceptions.HttpResponseError """ - if args: - options = args[0] - else: - options = _models.TextQueryOptions( - question=kwargs.pop("question"), - records=kwargs.pop("records"), - language=kwargs.pop("language", None), - string_index_type=kwargs.pop("string_index_type", "TextElements_v8") - ) + options = _get_positional_body(*args, **kwargs) or _models.TextQueryOptions( + question=kwargs.pop("question"), + records=kwargs.pop("records"), + language=kwargs.pop("language", None), + string_index_type=kwargs.pop("string_index_type", "TextElements_v8") + ) try: options['records'] = _validate_text_records(options['records']) except TypeError: diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py index c8ffd9515ccb..658d920781be 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py @@ -22,7 +22,7 @@ from msrest import Serializer from .. import models as _models -from .._patch import _validate_text_records +from .._patch import _validate_text_records, _get_positional_body if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -108,7 +108,7 @@ def query_knowledge_base( # type: (...) -> "_models.KnowledgeBaseAnswers" """Answers the specified question using your knowledge base. - :param options: Post body of the request. + :param options: Positional-only post body of the request. :type options: ~azure.ai.language.questionanswering.models.KnowledgeBaseQueryOptions :keyword project_name: The name of the project to use. @@ -204,21 +204,18 @@ def query_knowledge_base( :rtype: ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswers :raises: ~azure.core.exceptions.HttpResponseError """ - if args: - options = args[0] - else: - options = _models.KnowledgeBaseQueryOptions( - qna_id=kwargs.pop("qna_id", None), - question=kwargs.pop("question", None), - top=kwargs.pop("top", None), - user_id=kwargs.pop("user_id", None), - confidence_score_threshold=kwargs.pop("confidence_score_threshold", None), - context=kwargs.pop("context", None), - ranker_type=kwargs.pop("ranker_type", None), - strict_filters=kwargs.pop("strict_filters", None), - answer_span_request=kwargs.pop("answer_span_request", None), - include_unstructured_sources=kwargs.pop("include_unstructured_sources", None) - ) + options = _get_positional_body(*args, **kwargs) or _models.KnowledgeBaseQueryOptions( + qna_id=kwargs.pop("qna_id", None), + question=kwargs.pop("question", None), + top=kwargs.pop("top", None), + user_id=kwargs.pop("user_id", None), + confidence_score_threshold=kwargs.pop("confidence_score_threshold", None), + context=kwargs.pop("context", None), + ranker_type=kwargs.pop("ranker_type", None), + strict_filters=kwargs.pop("strict_filters", None), + answer_span_request=kwargs.pop("answer_span_request", None), + include_unstructured_sources=kwargs.pop("include_unstructured_sources", None) + ) cls = kwargs.pop("cls", None) # type: ClsType["_models.KnowledgeBaseAnswers"] error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop("error_map", {})) @@ -266,7 +263,7 @@ def query_text( # type: (...) -> "_models.TextAnswers" """Answers the specified question using the provided text in the body. - :param options: Post body of the request. + :param options: Positional-only post body of the request. :type options: ~azure.ai.language.questionanswering.models.TextQueryOptions :return: TextAnswers :rtype: ~azure.ai.language.questionanswering.models.TextAnswers @@ -330,15 +327,12 @@ def query_text( :rtype: ~azure.ai.language.questionanswering.models.TextAnswers :raises: ~azure.core.exceptions.HttpResponseError """ - if args: - options = args[0] - else: - options = _models.TextQueryOptions( - question=kwargs.pop("question"), - records=kwargs.pop("records"), - language=kwargs.pop("language", None), - string_index_type=kwargs.pop("string_index_type", "TextElements_v8") - ) + options = _get_positional_body(*args, **kwargs) or _models.TextQueryOptions( + question=kwargs.pop("question"), + records=kwargs.pop("records"), + language=kwargs.pop("language", None), + string_index_type=kwargs.pop("string_index_type", "TextElements_v8") + ) try: options['records'] = _validate_text_records(options['records']) except TypeError: diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase.py index dd279adccf87..ae26848deb0a 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase.py @@ -4,7 +4,7 @@ # Licensed under the MIT License. # ------------------------------------ import os - +import pytest from azure.core.exceptions import HttpResponseError, ClientAuthenticationError from azure.core.credentials import AzureKeyCredential @@ -349,4 +349,11 @@ def test_query_knowledgebase_python_dict(self, qna_account, qna_key, qna_project deployment_name='test' ) - assert len(output.answers) == 1 \ No newline at end of file + assert len(output.answers) == 1 + + def test_query_knowledge_base_overload_positional_and_kwarg(self): + with QuestionAnsweringClient("http://fake.com", AzureKeyCredential("123")) as client: + with pytest.raises(TypeError): + client.query_knowledge_base("positional_one", "positional_two") + with pytest.raises(TypeError): + client.query_knowledge_base("positional_options_bag", options="options bag by name") diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase_async.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase_async.py index fda1d6cb265d..e7e8e37bd377 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase_async.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase_async.py @@ -348,3 +348,10 @@ async def test_query_knowledgebase_python_dict(self, qna_account, qna_key, qna_p ) assert len(output.answers) == 1 + + async def test_query_knowledge_base_overload_positional_and_kwarg(self): + async with QuestionAnsweringClient("http://fake.com", AzureKeyCredential("123")) as client: + with pytest.raises(TypeError): + await client.query_knowledge_base("positional_one", "positional_two") + with pytest.raises(TypeError): + await client.query_knowledge_base("positional_options_bag", options="options bag by name") diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_text.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_text.py index db55ce2867c1..148d594622c6 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_text.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_text.py @@ -180,3 +180,11 @@ def test_query_text_overload(self, qna_account, qna_key): confident_answers = [a for a in output.answers if a.confidence_score > 0.9] assert len(confident_answers) == 2 assert confident_answers[0].answer_span.text == "two to four hours" + + def test_query_text_overload_positional_and_kwarg(self): + with QuestionAnsweringClient("http://fake.com", AzureKeyCredential("123")) as client: + with pytest.raises(TypeError): + client.query_text("positional_one", "positional_two") + with pytest.raises(TypeError): + client.query_text("positional_options_bag", options="options bag by name") + \ No newline at end of file diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_text_async.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_text_async.py index a4fb8d110dfc..d252004872c9 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_text_async.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_text_async.py @@ -181,3 +181,10 @@ async def test_query_text_overload(self, qna_account, qna_key): confident_answers = [a for a in output.answers if a.confidence_score > 0.9] assert len(confident_answers) == 2 assert confident_answers[0].answer_span.text == "two to four hours" + + async def test_query_text_overload_positional_and_kwarg(self): + async with QuestionAnsweringClient("http://fake.com", AzureKeyCredential("123")) as client: + with pytest.raises(TypeError): + await client.query_text("positional_one", "positional_two") + with pytest.raises(TypeError): + await client.query_text("positional_options_bag", options="options bag by name") From fb4a847ba5412edeacdfa876b287b2bf8e6baf39 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Wed, 29 Sep 2021 16:57:40 -0400 Subject: [PATCH 04/20] rename options bags to method name + options --- .../README.md | 31 +- .../aio/operations/_operations.py | 10 +- .../questionanswering/models/__init__.py | 12 +- .../questionanswering/models/_models.py | 284 ++++++++-------- .../questionanswering/models/_models_py3.py | 320 +++++++++--------- .../operations/_operations.py | 12 +- .../async_samples/sample_chat_async.py | 4 +- .../sample_query_knowledgebase_async.py | 2 +- .../samples/sample_chat.py | 4 +- .../samples/sample_query_knowledgebase.py | 2 +- .../swagger/README.md | 20 ++ .../tests/test_query_knowledgebase.py | 12 +- .../tests/test_query_knowledgebase_async.py | 10 +- 13 files changed, 375 insertions(+), 348 deletions(-) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/README.md b/sdk/cognitivelanguage/azure-ai-language-questionanswering/README.md index 06fb24064963..183d65726684 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/README.md +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/README.md @@ -10,9 +10,9 @@ Question Answering is a cloud-based API service that lets you create a conversat ### Prerequisites -* Python 2.7, or 3.6 or later is required to use this package. -* An [Azure subscription][azure_subscription] -* An existing Question Answering resource +- Python 2.7, or 3.6 or later is required to use this package. +- An [Azure subscription][azure_subscription] +- An existing Question Answering resource > Note: the new unified Cognitive Language Services are not currently available for deployment. @@ -56,7 +56,7 @@ client = QuestionAnsweringClient(endpoint, credential) ### QuestionAnsweringClient -The [QuestionAnsweringClient][questionanswering_client_class] is the primary interface for asking questions using a knowledge base with your own information, or text input using pre-trained models. +The [QuestionAnsweringClient][questionanswering_client_class] is the primary interface for asking questions using a knowledge base with your own information, or text input using pre-trained models. For asynchronous operations, an async `QuestionAnsweringClient` is in the `azure.ai.language.questionanswering.aio` namespace. ## Examples @@ -64,6 +64,7 @@ For asynchronous operations, an async `QuestionAnsweringClient` is in the `azure The `azure-ai-language-questionanswering` client library provides both synchronous and asynchronous APIs. The following examples show common scenarios using the `client` [created above](#create-questionansweringclient). + - [Ask a question](#ask-a-question) - [Ask a follow-up question](#ask-a-follow-up-question) - [Asynchronous operations](#asynchronous-operations) @@ -75,7 +76,7 @@ The only input required to ask a question using a knowledge base is just the que ```python from azure.ai.language.questionanswering import models as qna -params = qna.KnowledgeBaseQueryOptions( +params = qna.QueryKnowledgeBaseOptions( question="How long should my Surface battery last?" ) @@ -89,14 +90,14 @@ for candidate in output.answers: ``` -You can set additional properties on `KnowledgeBaseQueryOptions` to limit the number of answers, specify a minimum confidence score, and more. +You can set additional properties on `QueryKnowledgeBaseOptions` to limit the number of answers, specify a minimum confidence score, and more. ### Ask a follow-up question If your knowledge base is configured for [chit-chat][questionanswering_docs_chat], the answers from the knowledge base may include suggested [prompts for follow-up questions][questionanswering_refdocs_prompts] to initiate a conversation. You can ask a follow-up question by providing the ID of your chosen answer as the context for the continued conversation: ```python -params = qna.models.KnowledgeBaseQueryOptions( +params = qna.models.QueryKnowledgeBaseOptions( question="How long should charging take?" context=qna.models.KnowledgeBaseAnswerRequestContext( previous_qna_id=previous_answer.id @@ -112,9 +113,11 @@ for candidate in output.answers: print("Source: {}".format(candidate.source)) ``` + ### Asynchronous operations The above examples can also be run asynchronously using the client in the `aio` namespace: + ```python from azure.core.credentials import AzureKeyCredential from azure.ai.language.questionanswering.aio import QuestionAnsweringClient @@ -122,7 +125,7 @@ from azure.ai.language.questionanswering import models as qna client = QuestionAnsweringClient(endpoint, credential) -params = qna.KnowledgeBaseQueryOptions( +params = qna.QueryKnowledgeBaseOptions( question="How long should my Surface battery last?" ) @@ -133,11 +136,13 @@ output = await client.query_knowledgebase( ``` ## Optional Configuration + Optional keyword arguments can be passed in at the client and per-operation level. The azure-core [reference documentation][azure_core_ref_docs] describes available configurations for retries, logging, transport protocols, and more. ## Troubleshooting ### General + Azure QuestionAnswering clients raise exceptions defined in [Azure Core][azure_core_readme]. When you interact with the Cognitive Language Services Question Answering client library using the Python SDK, errors returned by the service correspond to the same HTTP status codes returned for [REST API][questionanswering_rest_docs] requests. @@ -156,6 +161,7 @@ except HttpResponseError as error: ``` ### Logging + This library uses the standard [logging][python_logging] library for logging. Basic information about HTTP sessions (URLs, headers, etc.) is logged at INFO @@ -168,9 +174,9 @@ See full SDK logging documentation with examples [here][sdk_logging_docs]. ## Next steps -* View our [samples][questionanswering_samples]. -* Read about the different [features][questionanswering_docs_features] of the Question Answering service. -* Try our service [demos][questionanswering_docs_demos]. +- View our [samples][questionanswering_samples]. +- Read about the different [features][questionanswering_docs_features] of the Question Answering service. +- Try our service [demos][questionanswering_docs_demos]. ## Contributing @@ -183,6 +189,7 @@ When you submit a pull request, a CLA-bot will automatically determine whether y This project has adopted the [Microsoft Open Source Code of Conduct][code_of_conduct]. For more information see the [Code of Conduct FAQ][coc_faq] or contact [opencode@microsoft.com][coc_contact] with any additional questions or comments. + [azure_cli]: https://docs.microsoft.com/cli/azure/ [azure_portal]: https://portal.azure.com/ [azure_subscription]: https://azure.microsoft.com/free/ @@ -196,7 +203,7 @@ This project has adopted the [Microsoft Open Source Code of Conduct][code_of_con [sdk_logging_docs]: https://docs.microsoft.com/azure/developer/python/azure-sdk-logging [azure_core_ref_docs]: https://azuresdkdocs.blob.core.windows.net/$web/python/azure-core/latest/azure.core.html [azure_core_readme]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/core/azure-core/README.md -[pip_link]:https://pypi.org/project/pip/ +[pip_link]: https://pypi.org/project/pip/ [questionanswering_client_class]: https://azuresdkdocs.blob.core.windows.net/$web/python/azure-ai-language-questionanswering/1.0.0b1/azure.ai.language.questionanswering.html#azure.ai.language.questionanswering.QuestionAnsweringClient [questionanswering_refdocs_prompts]: https://azuresdkdocs.blob.core.windows.net/$web/python/azure-ai-language-questionanswering/1.0.0b1/azure.ai.language.questionanswering.models.html#azure.ai.language.questionanswering.models.KnowledgeBaseAnswerDialog [questionanswering_client_src]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/cognitivelanguage/azure-ai-language-questionanswering/ diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py index 586897f0ead3..75cfdf276c37 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py @@ -32,7 +32,7 @@ class QuestionAnsweringClientOperationsMixin: @overload async def query_knowledge_base( self, - options: "_models.KnowledgeBaseQueryOptions", + options: "_models.QueryKnowledgeBaseOptions", *, project_name: str, deployment_name: str, @@ -42,7 +42,7 @@ async def query_knowledge_base( :param options: Positional-only post body of the request. :type options: - ~azure.ai.language.questionanswering.models.KnowledgeBaseQueryOptions + ~azure.ai.language.questionanswering.models.QueryKnowledgeBaseOptions :keyword project_name: The name of the project to use. :paramtype project_name: str :keyword deployment_name: The name of the specific deployment of the project to use. @@ -115,7 +115,7 @@ async def query_knowledge_base( :param options: Post body of the request. Provide either `options`, OR individual keyword arguments. If both are provided, only the options object will be used. :type options: - ~azure.ai.language.questionanswering.models.KnowledgeBaseQueryOptions + ~azure.ai.language.questionanswering.models.QueryKnowledgeBaseOptions :keyword project_name: The name of the project to use. :paramtype project_name: str :keyword deployment_name: The name of the specific deployment of the project to use. @@ -146,7 +146,7 @@ async def query_knowledge_base( :rtype: ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswers :raises: ~azure.core.exceptions.HttpResponseError """ - options = _get_positional_body(*args, **kwargs) or _models.KnowledgeBaseQueryOptions( + options = _get_positional_body(*args, **kwargs) or _models.QueryKnowledgeBaseOptions( qna_id=kwargs.pop("qna_id", None), question=kwargs.pop("question", None), top=kwargs.pop("top", None), @@ -165,7 +165,7 @@ async def query_knowledge_base( project_name = kwargs.pop("project_name") # type: str deployment_name = kwargs.pop("deployment_name") # type: str - json = self._serialize.body(options, "KnowledgeBaseQueryOptions") + json = self._serialize.body(options, "QueryKnowledgeBaseOptions") request = build_query_knowledge_base_request( content_type=content_type, diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/__init__.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/__init__.py index f6b186f02536..cad86768af66 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/__init__.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/__init__.py @@ -17,13 +17,13 @@ from ._models_py3 import KnowledgeBaseAnswerPrompt from ._models_py3 import KnowledgeBaseAnswerRequestContext from ._models_py3 import KnowledgeBaseAnswers - from ._models_py3 import KnowledgeBaseQueryOptions from ._models_py3 import MetadataFilter from ._models_py3 import MetadataRecord from ._models_py3 import QueryFilters + from ._models_py3 import QueryKnowledgeBaseOptions + from ._models_py3 import QueryTextOptions from ._models_py3 import TextAnswer from ._models_py3 import TextAnswers - from ._models_py3 import TextQueryOptions from ._models_py3 import TextRecord except (SyntaxError, ImportError): from ._models import AnswerSpan # type: ignore @@ -36,13 +36,13 @@ from ._models import KnowledgeBaseAnswerPrompt # type: ignore from ._models import KnowledgeBaseAnswerRequestContext # type: ignore from ._models import KnowledgeBaseAnswers # type: ignore - from ._models import KnowledgeBaseQueryOptions # type: ignore from ._models import MetadataFilter # type: ignore from ._models import MetadataRecord # type: ignore from ._models import QueryFilters # type: ignore + from ._models import QueryKnowledgeBaseOptions # type: ignore + from ._models import QueryTextOptions # type: ignore from ._models import TextAnswer # type: ignore from ._models import TextAnswers # type: ignore - from ._models import TextQueryOptions # type: ignore from ._models import TextRecord # type: ignore from ._question_answering_client_enums import ( @@ -64,13 +64,13 @@ "KnowledgeBaseAnswerPrompt", "KnowledgeBaseAnswerRequestContext", "KnowledgeBaseAnswers", - "KnowledgeBaseQueryOptions", "MetadataFilter", "MetadataRecord", "QueryFilters", + "QueryKnowledgeBaseOptions", + "QueryTextOptions", "TextAnswer", "TextAnswers", - "TextQueryOptions", "TextRecord", "ErrorCode", "InnerErrorCode", diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models.py index 2ca14b4f2b6c..1c38b963b5c3 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models.py @@ -417,92 +417,6 @@ def __init__(self, **kwargs): self.answers = kwargs.get("answers", None) -class KnowledgeBaseQueryOptions(msrest.serialization.Model): - """The question parameters to answer using a knowledge base. - - :ivar qna_id: Exact QnA ID to fetch from the knowledge base, this field takes priority over - question. - :vartype qna_id: int - :ivar question: User question to query against the knowledge base. - :vartype question: str - :ivar top: Max number of answers to be returned for the question. - :vartype top: int - :ivar user_id: Unique identifier for the user. - :vartype user_id: str - :ivar confidence_score_threshold: Minimum threshold score for answers, value ranges from 0 to - 1. - :vartype confidence_score_threshold: float - :ivar context: Context object with previous QnA's information. - :vartype context: ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswerRequestContext - :ivar ranker_type: (Optional) Set to 'QuestionOnly' for using a question only Ranker. Possible - values include: "Default", "QuestionOnly". - :vartype ranker_type: str or ~azure.ai.language.questionanswering.models.RankerType - :ivar filters: Filter QnAs based on give metadata list and knowledge base source names. - :vartype filters: ~azure.ai.language.questionanswering.models.QueryFilters - :ivar answer_span_request: To configure Answer span prediction feature. - :vartype answer_span_request: ~azure.ai.language.questionanswering.models.AnswerSpanRequest - :ivar include_unstructured_sources: (Optional) Flag to enable Query over Unstructured Sources. - :vartype include_unstructured_sources: bool - """ - - _validation = { - "confidence_score_threshold": {"maximum": 1, "minimum": 0}, - } - - _attribute_map = { - "qna_id": {"key": "qnaId", "type": "int"}, - "question": {"key": "question", "type": "str"}, - "top": {"key": "top", "type": "int"}, - "user_id": {"key": "userId", "type": "str"}, - "confidence_score_threshold": {"key": "confidenceScoreThreshold", "type": "float"}, - "context": {"key": "context", "type": "KnowledgeBaseAnswerRequestContext"}, - "ranker_type": {"key": "rankerType", "type": "str"}, - "filters": {"key": "filters", "type": "QueryFilters"}, - "answer_span_request": {"key": "answerSpanRequest", "type": "AnswerSpanRequest"}, - "include_unstructured_sources": {"key": "includeUnstructuredSources", "type": "bool"}, - } - - def __init__(self, **kwargs): - """ - :keyword qna_id: Exact QnA ID to fetch from the knowledge base, this field takes priority over - question. - :paramtype qna_id: int - :keyword question: User question to query against the knowledge base. - :paramtype question: str - :keyword top: Max number of answers to be returned for the question. - :paramtype top: int - :keyword user_id: Unique identifier for the user. - :paramtype user_id: str - :keyword confidence_score_threshold: Minimum threshold score for answers, value ranges from 0 - to 1. - :paramtype confidence_score_threshold: float - :keyword context: Context object with previous QnA's information. - :paramtype context: - ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswerRequestContext - :keyword ranker_type: (Optional) Set to 'QuestionOnly' for using a question only Ranker. - Possible values include: "Default", "QuestionOnly". - :paramtype ranker_type: str or ~azure.ai.language.questionanswering.models.RankerType - :keyword filters: Filter QnAs based on give metadata list and knowledge base source names. - :paramtype filters: ~azure.ai.language.questionanswering.models.QueryFilters - :keyword answer_span_request: To configure Answer span prediction feature. - :paramtype answer_span_request: ~azure.ai.language.questionanswering.models.AnswerSpanRequest - :keyword include_unstructured_sources: (Optional) Flag to enable Query over Unstructured - Sources. - :paramtype include_unstructured_sources: bool - """ - super(KnowledgeBaseQueryOptions, 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.confidence_score_threshold = kwargs.get("confidence_score_threshold", None) - self.context = kwargs.get("context", None) - self.ranker_type = kwargs.get("ranker_type", None) - self.filters = kwargs.get("filters", None) - self.answer_span_request = kwargs.get("answer_span_request", None) - self.include_unstructured_sources = kwargs.get("include_unstructured_sources", None) - - class MetadataFilter(msrest.serialization.Model): """Find QnAs that are associated with the given list of metadata. @@ -604,6 +518,148 @@ def __init__(self, **kwargs): self.logical_operation = kwargs.get("logical_operation", None) +class QueryKnowledgeBaseOptions(msrest.serialization.Model): + """The question parameters to answer using a knowledge base. + + :ivar qna_id: Exact QnA ID to fetch from the knowledge base, this field takes priority over + question. + :vartype qna_id: int + :ivar question: User question to query against the knowledge base. + :vartype question: str + :ivar top: Max number of answers to be returned for the question. + :vartype top: int + :ivar user_id: Unique identifier for the user. + :vartype user_id: str + :ivar confidence_score_threshold: Minimum threshold score for answers, value ranges from 0 to + 1. + :vartype confidence_score_threshold: float + :ivar context: Context object with previous QnA's information. + :vartype context: ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswerRequestContext + :ivar ranker_type: (Optional) Set to 'QuestionOnly' for using a question only Ranker. Possible + values include: "Default", "QuestionOnly". + :vartype ranker_type: str or ~azure.ai.language.questionanswering.models.RankerType + :ivar filters: Filter QnAs based on give metadata list and knowledge base source names. + :vartype filters: ~azure.ai.language.questionanswering.models.QueryFilters + :ivar answer_span_request: To configure Answer span prediction feature. + :vartype answer_span_request: ~azure.ai.language.questionanswering.models.AnswerSpanRequest + :ivar include_unstructured_sources: (Optional) Flag to enable Query over Unstructured Sources. + :vartype include_unstructured_sources: bool + """ + + _validation = { + "confidence_score_threshold": {"maximum": 1, "minimum": 0}, + } + + _attribute_map = { + "qna_id": {"key": "qnaId", "type": "int"}, + "question": {"key": "question", "type": "str"}, + "top": {"key": "top", "type": "int"}, + "user_id": {"key": "userId", "type": "str"}, + "confidence_score_threshold": {"key": "confidenceScoreThreshold", "type": "float"}, + "context": {"key": "context", "type": "KnowledgeBaseAnswerRequestContext"}, + "ranker_type": {"key": "rankerType", "type": "str"}, + "filters": {"key": "filters", "type": "QueryFilters"}, + "answer_span_request": {"key": "answerSpanRequest", "type": "AnswerSpanRequest"}, + "include_unstructured_sources": {"key": "includeUnstructuredSources", "type": "bool"}, + } + + def __init__(self, **kwargs): + """ + :keyword qna_id: Exact QnA ID to fetch from the knowledge base, this field takes priority over + question. + :paramtype qna_id: int + :keyword question: User question to query against the knowledge base. + :paramtype question: str + :keyword top: Max number of answers to be returned for the question. + :paramtype top: int + :keyword user_id: Unique identifier for the user. + :paramtype user_id: str + :keyword confidence_score_threshold: Minimum threshold score for answers, value ranges from 0 + to 1. + :paramtype confidence_score_threshold: float + :keyword context: Context object with previous QnA's information. + :paramtype context: + ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswerRequestContext + :keyword ranker_type: (Optional) Set to 'QuestionOnly' for using a question only Ranker. + Possible values include: "Default", "QuestionOnly". + :paramtype ranker_type: str or ~azure.ai.language.questionanswering.models.RankerType + :keyword filters: Filter QnAs based on give metadata list and knowledge base source names. + :paramtype filters: ~azure.ai.language.questionanswering.models.QueryFilters + :keyword answer_span_request: To configure Answer span prediction feature. + :paramtype answer_span_request: ~azure.ai.language.questionanswering.models.AnswerSpanRequest + :keyword include_unstructured_sources: (Optional) Flag to enable Query over Unstructured + Sources. + :paramtype include_unstructured_sources: bool + """ + super(QueryKnowledgeBaseOptions, 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.confidence_score_threshold = kwargs.get("confidence_score_threshold", None) + self.context = kwargs.get("context", None) + self.ranker_type = kwargs.get("ranker_type", None) + self.filters = kwargs.get("filters", None) + self.answer_span_request = kwargs.get("answer_span_request", None) + self.include_unstructured_sources = kwargs.get("include_unstructured_sources", None) + + +class QueryTextOptions(msrest.serialization.Model): + """The question and text record parameters to answer. + + All required parameters must be populated in order to send to Azure. + + :ivar question: Required. User question to query against the given text records. + :vartype question: str + :ivar records: Required. Text records to be searched for given question. + :vartype records: list[~azure.ai.language.questionanswering.models.TextRecord] + :ivar language: Language of the text records. This is BCP-47 representation of a language. For + example, use "en" for English; "es" for Spanish etc. If not set, use "en" for English as + default. + :vartype language: str + :ivar string_index_type: Specifies the method used to interpret string offsets. Defaults to + Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see + https://aka.ms/text-analytics-offsets. Possible values include: "TextElements_v8", + "UnicodeCodePoint", "Utf16CodeUnit". Default value: "TextElements_v8". + :vartype string_index_type: str or ~azure.ai.language.questionanswering.models.StringIndexType + """ + + _validation = { + "question": {"required": True}, + "records": {"required": True}, + } + + _attribute_map = { + "question": {"key": "question", "type": "str"}, + "records": {"key": "records", "type": "[TextRecord]"}, + "language": {"key": "language", "type": "str"}, + "string_index_type": {"key": "stringIndexType", "type": "str"}, + } + + def __init__(self, **kwargs): + """ + :keyword question: Required. User question to query against the given text records. + :paramtype question: str + :keyword records: Required. Text records to be searched for given question. + :paramtype records: list[~azure.ai.language.questionanswering.models.TextRecord] + :keyword language: Language of the text records. This is BCP-47 representation of a language. + For example, use "en" for English; "es" for Spanish etc. If not set, use "en" for English as + default. + :paramtype language: str + :keyword string_index_type: Specifies the method used to interpret string offsets. Defaults to + Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see + https://aka.ms/text-analytics-offsets. Possible values include: "TextElements_v8", + "UnicodeCodePoint", "Utf16CodeUnit". Default value: "TextElements_v8". + :paramtype string_index_type: str or + ~azure.ai.language.questionanswering.models.StringIndexType + """ + super(QueryTextOptions, self).__init__(**kwargs) + self.question = kwargs["question"] + self.records = kwargs["records"] + self.language = kwargs.get("language", None) + self.string_index_type = kwargs.get("string_index_type", "TextElements_v8") + + class TextAnswer(msrest.serialization.Model): """Represents answer result. @@ -678,62 +734,6 @@ def __init__(self, **kwargs): self.answers = kwargs.get("answers", None) -class TextQueryOptions(msrest.serialization.Model): - """The question and text record parameters to answer. - - All required parameters must be populated in order to send to Azure. - - :ivar question: Required. User question to query against the given text records. - :vartype question: str - :ivar records: Required. Text records to be searched for given question. - :vartype records: list[~azure.ai.language.questionanswering.models.TextRecord] - :ivar language: Language of the text records. This is BCP-47 representation of a language. For - example, use "en" for English; "es" for Spanish etc. If not set, use "en" for English as - default. - :vartype language: str - :ivar string_index_type: Specifies the method used to interpret string offsets. Defaults to - Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see - https://aka.ms/text-analytics-offsets. Possible values include: "TextElements_v8", - "UnicodeCodePoint", "Utf16CodeUnit". Default value: "TextElements_v8". - :vartype string_index_type: str or ~azure.ai.language.questionanswering.models.StringIndexType - """ - - _validation = { - "question": {"required": True}, - "records": {"required": True}, - } - - _attribute_map = { - "question": {"key": "question", "type": "str"}, - "records": {"key": "records", "type": "[TextRecord]"}, - "language": {"key": "language", "type": "str"}, - "string_index_type": {"key": "stringIndexType", "type": "str"}, - } - - def __init__(self, **kwargs): - """ - :keyword question: Required. User question to query against the given text records. - :paramtype question: str - :keyword records: Required. Text records to be searched for given question. - :paramtype records: list[~azure.ai.language.questionanswering.models.TextRecord] - :keyword language: Language of the text records. This is BCP-47 representation of a language. - For example, use "en" for English; "es" for Spanish etc. If not set, use "en" for English as - default. - :paramtype language: str - :keyword string_index_type: Specifies the method used to interpret string offsets. Defaults to - Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see - https://aka.ms/text-analytics-offsets. Possible values include: "TextElements_v8", - "UnicodeCodePoint", "Utf16CodeUnit". Default value: "TextElements_v8". - :paramtype string_index_type: str or - ~azure.ai.language.questionanswering.models.StringIndexType - """ - super(TextQueryOptions, self).__init__(**kwargs) - self.question = kwargs["question"] - self.records = kwargs["records"] - self.language = kwargs.get("language", None) - self.string_index_type = kwargs.get("string_index_type", "TextElements_v8") - - class TextRecord(msrest.serialization.Model): """Represent input text record to be queried. diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models_py3.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models_py3.py index 3602c5d022f8..3bb11a5eb2a3 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models_py3.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models_py3.py @@ -479,7 +479,121 @@ def __init__(self, *, answers: Optional[List["KnowledgeBaseAnswer"]] = None, **k self.answers = answers -class KnowledgeBaseQueryOptions(msrest.serialization.Model): +class MetadataFilter(msrest.serialization.Model): + """Find QnAs that are associated with the given list of metadata. + + :ivar metadata: + :vartype metadata: list[~azure.ai.language.questionanswering.models.MetadataRecord] + :ivar logical_operation: Operation used to join metadata filters. Possible values include: + "AND", "OR". + :vartype logical_operation: str or + ~azure.ai.language.questionanswering.models.LogicalOperationKind + """ + + _attribute_map = { + "metadata": {"key": "metadata", "type": "[MetadataRecord]"}, + "logical_operation": {"key": "logicalOperation", "type": "str"}, + } + + def __init__( + self, + *, + metadata: Optional[List["MetadataRecord"]] = None, + logical_operation: Optional[Union[str, "LogicalOperationKind"]] = None, + **kwargs + ): + """ + :keyword metadata: + :paramtype metadata: list[~azure.ai.language.questionanswering.models.MetadataRecord] + :keyword logical_operation: Operation used to join metadata filters. Possible values include: + "AND", "OR". + :paramtype logical_operation: str or + ~azure.ai.language.questionanswering.models.LogicalOperationKind + """ + super(MetadataFilter, self).__init__(**kwargs) + self.metadata = metadata + self.logical_operation = logical_operation + + +class MetadataRecord(msrest.serialization.Model): + """Object to provide the key value pair for each metadata. + + All required parameters must be populated in order to send to Azure. + + :ivar key: Required. Metadata Key from Metadata dictionary used in the QnA. + :vartype key: str + :ivar value: Required. Metadata Value from Metadata dictionary used in the QnA. + :vartype value: str + """ + + _validation = { + "key": {"required": True}, + "value": {"required": True}, + } + + _attribute_map = { + "key": {"key": "key", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__(self, *, key: str, value: str, **kwargs): + """ + :keyword key: Required. Metadata Key from Metadata dictionary used in the QnA. + :paramtype key: str + :keyword value: Required. Metadata Value from Metadata dictionary used in the QnA. + :paramtype value: str + """ + super(MetadataRecord, self).__init__(**kwargs) + self.key = key + self.value = value + + +class QueryFilters(msrest.serialization.Model): + """filters over knowledge base. + + :ivar metadata_filter: Find QnAs that are associated with the given list of metadata. + :vartype metadata_filter: ~azure.ai.language.questionanswering.models.MetadataFilter + :ivar source_filter: Find QnAs that are associated with the given list of sources in knowledge + base. + :vartype source_filter: list[str] + :ivar logical_operation: Logical operation used to join metadata filters with source filters. + Possible values include: "AND", "OR". + :vartype logical_operation: str or + ~azure.ai.language.questionanswering.models.LogicalOperationKind + """ + + _attribute_map = { + "metadata_filter": {"key": "metadataFilter", "type": "MetadataFilter"}, + "source_filter": {"key": "sourceFilter", "type": "[str]"}, + "logical_operation": {"key": "logicalOperation", "type": "str"}, + } + + def __init__( + self, + *, + metadata_filter: Optional["MetadataFilter"] = None, + source_filter: Optional[List[str]] = None, + logical_operation: Optional[Union[str, "LogicalOperationKind"]] = None, + **kwargs + ): + """ + :keyword metadata_filter: Find QnAs that are associated with the given list of metadata. + :paramtype metadata_filter: ~azure.ai.language.questionanswering.models.MetadataFilter + :keyword source_filter: Find QnAs that are associated with the given list of sources in + knowledge base. + :paramtype source_filter: list[str] + :keyword logical_operation: Logical operation used to join metadata filters with source + filters. Possible values include: "AND", "OR". + :paramtype logical_operation: str or + ~azure.ai.language.questionanswering.models.LogicalOperationKind + """ + super(QueryFilters, self).__init__(**kwargs) + self.metadata_filter = metadata_filter + self.source_filter = source_filter + self.logical_operation = logical_operation + + +class QueryKnowledgeBaseOptions(msrest.serialization.Model): """The question parameters to answer using a knowledge base. :ivar qna_id: Exact QnA ID to fetch from the knowledge base, this field takes priority over @@ -566,7 +680,7 @@ def __init__( Sources. :paramtype include_unstructured_sources: bool """ - super(KnowledgeBaseQueryOptions, self).__init__(**kwargs) + super(QueryKnowledgeBaseOptions, self).__init__(**kwargs) self.qna_id = qna_id self.question = question self.top = top @@ -579,118 +693,68 @@ def __init__( self.include_unstructured_sources = include_unstructured_sources -class MetadataFilter(msrest.serialization.Model): - """Find QnAs that are associated with the given list of metadata. - - :ivar metadata: - :vartype metadata: list[~azure.ai.language.questionanswering.models.MetadataRecord] - :ivar logical_operation: Operation used to join metadata filters. Possible values include: - "AND", "OR". - :vartype logical_operation: str or - ~azure.ai.language.questionanswering.models.LogicalOperationKind - """ - - _attribute_map = { - "metadata": {"key": "metadata", "type": "[MetadataRecord]"}, - "logical_operation": {"key": "logicalOperation", "type": "str"}, - } - - def __init__( - self, - *, - metadata: Optional[List["MetadataRecord"]] = None, - logical_operation: Optional[Union[str, "LogicalOperationKind"]] = None, - **kwargs - ): - """ - :keyword metadata: - :paramtype metadata: list[~azure.ai.language.questionanswering.models.MetadataRecord] - :keyword logical_operation: Operation used to join metadata filters. Possible values include: - "AND", "OR". - :paramtype logical_operation: str or - ~azure.ai.language.questionanswering.models.LogicalOperationKind - """ - super(MetadataFilter, self).__init__(**kwargs) - self.metadata = metadata - self.logical_operation = logical_operation - - -class MetadataRecord(msrest.serialization.Model): - """Object to provide the key value pair for each metadata. +class QueryTextOptions(msrest.serialization.Model): + """The question and text record parameters to answer. All required parameters must be populated in order to send to Azure. - :ivar key: Required. Metadata Key from Metadata dictionary used in the QnA. - :vartype key: str - :ivar value: Required. Metadata Value from Metadata dictionary used in the QnA. - :vartype value: str + :ivar question: Required. User question to query against the given text records. + :vartype question: str + :ivar records: Required. Text records to be searched for given question. + :vartype records: list[~azure.ai.language.questionanswering.models.TextRecord] + :ivar language: Language of the text records. This is BCP-47 representation of a language. For + example, use "en" for English; "es" for Spanish etc. If not set, use "en" for English as + default. + :vartype language: str + :ivar string_index_type: Specifies the method used to interpret string offsets. Defaults to + Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see + https://aka.ms/text-analytics-offsets. Possible values include: "TextElements_v8", + "UnicodeCodePoint", "Utf16CodeUnit". Default value: "TextElements_v8". + :vartype string_index_type: str or ~azure.ai.language.questionanswering.models.StringIndexType """ _validation = { - "key": {"required": True}, - "value": {"required": True}, - } - - _attribute_map = { - "key": {"key": "key", "type": "str"}, - "value": {"key": "value", "type": "str"}, + "question": {"required": True}, + "records": {"required": True}, } - def __init__(self, *, key: str, value: str, **kwargs): - """ - :keyword key: Required. Metadata Key from Metadata dictionary used in the QnA. - :paramtype key: str - :keyword value: Required. Metadata Value from Metadata dictionary used in the QnA. - :paramtype value: str - """ - super(MetadataRecord, self).__init__(**kwargs) - self.key = key - self.value = value - - -class QueryFilters(msrest.serialization.Model): - """filters over knowledge base. - - :ivar metadata_filter: Find QnAs that are associated with the given list of metadata. - :vartype metadata_filter: ~azure.ai.language.questionanswering.models.MetadataFilter - :ivar source_filter: Find QnAs that are associated with the given list of sources in knowledge - base. - :vartype source_filter: list[str] - :ivar logical_operation: Logical operation used to join metadata filters with source filters. - Possible values include: "AND", "OR". - :vartype logical_operation: str or - ~azure.ai.language.questionanswering.models.LogicalOperationKind - """ - _attribute_map = { - "metadata_filter": {"key": "metadataFilter", "type": "MetadataFilter"}, - "source_filter": {"key": "sourceFilter", "type": "[str]"}, - "logical_operation": {"key": "logicalOperation", "type": "str"}, + "question": {"key": "question", "type": "str"}, + "records": {"key": "records", "type": "[TextRecord]"}, + "language": {"key": "language", "type": "str"}, + "string_index_type": {"key": "stringIndexType", "type": "str"}, } def __init__( self, *, - metadata_filter: Optional["MetadataFilter"] = None, - source_filter: Optional[List[str]] = None, - logical_operation: Optional[Union[str, "LogicalOperationKind"]] = None, + question: str, + records: List["TextRecord"], + language: Optional[str] = None, + string_index_type: Optional[Union[str, "StringIndexType"]] = "TextElements_v8", **kwargs ): """ - :keyword metadata_filter: Find QnAs that are associated with the given list of metadata. - :paramtype metadata_filter: ~azure.ai.language.questionanswering.models.MetadataFilter - :keyword source_filter: Find QnAs that are associated with the given list of sources in - knowledge base. - :paramtype source_filter: list[str] - :keyword logical_operation: Logical operation used to join metadata filters with source - filters. Possible values include: "AND", "OR". - :paramtype logical_operation: str or - ~azure.ai.language.questionanswering.models.LogicalOperationKind + :keyword question: Required. User question to query against the given text records. + :paramtype question: str + :keyword records: Required. Text records to be searched for given question. + :paramtype records: list[~azure.ai.language.questionanswering.models.TextRecord] + :keyword language: Language of the text records. This is BCP-47 representation of a language. + For example, use "en" for English; "es" for Spanish etc. If not set, use "en" for English as + default. + :paramtype language: str + :keyword string_index_type: Specifies the method used to interpret string offsets. Defaults to + Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see + https://aka.ms/text-analytics-offsets. Possible values include: "TextElements_v8", + "UnicodeCodePoint", "Utf16CodeUnit". Default value: "TextElements_v8". + :paramtype string_index_type: str or + ~azure.ai.language.questionanswering.models.StringIndexType """ - super(QueryFilters, self).__init__(**kwargs) - self.metadata_filter = metadata_filter - self.source_filter = source_filter - self.logical_operation = logical_operation + super(QueryTextOptions, self).__init__(**kwargs) + self.question = question + self.records = records + self.language = language + self.string_index_type = string_index_type class TextAnswer(msrest.serialization.Model): @@ -777,70 +841,6 @@ def __init__(self, *, answers: Optional[List["TextAnswer"]] = None, **kwargs): self.answers = answers -class TextQueryOptions(msrest.serialization.Model): - """The question and text record parameters to answer. - - All required parameters must be populated in order to send to Azure. - - :ivar question: Required. User question to query against the given text records. - :vartype question: str - :ivar records: Required. Text records to be searched for given question. - :vartype records: list[~azure.ai.language.questionanswering.models.TextRecord] - :ivar language: Language of the text records. This is BCP-47 representation of a language. For - example, use "en" for English; "es" for Spanish etc. If not set, use "en" for English as - default. - :vartype language: str - :ivar string_index_type: Specifies the method used to interpret string offsets. Defaults to - Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see - https://aka.ms/text-analytics-offsets. Possible values include: "TextElements_v8", - "UnicodeCodePoint", "Utf16CodeUnit". Default value: "TextElements_v8". - :vartype string_index_type: str or ~azure.ai.language.questionanswering.models.StringIndexType - """ - - _validation = { - "question": {"required": True}, - "records": {"required": True}, - } - - _attribute_map = { - "question": {"key": "question", "type": "str"}, - "records": {"key": "records", "type": "[TextRecord]"}, - "language": {"key": "language", "type": "str"}, - "string_index_type": {"key": "stringIndexType", "type": "str"}, - } - - def __init__( - self, - *, - question: str, - records: List["TextRecord"], - language: Optional[str] = None, - string_index_type: Optional[Union[str, "StringIndexType"]] = "TextElements_v8", - **kwargs - ): - """ - :keyword question: Required. User question to query against the given text records. - :paramtype question: str - :keyword records: Required. Text records to be searched for given question. - :paramtype records: list[~azure.ai.language.questionanswering.models.TextRecord] - :keyword language: Language of the text records. This is BCP-47 representation of a language. - For example, use "en" for English; "es" for Spanish etc. If not set, use "en" for English as - default. - :paramtype language: str - :keyword string_index_type: Specifies the method used to interpret string offsets. Defaults to - Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see - https://aka.ms/text-analytics-offsets. Possible values include: "TextElements_v8", - "UnicodeCodePoint", "Utf16CodeUnit". Default value: "TextElements_v8". - :paramtype string_index_type: str or - ~azure.ai.language.questionanswering.models.StringIndexType - """ - super(TextQueryOptions, self).__init__(**kwargs) - self.question = question - self.records = records - self.language = language - self.string_index_type = string_index_type - - class TextRecord(msrest.serialization.Model): """Represent input text record to be queried. diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py index 658d920781be..90ecef115959 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py @@ -102,7 +102,7 @@ class QuestionAnsweringClientOperationsMixin(object): @overload def query_knowledge_base( self, - options, # type: "_models.KnowledgeBaseQueryOptions" + options, # type: "_models.QueryKnowledgeBaseOptions" **kwargs # type: Any ): # type: (...) -> "_models.KnowledgeBaseAnswers" @@ -110,7 +110,7 @@ def query_knowledge_base( :param options: Positional-only post body of the request. :type options: - ~azure.ai.language.questionanswering.models.KnowledgeBaseQueryOptions + ~azure.ai.language.questionanswering.models.QueryKnowledgeBaseOptions :keyword project_name: The name of the project to use. :paramtype project_name: str :keyword deployment_name: The name of the specific deployment of the project to use. @@ -164,7 +164,7 @@ def query_knowledge_base( def query_knowledge_base( self, - *args, # type: "_models.KnowledgeBaseQueryOptions" + *args, # type: "_models.QueryKnowledgeBaseOptions" **kwargs # type: Any ): # type: (...) -> "_models.KnowledgeBaseAnswers" @@ -173,7 +173,7 @@ def query_knowledge_base( :param options: Post body of the request. Provide either `options`, OR individual keyword arguments. If both are provided, only the options object will be used. :type options: - ~azure.ai.language.questionanswering.models.KnowledgeBaseQueryOptions + ~azure.ai.language.questionanswering.models.QueryKnowledgeBaseOptions :keyword project_name: The name of the project to use. :paramtype project_name: str :keyword deployment_name: The name of the specific deployment of the project to use. @@ -204,7 +204,7 @@ def query_knowledge_base( :rtype: ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswers :raises: ~azure.core.exceptions.HttpResponseError """ - options = _get_positional_body(*args, **kwargs) or _models.KnowledgeBaseQueryOptions( + options = _get_positional_body(*args, **kwargs) or _models.QueryKnowledgeBaseOptions( qna_id=kwargs.pop("qna_id", None), question=kwargs.pop("question", None), top=kwargs.pop("top", None), @@ -223,7 +223,7 @@ def query_knowledge_base( project_name = kwargs.pop("project_name") # type: str deployment_name = kwargs.pop("deployment_name") # type: str - json = self._serialize.body(options, "KnowledgeBaseQueryOptions") + json = self._serialize.body(options, "QueryKnowledgeBaseOptions") request = build_query_knowledge_base_request( content_type=content_type, diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/async_samples/sample_chat_async.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/async_samples/sample_chat_async.py index 483e68f85705..fa80fc5e0c3c 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/async_samples/sample_chat_async.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/async_samples/sample_chat_async.py @@ -35,7 +35,7 @@ async def sample_chit_chat(): client = QuestionAnsweringClient(endpoint, AzureKeyCredential(key)) async with client: - first_question = qna.KnowledgeBaseQueryOptions( + first_question = qna.QueryKnowledgeBaseOptions( question="How long should my Surface battery last?", top=3, confidence_score_threshold=0.2, @@ -56,7 +56,7 @@ async def sample_chit_chat(): print("Q: {}".format(first_question.question)) print("A: {}".format(best_candidate.answer)) - followup_question = qna.KnowledgeBaseQueryOptions( + followup_question = qna.QueryKnowledgeBaseOptions( question="How long it takes to charge Surface?", top=3, confidence_score_threshold=0.2, diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/async_samples/sample_query_knowledgebase_async.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/async_samples/sample_query_knowledgebase_async.py index 2f5b0ef1f2e5..93a4b946f7ef 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/async_samples/sample_query_knowledgebase_async.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/async_samples/sample_query_knowledgebase_async.py @@ -35,7 +35,7 @@ async def sample_query_knowledgebase(): client = QuestionAnsweringClient(endpoint, AzureKeyCredential(key)) async with client: - input = qna.KnowledgeBaseQueryOptions( + input = qna.QueryKnowledgeBaseOptions( question="How long should my Surface battery last?", top=3, confidence_score_threshold=0.2, diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/sample_chat.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/sample_chat.py index 68077ff16f05..f7a065b77179 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/sample_chat.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/sample_chat.py @@ -33,7 +33,7 @@ def sample_chit_chat(): client = QuestionAnsweringClient(endpoint, AzureKeyCredential(key)) with client: - first_question = qna.KnowledgeBaseQueryOptions( + first_question = qna.QueryKnowledgeBaseOptions( question="How long should my Surface battery last?", top=3, confidence_score_threshold=0.2, @@ -54,7 +54,7 @@ def sample_chit_chat(): print("Q: {}".format(first_question.question)) print("A: {}".format(best_candidate.answer)) - followup_question = qna.KnowledgeBaseQueryOptions( + followup_question = qna.QueryKnowledgeBaseOptions( question="How long it takes to charge Surface?", top=3, confidence_score_threshold=0.2, diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/sample_query_knowledgebase.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/sample_query_knowledgebase.py index 21599649b602..6bfb59022c0b 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/sample_query_knowledgebase.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/sample_query_knowledgebase.py @@ -33,7 +33,7 @@ def sample_query_knowledgebase(): client = QuestionAnsweringClient(endpoint, AzureKeyCredential(key)) with client: - input = qna.KnowledgeBaseQueryOptions( + input = qna.QueryKnowledgeBaseOptions( question="How long should my Surface battery last?", top=3, confidence_score_threshold=0.2, diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/swagger/README.md b/sdk/cognitivelanguage/azure-ai-language-questionanswering/swagger/README.md index 882e7f00f690..48fd26daafa3 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/swagger/README.md +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/swagger/README.md @@ -77,3 +77,23 @@ directive: transform: > $["x-ms-client-name"] = "Options"; ``` + +### Rename `KnowledgeBaseQueryOptions` -> `QueryKnowledgeBaseOptions` + +```yaml +directive: + - from: swagger-document + where: $["definitions"]["KnowledgeBaseQueryOptions"] + transform: > + $["x-ms-client-name"] = "QueryKnowledgeBaseOptions"; +``` + +### Rename `TextQueryOptions` -> `QueryTextOptions` + +```yaml +directive: + - from: swagger-document + where: $["definitions"]["TextQueryOptions"] + transform: > + $["x-ms-client-name"] = "QueryTextOptions"; +``` diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase.py index ae26848deb0a..252b88a2a9bc 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase.py @@ -16,7 +16,7 @@ from azure.ai.language.questionanswering import QuestionAnsweringClient from azure.ai.language.questionanswering.operations._operations import build_query_text_request, build_query_knowledge_base_request from azure.ai.language.questionanswering.models import ( - KnowledgeBaseQueryOptions, + QueryKnowledgeBaseOptions, KnowledgeBaseAnswerRequestContext, AnswerSpanRequest, ) @@ -125,7 +125,7 @@ def test_query_knowledgebase_llc_with_answerspan(self, qna_account, qna_key, qna @GlobalQuestionAnsweringAccountPreparer() def test_query_knowledgebase(self, qna_account, qna_key, qna_project): client = QuestionAnsweringClient(qna_account, AzureKeyCredential(qna_key)) - query_params = KnowledgeBaseQueryOptions( + query_params = QueryKnowledgeBaseOptions( question="Ports and connectors", top=3, context=KnowledgeBaseAnswerRequestContext( @@ -166,7 +166,7 @@ def test_query_knowledgebase(self, qna_account, qna_key, qna_project): @GlobalQuestionAnsweringAccountPreparer() def test_query_knowledgebase_with_answerspan(self, qna_account, qna_key, qna_project): client = QuestionAnsweringClient(qna_account, AzureKeyCredential(qna_key)) - query_params = KnowledgeBaseQueryOptions( + query_params = QueryKnowledgeBaseOptions( question="Ports and connectors", top=3, context=KnowledgeBaseAnswerRequestContext( @@ -271,7 +271,7 @@ def test_query_knowledgebase_overload(self, qna_account, qna_key, qna_project): def test_query_knowledgebase_with_followup(self, qna_account, qna_key, qna_project): client = QuestionAnsweringClient(qna_account, AzureKeyCredential(qna_key)) with client: - query_params = KnowledgeBaseQueryOptions( + query_params = QueryKnowledgeBaseOptions( question="How long should my Surface battery last?", top=3, user_id="sd53lsY=", @@ -293,7 +293,7 @@ def test_query_knowledgebase_with_followup(self, qna_account, qna_key, qna_proje assert len(confident_answers) == 1 assert confident_answers[0].source == "surface-pro-4-user-guide-EN.pdf" - query_params = KnowledgeBaseQueryOptions( + query_params = QueryKnowledgeBaseOptions( question="How long it takes to charge Surface?", top=3, user_id="sd53lsY=", @@ -325,7 +325,7 @@ def test_query_knowledgebase_with_followup(self, qna_account, qna_key, qna_proje def test_query_knowledgebase_only_id(self, qna_account, qna_key, qna_project): client = QuestionAnsweringClient(qna_account, AzureKeyCredential(qna_key)) with client: - query_params = KnowledgeBaseQueryOptions( + query_params = QueryKnowledgeBaseOptions( qna_id=19 ) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase_async.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase_async.py index e7e8e37bd377..9a29975fde29 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase_async.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase_async.py @@ -16,7 +16,7 @@ from asynctestcase import AsyncQuestionAnsweringTest from azure.ai.language.questionanswering.models import ( - KnowledgeBaseQueryOptions, + QueryKnowledgeBaseOptions, KnowledgeBaseAnswerRequestContext, AnswerSpanRequest, ) @@ -127,7 +127,7 @@ async def test_query_knowledgebase_llc_with_answerspan(self, qna_account, qna_ke @GlobalQuestionAnsweringAccountPreparer() async def test_query_knowledgebase(self, qna_account, qna_key, qna_project): client = QuestionAnsweringClient(qna_account, AzureKeyCredential(qna_key)) - query_params = KnowledgeBaseQueryOptions( + query_params = QueryKnowledgeBaseOptions( question="Ports and connectors", top=3, context=KnowledgeBaseAnswerRequestContext( @@ -168,7 +168,7 @@ async def test_query_knowledgebase(self, qna_account, qna_key, qna_project): @GlobalQuestionAnsweringAccountPreparer() async def test_query_knowledgebase_with_answerspan(self, qna_account, qna_key, qna_project): client = QuestionAnsweringClient(qna_account, AzureKeyCredential(qna_key)) - query_params = KnowledgeBaseQueryOptions( + query_params = QueryKnowledgeBaseOptions( question="Ports and connectors", top=3, context=KnowledgeBaseAnswerRequestContext( @@ -272,7 +272,7 @@ async def test_query_knowledgebase_overload(self, qna_account, qna_key, qna_proj async def test_query_knowledgebase_with_followup(self, qna_account, qna_key, qna_project): client = QuestionAnsweringClient(qna_account, AzureKeyCredential(qna_key)) async with client: - query_params = KnowledgeBaseQueryOptions( + query_params = QueryKnowledgeBaseOptions( question="How long should my Surface battery last?", top=3, user_id="sd53lsY=", @@ -294,7 +294,7 @@ async def test_query_knowledgebase_with_followup(self, qna_account, qna_key, qna assert len(confident_answers) == 1 assert confident_answers[0].source == "surface-pro-4-user-guide-EN.pdf" - query_params = KnowledgeBaseQueryOptions( + query_params = QueryKnowledgeBaseOptions( question="How long it takes to charge Surface?", top=3, user_id="sd53lsY=", From 47042305e86d9a6dfe0633e04e734c69d6f401c5 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Wed, 29 Sep 2021 19:14:16 -0400 Subject: [PATCH 05/20] hide string index type --- .../questionanswering/models/__init__.py | 2 -- .../questionanswering/models/_models.py | 13 +---------- .../questionanswering/models/_models_py3.py | 23 ++----------------- .../_question_answering_client_enums.py | 18 --------------- .../swagger/README.md | 10 ++++++++ 5 files changed, 13 insertions(+), 53 deletions(-) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/__init__.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/__init__.py index cad86768af66..202bbf5824ba 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/__init__.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/__init__.py @@ -50,7 +50,6 @@ InnerErrorCode, LogicalOperationKind, RankerType, - StringIndexType, ) __all__ = [ @@ -76,5 +75,4 @@ "InnerErrorCode", "LogicalOperationKind", "RankerType", - "StringIndexType", ] diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models.py index 1c38b963b5c3..05d716ec10d3 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models.py @@ -617,11 +617,6 @@ class QueryTextOptions(msrest.serialization.Model): example, use "en" for English; "es" for Spanish etc. If not set, use "en" for English as default. :vartype language: str - :ivar string_index_type: Specifies the method used to interpret string offsets. Defaults to - Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see - https://aka.ms/text-analytics-offsets. Possible values include: "TextElements_v8", - "UnicodeCodePoint", "Utf16CodeUnit". Default value: "TextElements_v8". - :vartype string_index_type: str or ~azure.ai.language.questionanswering.models.StringIndexType """ _validation = { @@ -646,18 +641,12 @@ def __init__(self, **kwargs): For example, use "en" for English; "es" for Spanish etc. If not set, use "en" for English as default. :paramtype language: str - :keyword string_index_type: Specifies the method used to interpret string offsets. Defaults to - Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see - https://aka.ms/text-analytics-offsets. Possible values include: "TextElements_v8", - "UnicodeCodePoint", "Utf16CodeUnit". Default value: "TextElements_v8". - :paramtype string_index_type: str or - ~azure.ai.language.questionanswering.models.StringIndexType """ super(QueryTextOptions, self).__init__(**kwargs) self.question = kwargs["question"] self.records = kwargs["records"] self.language = kwargs.get("language", None) - self.string_index_type = kwargs.get("string_index_type", "TextElements_v8") + self.string_index_type = "UnicodeCodePoint" class TextAnswer(msrest.serialization.Model): diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models_py3.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models_py3.py index 3bb11a5eb2a3..46f55235c553 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models_py3.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models_py3.py @@ -706,11 +706,6 @@ class QueryTextOptions(msrest.serialization.Model): example, use "en" for English; "es" for Spanish etc. If not set, use "en" for English as default. :vartype language: str - :ivar string_index_type: Specifies the method used to interpret string offsets. Defaults to - Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see - https://aka.ms/text-analytics-offsets. Possible values include: "TextElements_v8", - "UnicodeCodePoint", "Utf16CodeUnit". Default value: "TextElements_v8". - :vartype string_index_type: str or ~azure.ai.language.questionanswering.models.StringIndexType """ _validation = { @@ -725,15 +720,7 @@ class QueryTextOptions(msrest.serialization.Model): "string_index_type": {"key": "stringIndexType", "type": "str"}, } - def __init__( - self, - *, - question: str, - records: List["TextRecord"], - language: Optional[str] = None, - string_index_type: Optional[Union[str, "StringIndexType"]] = "TextElements_v8", - **kwargs - ): + def __init__(self, *, question: str, records: List["TextRecord"], language: Optional[str] = None, **kwargs): """ :keyword question: Required. User question to query against the given text records. :paramtype question: str @@ -743,18 +730,12 @@ def __init__( For example, use "en" for English; "es" for Spanish etc. If not set, use "en" for English as default. :paramtype language: str - :keyword string_index_type: Specifies the method used to interpret string offsets. Defaults to - Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see - https://aka.ms/text-analytics-offsets. Possible values include: "TextElements_v8", - "UnicodeCodePoint", "Utf16CodeUnit". Default value: "TextElements_v8". - :paramtype string_index_type: str or - ~azure.ai.language.questionanswering.models.StringIndexType """ super(QueryTextOptions, self).__init__(**kwargs) self.question = question self.records = records self.language = language - self.string_index_type = string_index_type + self.string_index_type = "UnicodeCodePoint" class TextAnswer(msrest.serialization.Model): diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_question_answering_client_enums.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_question_answering_client_enums.py index d8fa5d884ed3..d6c78563d2b6 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_question_answering_client_enums.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_question_answering_client_enums.py @@ -47,21 +47,3 @@ class RankerType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DEFAULT = "Default" QUESTION_ONLY = "QuestionOnly" - - -class StringIndexType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Specifies the method used to interpret string offsets. Defaults to Text Elements (Graphemes) - according to Unicode v8.0.0. For additional information see - https://aka.ms/text-analytics-offsets. - """ - - #: Returned offset and length values will correspond to TextElements (Graphemes and Grapheme - #: clusters) confirming to the Unicode 8.0.0 standard. Use this option if your application is - #: written in .Net Framework or .Net Core and you will be using StringInfo. - TEXT_ELEMENTS_V8 = "TextElements_v8" - #: Returned offset and length values will correspond to Unicode code points. Use this option if - #: your application is written in a language that support Unicode, for example Python. - UNICODE_CODE_POINT = "UnicodeCodePoint" - #: Returned offset and length values will correspond to UTF-16 code units. Use this option if your - #: application is written in a language that support Unicode, for example Java, JavaScript. - UTF16_CODE_UNIT = "Utf16CodeUnit" diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/swagger/README.md b/sdk/cognitivelanguage/azure-ai-language-questionanswering/swagger/README.md index 48fd26daafa3..1acb1db2acee 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/swagger/README.md +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/swagger/README.md @@ -97,3 +97,13 @@ directive: transform: > $["x-ms-client-name"] = "QueryTextOptions"; ``` + +### Delete `StringIndexType` + +```yaml +directive: + - from: swagger-document + where: $["definitions"]["TextQueryOptions"] + transform: > + delete $.properties["stringIndexType"] +``` \ No newline at end of file From 73827b7f998654fe6e19c0afba27272bb86dd4eb Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Wed, 29 Sep 2021 19:15:37 -0400 Subject: [PATCH 06/20] fix TextQueryOptions -> QueryTextOptions --- .../aio/operations/_operations.py | 10 ++++---- .../operations/_operations.py | 23 +++++-------------- .../async_samples/sample_query_text_async.py | 2 +- .../samples/sample_query_text.py | 2 +- .../tests/test_query_text.py | 5 ++-- .../tests/test_query_text_async.py | 4 ++-- 6 files changed, 17 insertions(+), 29 deletions(-) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py index 75cfdf276c37..3e06accbd0fc 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py @@ -197,11 +197,11 @@ async def query_knowledge_base( query_knowledge_base.metadata = {"url": "/:query-knowledgebases"} # type: ignore @overload - async def query_text(self, options: "_models.TextQueryOptions", **kwargs: Any) -> "_models.TextAnswers": + async def query_text(self, options: "_models.QueryTextOptions", **kwargs: Any) -> "_models.TextAnswers": """Answers the specified question using the provided text in the body. :param options: Positional-only post body of the request. - :type options: ~azure.ai.language.questionanswering.models.TextQueryOptions + :type options: ~azure.ai.language.questionanswering.models.QueryTextOptions :return: TextAnswers :rtype: ~azure.ai.language.questionanswering.models.TextAnswers :raises: ~azure.core.exceptions.HttpResponseError @@ -246,7 +246,7 @@ async def query_text( :param options: Post body of the request. Provide either `options`, OR individual keyword arguments. If both are provided, only the options object will be used. - :type options: ~azure.ai.language.questionanswering.models.TextQueryOptions + :type options: ~azure.ai.language.questionanswering.models.QueryTextOptions :keyword question: User question to query against the given text records. Provide either `options`, OR individual keyword arguments. If both are provided, only the options object will be used. :paramtype question: str @@ -265,7 +265,7 @@ async def query_text( :rtype: ~azure.ai.language.questionanswering.models.TextAnswers :raises: ~azure.core.exceptions.HttpResponseError """ - options = _get_positional_body(*args, **kwargs) or _models.TextQueryOptions( + options = _get_positional_body(*args, **kwargs) or _models.QueryTextOptions( question=kwargs.pop("question"), records=kwargs.pop("records"), language=kwargs.pop("language", None), @@ -281,7 +281,7 @@ async def query_text( error_map.update(kwargs.pop("error_map", {})) content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] - json = self._serialize.body(options, "TextQueryOptions") + json = self._serialize.body(options, "QueryTextOptions") request = build_query_text_request( content_type=content_type, diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py index 90ecef115959..2657e9ba2532 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py @@ -257,14 +257,14 @@ def query_knowledge_base( @overload def query_text( self, - options, # type: "_models.TextQueryOptions" + options, # type: "_models.QueryTextOptions" **kwargs # type: Any ): # type: (...) -> "_models.TextAnswers" """Answers the specified question using the provided text in the body. :param options: Positional-only post body of the request. - :type options: ~azure.ai.language.questionanswering.models.TextQueryOptions + :type options: ~azure.ai.language.questionanswering.models.QueryTextOptions :return: TextAnswers :rtype: ~azure.ai.language.questionanswering.models.TextAnswers :raises: ~azure.core.exceptions.HttpResponseError @@ -287,11 +287,6 @@ def query_text( example, use "en" for English; "es" for Spanish etc. If not set, use "en" for English as default. :paramtype language: str - :keyword string_index_type: Specifies the method used to interpret string offsets. Defaults to - Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see - https://aka.ms/text-analytics-offsets. Possible values include: "TextElements_v8", - "UnicodeCodePoint", "Utf16CodeUnit". Default value: "TextElements_v8". - :paramtype string_index_type: str or ~azure.ai.language.questionanswering.models.StringIndexType :return: TextAnswers :rtype: ~azure.ai.language.questionanswering.models.TextAnswers :raises: ~azure.core.exceptions.HttpResponseError @@ -300,7 +295,7 @@ def query_text( def query_text( self, - *args, # type: "_models.TextQueryOptions" + *args, # type: "_models.QueryTextOptions" **kwargs # type: Any ): # type: (...) -> "_models.TextAnswers" @@ -308,7 +303,7 @@ def query_text( :param options: Post body of the request. Provide either `options`, OR individual keyword arguments. If both are provided, only the options object will be used. - :type options: ~azure.ai.language.questionanswering.models.TextQueryOptions + :type options: ~azure.ai.language.questionanswering.models.QueryTextOptions :keyword question: User question to query against the given text records. Provide either `options`, OR individual keyword arguments. If both are provided, only the options object will be used. :paramtype question: str @@ -318,20 +313,14 @@ def query_text( :keyword language: Language of the text records. This is BCP-47 representation of a language. For example, use "en" for English; "es" for Spanish etc. If not set, use "en" for English as default. :paramtype language: str - :keyword string_index_type: Specifies the method used to interpret string offsets. Defaults to - Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see - https://aka.ms/text-analytics-offsets. Possible values include: "TextElements_v8", - "UnicodeCodePoint", "Utf16CodeUnit". Default value: "TextElements_v8". - :paramtype string_index_type: str or ~azure.ai.language.questionanswering.models.StringIndexType :return: TextAnswers :rtype: ~azure.ai.language.questionanswering.models.TextAnswers :raises: ~azure.core.exceptions.HttpResponseError """ - options = _get_positional_body(*args, **kwargs) or _models.TextQueryOptions( + options = _get_positional_body(*args, **kwargs) or _models.QueryTextOptions( question=kwargs.pop("question"), records=kwargs.pop("records"), language=kwargs.pop("language", None), - string_index_type=kwargs.pop("string_index_type", "TextElements_v8") ) try: options['records'] = _validate_text_records(options['records']) @@ -343,7 +332,7 @@ def query_text( error_map.update(kwargs.pop("error_map", {})) content_type = kwargs.pop("content_type", "application/json") # type: Optional[str] - json = self._serialize.body(options, "TextQueryOptions") + json = self._serialize.body(options, "QueryTextOptions") request = build_query_text_request( content_type=content_type, diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/async_samples/sample_query_text_async.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/async_samples/sample_query_text_async.py index a34195f7e320..8b7df0051fd0 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/async_samples/sample_query_text_async.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/async_samples/sample_query_text_async.py @@ -32,7 +32,7 @@ async def sample_query_text(): client = QuestionAnsweringClient(endpoint, AzureKeyCredential(key)) async with client: - input = qna.TextQueryOptions( + input = qna.QueryTextOptions( question="How long it takes to charge surface?", records=[ qna.TextRecord( diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/sample_query_text.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/sample_query_text.py index 9f784b5a5e4c..6d3cc65baafe 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/sample_query_text.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/sample_query_text.py @@ -31,7 +31,7 @@ def sample_query_text(): client = QuestionAnsweringClient(endpoint, AzureKeyCredential(key)) with client: - input = qna.TextQueryOptions( + input = qna.QueryTextOptions( question="How long it takes to charge surface?", records=[ qna.TextRecord( diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_text.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_text.py index 148d594622c6..434141a88a2d 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_text.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_text.py @@ -17,7 +17,7 @@ from azure.ai.language.questionanswering import QuestionAnsweringClient from azure.ai.language.questionanswering.operations._operations import build_query_text_request, build_query_knowledge_base_request from azure.ai.language.questionanswering.models import ( - TextQueryOptions, + QueryTextOptions, TextRecord ) @@ -67,7 +67,7 @@ def test_query_text_llc(self, qna_account, qna_key): @GlobalQuestionAnsweringAccountPreparer() def test_query_text(self, qna_account, qna_key): client = QuestionAnsweringClient(qna_account, AzureKeyCredential(qna_key)) - params = TextQueryOptions( + params = QueryTextOptions( question="What is the meaning of life?", records=[ TextRecord( @@ -187,4 +187,3 @@ def test_query_text_overload_positional_and_kwarg(self): client.query_text("positional_one", "positional_two") with pytest.raises(TypeError): client.query_text("positional_options_bag", options="options bag by name") - \ No newline at end of file diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_text_async.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_text_async.py index d252004872c9..b5d6323a64db 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_text_async.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_text_async.py @@ -17,7 +17,7 @@ from azure.ai.language.questionanswering.aio import QuestionAnsweringClient from azure.ai.language.questionanswering.operations._operations import build_query_text_request, build_query_knowledge_base_request from azure.ai.language.questionanswering.models import ( - TextQueryOptions, + QueryTextOptions, TextRecord ) @@ -69,7 +69,7 @@ async def test_query_text_llc(self, qna_account, qna_key): @GlobalQuestionAnsweringAccountPreparer() async def test_query_text(self, qna_account, qna_key): client = QuestionAnsweringClient(qna_account, AzureKeyCredential(qna_key)) - params = TextQueryOptions( + params = QueryTextOptions( question="What is the meaning of life?", records=[ TextRecord( From 00d3bf4cd7e30c853694541a8533c8b9bc63913d Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Wed, 29 Sep 2021 19:18:04 -0400 Subject: [PATCH 07/20] remove string_index_type everywhere --- .../questionanswering/aio/operations/_operations.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py index 3e06accbd0fc..f1b28b6aa1d8 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py @@ -215,7 +215,6 @@ async def query_text( question: str, records: List["_models.TextRecord"], language: Optional[str] = None, - string_index_type: Optional[Union[str, "_models.StringIndexType"]] = "TextElements_v8", **kwargs: Any ) -> "_models.TextAnswers": """Answers the specified question using the provided text in the body. @@ -228,11 +227,6 @@ async def query_text( example, use "en" for English; "es" for Spanish etc. If not set, use "en" for English as default. :paramtype language: str - :keyword string_index_type: Specifies the method used to interpret string offsets. Defaults to - Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see - https://aka.ms/text-analytics-offsets. Possible values include: "TextElements_v8", - "UnicodeCodePoint", "Utf16CodeUnit". Default value: "TextElements_v8". - :paramtype string_index_type: str or ~azure.ai.language.questionanswering.models.StringIndexType :return: TextAnswers :rtype: ~azure.ai.language.questionanswering.models.TextAnswers :raises: ~azure.core.exceptions.HttpResponseError @@ -256,11 +250,6 @@ async def query_text( :keyword language: Language of the text records. This is BCP-47 representation of a language. For example, use "en" for English; "es" for Spanish etc. If not set, use "en" for English as default. :paramtype language: str - :keyword string_index_type: Specifies the method used to interpret string offsets. Defaults to - Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see - https://aka.ms/text-analytics-offsets. Possible values include: "TextElements_v8", - "UnicodeCodePoint", "Utf16CodeUnit". Default value: "TextElements_v8". - :paramtype string_index_type: str or ~azure.ai.language.questionanswering.models.StringIndexType :return: TextAnswers :rtype: ~azure.ai.language.questionanswering.models.TextAnswers :raises: ~azure.core.exceptions.HttpResponseError @@ -269,7 +258,6 @@ async def query_text( question=kwargs.pop("question"), records=kwargs.pop("records"), language=kwargs.pop("language", None), - string_index_type=kwargs.pop("string_index_type", "TextElements_v8") ) try: options['records'] = _validate_text_records(options['records']) From a0a3be000ca328a8477f0e9b71601585c514a9a6 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Wed, 29 Sep 2021 19:29:20 -0400 Subject: [PATCH 08/20] add default_language kwarg --- .../language/questionanswering/_question_answering_client.py | 3 +++ .../questionanswering/aio/_question_answering_client.py | 3 +++ .../language/questionanswering/aio/operations/_operations.py | 2 +- .../ai/language/questionanswering/operations/_operations.py | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_question_answering_client.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_question_answering_client.py index 9de9e08df077..0ec3d5a66199 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_question_answering_client.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_question_answering_client.py @@ -32,6 +32,8 @@ class QuestionAnsweringClient(QuestionAnsweringClientOperationsMixin): :type endpoint: str :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.AzureKeyCredential + :keyword str default_language: Sets the default language to use for all operations. + Defaults to "en". """ def __init__( @@ -49,6 +51,7 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False + self._default_language = kwargs.pop("default_language", "en") def send_request( self, diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/_question_answering_client.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/_question_answering_client.py index 6994f258008f..c9bc4a2edd2a 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/_question_answering_client.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/_question_answering_client.py @@ -27,6 +27,8 @@ class QuestionAnsweringClient(QuestionAnsweringClientOperationsMixin): :type endpoint: str :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.AzureKeyCredential + :keyword str default_language: Sets the default language to use for all operations. + Defaults to "en". """ def __init__(self, endpoint: str, credential: AzureKeyCredential, **kwargs: Any) -> None: @@ -38,6 +40,7 @@ def __init__(self, endpoint: str, credential: AzureKeyCredential, **kwargs: Any) self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False + self._default_language = kwargs.pop("default_language", "en") def send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py index f1b28b6aa1d8..1dfce4fe13f9 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py @@ -257,7 +257,7 @@ async def query_text( options = _get_positional_body(*args, **kwargs) or _models.QueryTextOptions( question=kwargs.pop("question"), records=kwargs.pop("records"), - language=kwargs.pop("language", None), + language=kwargs.pop("language", self._default_language), ) try: options['records'] = _validate_text_records(options['records']) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py index 2657e9ba2532..08963f4bc79e 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py @@ -320,7 +320,7 @@ def query_text( options = _get_positional_body(*args, **kwargs) or _models.QueryTextOptions( question=kwargs.pop("question"), records=kwargs.pop("records"), - language=kwargs.pop("language", None), + language=kwargs.pop("language", self._default_language), ) try: options['records'] = _validate_text_records(options['records']) From 9cf338021617263a7242c19d862620e58f5ea3b6 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Wed, 29 Sep 2021 19:52:00 -0400 Subject: [PATCH 09/20] verify either qna_id or question exists --- .../ai/language/questionanswering/_patch.py | 14 ++++++++++++++ .../aio/operations/_operations.py | 3 ++- .../operations/_operations.py | 3 ++- .../tests/test_query_knowledgebase.py | 19 ++++++++++++++++++- .../tests/test_query_knowledgebase_async.py | 19 ++++++++++++++++++- 5 files changed, 54 insertions(+), 4 deletions(-) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_patch.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_patch.py index d637ad8ff20f..d2ed46a3e32d 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_patch.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_patch.py @@ -38,6 +38,7 @@ def _validate_text_records(records): return request_batch def _get_positional_body(*args, **kwargs): + """Verify args and kwargs are valid, and then return the positional body, if users passed it in.""" if len(args) > 1: raise TypeError("There can only be one positional argument, which is the post body of this request.") if args and "options" in kwargs: @@ -45,3 +46,16 @@ def _get_positional_body(*args, **kwargs): "You have already supplied the request body as a positional parameter, you can not supply it as a kwarg as well." ) return args[0] if args else None + +def _verify_qna_id_and_question(query_knowledgebase_options): + """For query_knowledge_base we require either `question` or `qna_id`.""" + try: + qna_id = query_knowledgebase_options.qna_id + question = query_knowledgebase_options.question + except AttributeError: + qna_id = query_knowledgebase_options.get("qna_id") or query_knowledgebase_options.get("qnaId") + question = query_knowledgebase_options.get("question") + if not (qna_id or question): + raise TypeError( + "You need to pass in either `qna_id` or `question`." + ) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py index 1dfce4fe13f9..ab264accbf46 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py @@ -22,7 +22,7 @@ from ... import models as _models from ...operations._operations import build_query_knowledge_base_request, build_query_text_request -from ..._patch import _validate_text_records, _get_positional_body +from ..._patch import _validate_text_records, _get_positional_body, _verify_qna_id_and_question T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -158,6 +158,7 @@ async def query_knowledge_base( answer_span_request=kwargs.pop("answer_span_request", None), include_unstructured_sources=kwargs.pop("include_unstructured_sources", None) ) + _verify_qna_id_and_question(options) cls = kwargs.pop("cls", None) # type: ClsType["_models.KnowledgeBaseAnswers"] error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop("error_map", {})) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py index 08963f4bc79e..f4f9bdbd067c 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py @@ -22,7 +22,7 @@ from msrest import Serializer from .. import models as _models -from .._patch import _validate_text_records, _get_positional_body +from .._patch import _validate_text_records, _get_positional_body, _verify_qna_id_and_question if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -216,6 +216,7 @@ def query_knowledge_base( answer_span_request=kwargs.pop("answer_span_request", None), include_unstructured_sources=kwargs.pop("include_unstructured_sources", None) ) + _verify_qna_id_and_question(options) cls = kwargs.pop("cls", None) # type: ClsType["_models.KnowledgeBaseAnswers"] error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop("error_map", {})) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase.py index 252b88a2a9bc..31e0391e0fbc 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase.py @@ -351,9 +351,26 @@ def test_query_knowledgebase_python_dict(self, qna_account, qna_key, qna_project assert len(output.answers) == 1 - def test_query_knowledge_base_overload_positional_and_kwarg(self): + def test_query_knowledgebase_overload_positional_and_kwarg(self): with QuestionAnsweringClient("http://fake.com", AzureKeyCredential("123")) as client: with pytest.raises(TypeError): client.query_knowledge_base("positional_one", "positional_two") with pytest.raises(TypeError): client.query_knowledge_base("positional_options_bag", options="options bag by name") + + def test_query_knowledge_question_or_qna_id(self): + with QuestionAnsweringClient("http://fake.com", AzureKeyCredential("123")) as client: + + options = QueryKnowledgeBaseOptions() + with pytest.raises(TypeError): + client.query_knowledge_base( + options, + project_name="hello", + deployment_name='test' + ) + + with pytest.raises(TypeError): + client.query_knowledge_base( + project_name="hello", + deployment_name='test' + ) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase_async.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase_async.py index 9a29975fde29..e57089d3d94e 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase_async.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase_async.py @@ -349,9 +349,26 @@ async def test_query_knowledgebase_python_dict(self, qna_account, qna_key, qna_p assert len(output.answers) == 1 - async def test_query_knowledge_base_overload_positional_and_kwarg(self): + async def test_query_knowledgebase_overload_positional_and_kwarg(self): async with QuestionAnsweringClient("http://fake.com", AzureKeyCredential("123")) as client: with pytest.raises(TypeError): await client.query_knowledge_base("positional_one", "positional_two") with pytest.raises(TypeError): await client.query_knowledge_base("positional_options_bag", options="options bag by name") + + async def test_query_knowledge_question_or_qna_id(self): + async with QuestionAnsweringClient("http://fake.com", AzureKeyCredential("123")) as client: + + options = QueryKnowledgeBaseOptions() + with pytest.raises(TypeError): + await client.query_knowledge_base( + options, + project_name="hello", + deployment_name='test' + ) + + with pytest.raises(TypeError): + await client.query_knowledge_base( + project_name="hello", + deployment_name='test' + ) From 58adac70487c209b814b33ae82aed48b57c0e094 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Wed, 29 Sep 2021 20:02:04 -0400 Subject: [PATCH 10/20] bump azure-core version --- .../azure-ai-language-questionanswering/setup.py | 6 +++--- shared_requirements.txt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/setup.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/setup.py index 976409977724..30a3e31665b1 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/setup.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/setup.py @@ -58,15 +58,15 @@ packages=find_packages(exclude=[ 'tests', # Exclude packages that will be covered by PEP420 or nspkg - # This means any folder structure that only consists of a __init__.py. - # For example, for storage, this would mean adding 'azure.storage' + # This means any folder structure that only consists of a __init__.py. + # For example, for storage, this would mean adding 'azure.storage' # in addition to the default 'azure' that is seen here. 'azure', 'azure.ai', 'azure.ai.language', ]), install_requires=[ - 'azure-core<2.0.0,>=1.16.0', + 'azure-core<2.0.0,>=1.19.0', 'msrest>=0.6.21', ], extras_require={ diff --git a/shared_requirements.txt b/shared_requirements.txt index e375e2f5aaeb..96613e8207e7 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -150,7 +150,7 @@ chardet<5,>=3.0.2 #override azure-keyvault-secrets azure-core<2.0.0,>=1.7.0 #override azure-ai-textanalytics msrest>=0.6.21 #override azure-ai-textanalytics azure-core<2.0.0,>=1.14.0 -#override azure-ai-language-questionanswering azure-core<2.0.0,>=1.16.0 +#override azure-ai-language-questionanswering azure-core<2.0.0,>=1.19.0 #override azure-ai-language-questionanswering msrest>=0.6.21 #override azure-search-documents azure-core<2.0.0,>=1.18.0 #override azure-ai-formrecognizer msrest>=0.6.21 From 5eb79d770bc5f2fc87e6d9fe75c99a338a3e0dfb Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Wed, 29 Sep 2021 20:07:59 -0400 Subject: [PATCH 11/20] regen with hash --- .../azure-ai-language-questionanswering/swagger/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/swagger/README.md b/sdk/cognitivelanguage/azure-ai-language-questionanswering/swagger/README.md index 1acb1db2acee..ac76f4f56949 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/swagger/README.md +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/swagger/README.md @@ -20,7 +20,7 @@ autorest ### Settings ```yaml -input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/feature/cognitiveservices/language/specification/cognitiveservices/data-plane/Language/preview/2021-07-15-preview/questionanswering.json +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/68e7988aba481206f08019d3efb585683d5bc577/specification/cognitiveservices/data-plane/Language/preview/2021-07-15-preview/questionanswering.json output-folder: ../azure/ai/language/questionanswering namespace: azure.ai.language.questionanswering package-name: azure-ai-language-questionanswering From 9d3dae9238b5d393f705000b19aa87c412b3620f Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Wed, 29 Sep 2021 20:35:32 -0400 Subject: [PATCH 12/20] make metadatafilter a list of tuples --- .../questionanswering/models/__init__.py | 3 -- .../questionanswering/models/_models.py | 39 ++--------------- .../questionanswering/models/_models_py3.py | 43 +++---------------- .../swagger/README.md | 12 ++++++ 4 files changed, 20 insertions(+), 77 deletions(-) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/__init__.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/__init__.py index 202bbf5824ba..e7f241830c2f 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/__init__.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/__init__.py @@ -18,7 +18,6 @@ from ._models_py3 import KnowledgeBaseAnswerRequestContext from ._models_py3 import KnowledgeBaseAnswers from ._models_py3 import MetadataFilter - from ._models_py3 import MetadataRecord from ._models_py3 import QueryFilters from ._models_py3 import QueryKnowledgeBaseOptions from ._models_py3 import QueryTextOptions @@ -37,7 +36,6 @@ from ._models import KnowledgeBaseAnswerRequestContext # type: ignore from ._models import KnowledgeBaseAnswers # type: ignore from ._models import MetadataFilter # type: ignore - from ._models import MetadataRecord # type: ignore from ._models import QueryFilters # type: ignore from ._models import QueryKnowledgeBaseOptions # type: ignore from ._models import QueryTextOptions # type: ignore @@ -64,7 +62,6 @@ "KnowledgeBaseAnswerRequestContext", "KnowledgeBaseAnswers", "MetadataFilter", - "MetadataRecord", "QueryFilters", "QueryKnowledgeBaseOptions", "QueryTextOptions", diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models.py index 05d716ec10d3..0946d3315693 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models.py @@ -421,7 +421,7 @@ class MetadataFilter(msrest.serialization.Model): """Find QnAs that are associated with the given list of metadata. :ivar metadata: - :vartype metadata: list[~azure.ai.language.questionanswering.models.MetadataRecord] + :vartype metadata: list[tuple[str]] :ivar logical_operation: Operation used to join metadata filters. Possible values include: "AND", "OR". :vartype logical_operation: str or @@ -429,14 +429,14 @@ class MetadataFilter(msrest.serialization.Model): """ _attribute_map = { - "metadata": {"key": "metadata", "type": "[MetadataRecord]"}, + "metadata": {"key": "metadata", "type": "[[str]]"}, "logical_operation": {"key": "logicalOperation", "type": "str"}, } def __init__(self, **kwargs): """ :keyword metadata: - :paramtype metadata: list[~azure.ai.language.questionanswering.models.MetadataRecord] + :paramtype metadata: list[tuple[str]] :keyword logical_operation: Operation used to join metadata filters. Possible values include: "AND", "OR". :paramtype logical_operation: str or @@ -447,39 +447,6 @@ def __init__(self, **kwargs): self.logical_operation = kwargs.get("logical_operation", None) -class MetadataRecord(msrest.serialization.Model): - """Object to provide the key value pair for each metadata. - - All required parameters must be populated in order to send to Azure. - - :ivar key: Required. Metadata Key from Metadata dictionary used in the QnA. - :vartype key: str - :ivar value: Required. Metadata Value from Metadata dictionary used in the QnA. - :vartype value: str - """ - - _validation = { - "key": {"required": True}, - "value": {"required": True}, - } - - _attribute_map = { - "key": {"key": "key", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, **kwargs): - """ - :keyword key: Required. Metadata Key from Metadata dictionary used in the QnA. - :paramtype key: str - :keyword value: Required. Metadata Value from Metadata dictionary used in the QnA. - :paramtype value: str - """ - super(MetadataRecord, self).__init__(**kwargs) - self.key = kwargs["key"] - self.value = kwargs["value"] - - class QueryFilters(msrest.serialization.Model): """filters over knowledge base. diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models_py3.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models_py3.py index 46f55235c553..b6aae092759f 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models_py3.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models_py3.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, Tuple, Union from azure.core.exceptions import HttpResponseError import msrest.serialization @@ -483,7 +483,7 @@ class MetadataFilter(msrest.serialization.Model): """Find QnAs that are associated with the given list of metadata. :ivar metadata: - :vartype metadata: list[~azure.ai.language.questionanswering.models.MetadataRecord] + :vartype metadata: list[str] :ivar logical_operation: Operation used to join metadata filters. Possible values include: "AND", "OR". :vartype logical_operation: str or @@ -491,20 +491,20 @@ class MetadataFilter(msrest.serialization.Model): """ _attribute_map = { - "metadata": {"key": "metadata", "type": "[MetadataRecord]"}, + "metadata": {"key": "metadata", "type": "[[str]]"}, "logical_operation": {"key": "logicalOperation", "type": "str"}, } def __init__( self, *, - metadata: Optional[List["MetadataRecord"]] = None, + metadata: Optional[List[Tuple[str, str]]] = None, logical_operation: Optional[Union[str, "LogicalOperationKind"]] = None, **kwargs ): """ :keyword metadata: - :paramtype metadata: list[~azure.ai.language.questionanswering.models.MetadataRecord] + :paramtype metadata: list[tuple[str, str]] :keyword logical_operation: Operation used to join metadata filters. Possible values include: "AND", "OR". :paramtype logical_operation: str or @@ -515,39 +515,6 @@ def __init__( self.logical_operation = logical_operation -class MetadataRecord(msrest.serialization.Model): - """Object to provide the key value pair for each metadata. - - All required parameters must be populated in order to send to Azure. - - :ivar key: Required. Metadata Key from Metadata dictionary used in the QnA. - :vartype key: str - :ivar value: Required. Metadata Value from Metadata dictionary used in the QnA. - :vartype value: str - """ - - _validation = { - "key": {"required": True}, - "value": {"required": True}, - } - - _attribute_map = { - "key": {"key": "key", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, *, key: str, value: str, **kwargs): - """ - :keyword key: Required. Metadata Key from Metadata dictionary used in the QnA. - :paramtype key: str - :keyword value: Required. Metadata Value from Metadata dictionary used in the QnA. - :paramtype value: str - """ - super(MetadataRecord, self).__init__(**kwargs) - self.key = key - self.value = value - - class QueryFilters(msrest.serialization.Model): """filters over knowledge base. diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/swagger/README.md b/sdk/cognitivelanguage/azure-ai-language-questionanswering/swagger/README.md index ac76f4f56949..0fa8ecfb82f5 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/swagger/README.md +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/swagger/README.md @@ -106,4 +106,16 @@ directive: where: $["definitions"]["TextQueryOptions"] transform: > delete $.properties["stringIndexType"] +``` + +### Make `MetadataFilter`'s `metadata` property a list of string + +```yaml +directive: + - from: swagger-document + where: $["definitions"] + transform: > + delete $["MetadataFilter"]["properties"]["metadata"]["items"]["$ref"]; + $["MetadataFilter"]["properties"]["metadata"]["items"]["type"] = "string"; + delete $["MetadataRecord"]; ``` \ No newline at end of file From 255614b830c33fda1c4b2d59efaa720d129901e0 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Wed, 29 Sep 2021 20:38:51 -0400 Subject: [PATCH 13/20] update property renames for query knowledgebase options --- .../questionanswering/aio/operations/_operations.py | 12 ++++++------ .../questionanswering/operations/_operations.py | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py index ab264accbf46..9bc2e8e55d4c 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py @@ -66,7 +66,7 @@ async def query_knowledge_base( confidence_score_threshold: Optional[float] = None, context: Optional["_models.KnowledgeBaseAnswerRequestContext"] = None, ranker_type: Optional[Union[str, "_models.RankerType"]] = None, - strict_filters: Optional["_models.StrictFilters"] = None, + filters: Optional["_models.QueryFilters"] = None, answer_span_request: Optional["_models.AnswerSpanRequest"] = None, include_unstructured_sources: Optional[bool] = None, **kwargs: Any @@ -94,8 +94,8 @@ async def query_knowledge_base( :keyword ranker_type: (Optional) Set to 'QuestionOnly' for using a question only Ranker. Possible values include: "Default", "QuestionOnly". :paramtype ranker_type: str or ~azure.ai.language.questionanswering.models.RankerType - :keyword strict_filters: Filter QnAs based on give metadata list and knowledge base source names. - :paramtype strict_filters: ~azure.ai.language.questionanswering.models.StrictFilters + :keyword filters: Filter QnAs based on give metadata list and knowledge base source names. + :paramtype filters: ~azure.ai.language.questionanswering.models.QueryFilters :keyword answer_span_request: To configure Answer span prediction feature. :paramtype answer_span_request: ~azure.ai.language.questionanswering.models.AnswerSpanRequest :keyword include_unstructured_sources: (Optional) Flag to enable Query over Unstructured Sources. @@ -136,8 +136,8 @@ async def query_knowledge_base( :keyword ranker_type: (Optional) Set to 'QuestionOnly' for using a question only Ranker. Possible values include: "Default", "QuestionOnly". :paramtype ranker_type: str or ~azure.ai.language.questionanswering.models.RankerType - :keyword strict_filters: Filter QnAs based on give metadata list and knowledge base source names. - :paramtype strict_filters: ~azure.ai.language.questionanswering.models.StrictFilters + :keyword filters: Filter QnAs based on give metadata list and knowledge base source names. + :paramtype filters: ~azure.ai.language.questionanswering.models.QueryFilters :keyword answer_span_request: To configure Answer span prediction feature. :paramtype answer_span_request: ~azure.ai.language.questionanswering.models.AnswerSpanRequest :keyword include_unstructured_sources: (Optional) Flag to enable Query over Unstructured Sources. @@ -154,7 +154,7 @@ async def query_knowledge_base( confidence_score_threshold=kwargs.pop("confidence_score_threshold", None), context=kwargs.pop("context", None), ranker_type=kwargs.pop("ranker_type", None), - strict_filters=kwargs.pop("strict_filters", None), + filters=kwargs.pop("filters", None), answer_span_request=kwargs.pop("answer_span_request", None), include_unstructured_sources=kwargs.pop("include_unstructured_sources", None) ) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py index f4f9bdbd067c..ed30f42bcdad 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py @@ -150,8 +150,8 @@ def query_knowledge_base( :keyword ranker_type: (Optional) Set to 'QuestionOnly' for using a question only Ranker. Possible values include: "Default", "QuestionOnly". :paramtype ranker_type: str or ~azure.ai.language.questionanswering.models.RankerType - :keyword strict_filters: Filter QnAs based on give metadata list and knowledge base source names. - :paramtype strict_filters: ~azure.ai.language.questionanswering.models.StrictFilters + :keyword filters: Filter QnAs based on give metadata list and knowledge base source names. + :paramtype filters: ~azure.ai.language.questionanswering.models.QueryFilters :keyword answer_span_request: To configure Answer span prediction feature. :paramtype answer_span_request: ~azure.ai.language.questionanswering.models.AnswerSpanRequest :keyword include_unstructured_sources: (Optional) Flag to enable Query over Unstructured Sources. @@ -194,8 +194,8 @@ def query_knowledge_base( :keyword ranker_type: (Optional) Set to 'QuestionOnly' for using a question only Ranker. Possible values include: "Default", "QuestionOnly". :paramtype ranker_type: str or ~azure.ai.language.questionanswering.models.RankerType - :keyword strict_filters: Filter QnAs based on give metadata list and knowledge base source names. - :paramtype strict_filters: ~azure.ai.language.questionanswering.models.StrictFilters + :keyword filters: Filter QnAs based on give metadata list and knowledge base source names. + :paramtype filters: ~azure.ai.language.questionanswering.models.QueryFilters :keyword answer_span_request: To configure Answer span prediction feature. :paramtype answer_span_request: ~azure.ai.language.questionanswering.models.AnswerSpanRequest :keyword include_unstructured_sources: (Optional) Flag to enable Query over Unstructured Sources. @@ -212,7 +212,7 @@ def query_knowledge_base( confidence_score_threshold=kwargs.pop("confidence_score_threshold", None), context=kwargs.pop("context", None), ranker_type=kwargs.pop("ranker_type", None), - strict_filters=kwargs.pop("strict_filters", None), + filters=kwargs.pop("filters", None), answer_span_request=kwargs.pop("answer_span_request", None), include_unstructured_sources=kwargs.pop("include_unstructured_sources", None) ) From 2522ff386546666b47403d62f66beeb3686211ae Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Thu, 30 Sep 2021 11:38:02 -0400 Subject: [PATCH 14/20] add metadata filter tests --- ...ebase.test_query_knowledgebase_filter.yaml | 66 +++++++++++++++++++ ...async.test_query_knowledgebase_filter.yaml | 55 ++++++++++++++++ .../tests/test_query_knowledgebase.py | 33 +++++++++- .../tests/test_query_knowledgebase_async.py | 33 +++++++++- 4 files changed, 185 insertions(+), 2 deletions(-) create mode 100644 sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_filter.yaml create mode 100644 sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_filter.yaml diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_filter.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_filter.yaml new file mode 100644 index 000000000000..2fb633fa5635 --- /dev/null +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_filter.yaml @@ -0,0 +1,66 @@ +interactions: +- request: + body: '{"question": "Battery life", "top": 3, "filters": {"metadataFilter": {"metadata": + [["explicitlytaggedheading", "check the battery level"], ["explicitlytaggedheading", + "make your battery last"]]}, "logicalOperation": "OR"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '222' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-language-questionanswering/1.0.0b2 Python/3.9.5 (macOS-11.5.2-x86_64-i386-64bit) + method: POST + uri: https://test-resource.api.cognitive.microsoft.com/language/:query-knowledgebases?projectName=test-project&deploymentName=test&api-version=2021-07-15-preview + response: + body: + string: "{\n \"answers\": [\n {\n \"questions\": [\n \"Check + the battery level\"\n ],\n \"answer\": \"**Check the battery level**\\n\\nYou + can check the battery level from the lock screen or the desktop:\",\n \"confidenceScore\": + 0.6905,\n \"id\": 24,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n + \ \"metadata\": {\n \"explicitlytaggedheading\": \"check the battery + level\"\n },\n \"dialog\": {\n \"isContextOnly\": false,\n + \ \"prompts\": []\n }\n },\n {\n \"questions\": [\n + \ \"Make your battery last\"\n ],\n \"answer\": \"**Make your + battery last**\\n\\nFor info on how to care for your battery and power supply, + conserve power, and make your Surface battery last longer, see [Surface battery + and power](http://www.microsoft.com/surface/support/hardware-and-drivers/battery-and-power) + on Surface.com.\",\n \"confidenceScore\": 0.5818,\n \"id\": 27,\n + \ \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": + {\n \"explicitlytaggedheading\": \"make your battery last\"\n },\n + \ \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": + []\n }\n },\n {\n \"questions\": [\n \"Desktop taskbar.\"\n + \ ],\n \"answer\": \"**Desktop taskbar.**\\n\\nBattery status appears + at the right side of the taskbar. Select the battery icon for info about the + charging and battery status, including the percent remaining. \u272A\",\n + \ \"confidenceScore\": 0.36340000000000006,\n \"id\": 26,\n \"source\": + \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": {},\n \"dialog\": + {\n \"isContextOnly\": false,\n \"prompts\": []\n }\n }\n + \ ]\n}" + headers: + apim-request-id: + - d3b7407a-57b7-49c1-af6e-b6fc494f4bdb + content-length: + - '1622' + content-type: + - application/json; charset=utf-8 + csp-billing-usage: + - CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 + date: + - Thu, 30 Sep 2021 15:37:25 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '902' + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_filter.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_filter.yaml new file mode 100644 index 000000000000..223d22e7228f --- /dev/null +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_filter.yaml @@ -0,0 +1,55 @@ +interactions: +- request: + body: '{"question": "Battery life", "top": 3, "filters": {"metadataFilter": {"metadata": + [["explicitlytaggedheading", "check the battery level"], ["explicitlytaggedheading", + "make your battery last"]]}, "logicalOperation": "OR"}}' + headers: + Accept: + - application/json + Content-Length: + - '222' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-language-questionanswering/1.0.0b2 Python/3.9.5 (macOS-11.5.2-x86_64-i386-64bit) + method: POST + uri: https://test-resource.api.cognitive.microsoft.com/language/:query-knowledgebases?projectName=test-project&deploymentName=test&api-version=2021-07-15-preview + response: + body: + string: "{\n \"answers\": [\n {\n \"questions\": [\n \"Check + the battery level\"\n ],\n \"answer\": \"**Check the battery level**\\n\\nYou + can check the battery level from the lock screen or the desktop:\",\n \"confidenceScore\": + 0.6905,\n \"id\": 24,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n + \ \"metadata\": {\n \"explicitlytaggedheading\": \"check the battery + level\"\n },\n \"dialog\": {\n \"isContextOnly\": false,\n + \ \"prompts\": []\n }\n },\n {\n \"questions\": [\n + \ \"Make your battery last\"\n ],\n \"answer\": \"**Make your + battery last**\\n\\nFor info on how to care for your battery and power supply, + conserve power, and make your Surface battery last longer, see [Surface battery + and power](http://www.microsoft.com/surface/support/hardware-and-drivers/battery-and-power) + on Surface.com.\",\n \"confidenceScore\": 0.5818,\n \"id\": 27,\n + \ \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": + {\n \"explicitlytaggedheading\": \"make your battery last\"\n },\n + \ \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": + []\n }\n },\n {\n \"questions\": [\n \"Desktop taskbar.\"\n + \ ],\n \"answer\": \"**Desktop taskbar.**\\n\\nBattery status appears + at the right side of the taskbar. Select the battery icon for info about the + charging and battery status, including the percent remaining. \u272A\",\n + \ \"confidenceScore\": 0.36340000000000006,\n \"id\": 26,\n \"source\": + \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": {},\n \"dialog\": + {\n \"isContextOnly\": false,\n \"prompts\": []\n }\n }\n + \ ]\n}" + headers: + apim-request-id: c381395f-d6a2-4c9c-9cd8-f80373269209 + content-length: '1622' + content-type: application/json; charset=utf-8 + csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 + date: Thu, 30 Sep 2021 15:37:26 GMT + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '384' + status: + code: 200 + message: OK + url: https://wuppe.api.cognitive.microsoft.com/language/:query-knowledgebases?projectName=190a9e13-8ede-4e4b-a8fd-c4d7f2aeab6c&deploymentName=test&api-version=2021-07-15-preview +version: 1 diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase.py index 31e0391e0fbc..afef84a377ef 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase.py @@ -19,6 +19,9 @@ QueryKnowledgeBaseOptions, KnowledgeBaseAnswerRequestContext, AnswerSpanRequest, + MetadataFilter, + LogicalOperationKind, + QueryFilters, ) @@ -358,7 +361,7 @@ def test_query_knowledgebase_overload_positional_and_kwarg(self): with pytest.raises(TypeError): client.query_knowledge_base("positional_options_bag", options="options bag by name") - def test_query_knowledge_question_or_qna_id(self): + def test_query_knowledgebase_question_or_qna_id(self): with QuestionAnsweringClient("http://fake.com", AzureKeyCredential("123")) as client: options = QueryKnowledgeBaseOptions() @@ -374,3 +377,31 @@ def test_query_knowledge_question_or_qna_id(self): project_name="hello", deployment_name='test' ) + + @GlobalQuestionAnsweringAccountPreparer() + def test_query_knowledgebase_filter(self, qna_account, qna_key, qna_project): + """Thanks to @heaths for this test!""" + filters = QueryFilters( + metadata_filter=MetadataFilter( + metadata=[ + ("explicitlytaggedheading", "check the battery level"), + ("explicitlytaggedheading", "make your battery last") + ], + ), + logical_operation=LogicalOperationKind.OR_ENUM + ) + with QuestionAnsweringClient(qna_account, AzureKeyCredential(qna_key)) as client: + response = client.query_knowledge_base( + project_name=qna_project, + deployment_name='test', + question="Battery life", + filters=filters, + top=3, + ) + assert len(response.answers) == 3 + assert any( + [a for a in response.answers if a.metadata.get('explicitlytaggedheading') == "check the battery level"] + ) + assert any( + [a for a in response.answers if a.metadata.get('explicitlytaggedheading') == "make your battery last"] + ) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase_async.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase_async.py index e57089d3d94e..880b2b1ad392 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase_async.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase_async.py @@ -19,6 +19,9 @@ QueryKnowledgeBaseOptions, KnowledgeBaseAnswerRequestContext, AnswerSpanRequest, + QueryFilters, + MetadataFilter, + LogicalOperationKind, ) from azure.ai.language.questionanswering.aio import QuestionAnsweringClient from azure.ai.language.questionanswering.operations._operations import build_query_knowledge_base_request, build_query_text_request @@ -356,7 +359,7 @@ async def test_query_knowledgebase_overload_positional_and_kwarg(self): with pytest.raises(TypeError): await client.query_knowledge_base("positional_options_bag", options="options bag by name") - async def test_query_knowledge_question_or_qna_id(self): + async def test_query_knowledgebase_question_or_qna_id(self): async with QuestionAnsweringClient("http://fake.com", AzureKeyCredential("123")) as client: options = QueryKnowledgeBaseOptions() @@ -372,3 +375,31 @@ async def test_query_knowledge_question_or_qna_id(self): project_name="hello", deployment_name='test' ) + + @GlobalQuestionAnsweringAccountPreparer() + async def test_query_knowledgebase_filter(self, qna_account, qna_key, qna_project): + """Thanks to @heaths for this test!""" + filters = QueryFilters( + metadata_filter=MetadataFilter( + metadata=[ + ("explicitlytaggedheading", "check the battery level"), + ("explicitlytaggedheading", "make your battery last") + ], + ), + logical_operation=LogicalOperationKind.OR_ENUM + ) + async with QuestionAnsweringClient(qna_account, AzureKeyCredential(qna_key)) as client: + response = await client.query_knowledge_base( + project_name=qna_project, + deployment_name='test', + question="Battery life", + filters=filters, + top=3, + ) + assert len(response.answers) == 3 + assert any( + [a for a in response.answers if a.metadata.get('explicitlytaggedheading') == "check the battery level"] + ) + assert any( + [a for a in response.answers if a.metadata.get('explicitlytaggedheading') == "make your battery last"] + ) From 0d809e20377dd2036c93a7e6fc513141bed2743a Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Thu, 30 Sep 2021 11:53:01 -0400 Subject: [PATCH 15/20] rerecord and update tests to new behavior --- ...nowledgebase.test_query_knowledgebase.yaml | 20 ++++---- ...ebase.test_query_knowledgebase_filter.yaml | 6 +-- ...edgebase.test_query_knowledgebase_llc.yaml | 20 ++++---- ...ery_knowledgebase_llc_with_answerspan.yaml | 36 ++++++------- ...base.test_query_knowledgebase_only_id.yaml | 8 +-- ...ase.test_query_knowledgebase_overload.yaml | 23 +++------ ....test_query_knowledgebase_python_dict.yaml | 8 +-- ...t_query_knowledgebase_with_answerspan.yaml | 40 ++++++++------- ...t_query_knowledgebase_with_dictparams.yaml | 23 +++------ ...est_query_knowledgebase_with_followup.yaml | 51 ++++++++----------- ...gebase_async.test_query_knowledgebase.yaml | 20 ++++---- ...async.test_query_knowledgebase_filter.yaml | 6 +-- ...se_async.test_query_knowledgebase_llc.yaml | 20 ++++---- ...ery_knowledgebase_llc_with_answerspan.yaml | 40 ++++++++------- ...sync.test_query_knowledgebase_only_id.yaml | 8 +-- ...ync.test_query_knowledgebase_overload.yaml | 23 +++------ ....test_query_knowledgebase_python_dict.yaml | 8 +-- ...t_query_knowledgebase_with_answerspan.yaml | 40 ++++++++------- ...t_query_knowledgebase_with_dictparams.yaml | 23 +++------ ...est_query_knowledgebase_with_followup.yaml | 51 ++++++++----------- .../test_query_text.test_query_text.yaml | 24 ++++----- .../test_query_text.test_query_text_llc.yaml | 16 +++--- ...t_query_text.test_query_text_overload.yaml | 20 ++++---- ..._text.test_query_text_with_dictparams.yaml | 22 ++++---- ...text.test_query_text_with_str_records.yaml | 16 +++--- ...test_query_text_async.test_query_text.yaml | 22 ++++---- ..._query_text_async.test_query_text_llc.yaml | 16 +++--- ...y_text_async.test_query_text_overload.yaml | 14 ++--- ...async.test_query_text_with_dictparams.yaml | 22 ++++---- ...sync.test_query_text_with_str_records.yaml | 22 ++++---- .../tests/test_query_knowledgebase.py | 8 +-- .../tests/test_query_knowledgebase_async.py | 8 +-- 32 files changed, 327 insertions(+), 357 deletions(-) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase.yaml index afdbe07a2dba..1a5ee269c0f9 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase.yaml @@ -82,10 +82,10 @@ interactions: devices directly to your Surface Pro 4 using the USB port, Mini DisplayPort, or Bluetooth. Or, connect everything to a Surface Dock (sold separately). With Surface Dock, you can switch between fully connected and fully mobile - with a single connector.\",\n \"confidenceScore\": 0.46380000000000005,\n - \ \"id\": 64,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n - \ \"metadata\": {\n \"explicitlytaggedheading\": \"connect monitors, - accessories, and other devices\"\n },\n \"dialog\": {\n \"isContextOnly\": + with a single connector.\",\n \"confidenceScore\": 0.4067,\n \"id\": + 64,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": + {\n \"explicitlytaggedheading\": \"connect monitors, accessories, and + other devices\"\n },\n \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": [\n {\n \"displayOrder\": 0,\n \"qnaId\": 65,\n \"displayText\": \"Set up your workspace with Surface Dock\"\n },\n {\n \"displayOrder\": @@ -99,27 +99,27 @@ interactions: is for video only. Audio will play from your Surface speakers unless you\u2019ve connected external speakers. For more info about this, see [Surface sound,](http://www.microsoft.com/surface/support/hardware-and-drivers/sound-volume-and-speakers) [volume, and audio accessories](http://www.microsoft.com/surface/support/hardware-and-drivers/sound-volume-and-speakers) - on Surface.com.\",\n \"confidenceScore\": 0.4307,\n \"id\": 68,\n + on Surface.com.\",\n \"confidenceScore\": 0.3392,\n \"id\": 68,\n \ \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": {},\n \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": []\n }\n }\n ]\n}" headers: apim-request-id: - - af2f063d-0c1a-4be9-8022-4748b0b968f4 + - d0dc208c-60f1-4669-bddb-4522e3949ecf content-length: - - '7136' + - '7123' content-type: - application/json; charset=utf-8 csp-billing-usage: - - CognitiveServices.TextAnalytics.QuestionAnsweringTransaction=1 + - CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 date: - - Tue, 21 Sep 2021 21:06:29 GMT + - Thu, 30 Sep 2021 15:52:34 GMT strict-transport-security: - max-age=31536000; includeSubDomains; preload x-content-type-options: - nosniff x-envoy-upstream-service-time: - - '1908' + - '1273' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_filter.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_filter.yaml index 2fb633fa5635..29691ffe60eb 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_filter.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_filter.yaml @@ -45,7 +45,7 @@ interactions: \ ]\n}" headers: apim-request-id: - - d3b7407a-57b7-49c1-af6e-b6fc494f4bdb + - 7884df53-4df8-488a-b78c-692ac7f4f783 content-length: - '1622' content-type: @@ -53,13 +53,13 @@ interactions: csp-billing-usage: - CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 date: - - Thu, 30 Sep 2021 15:37:25 GMT + - Thu, 30 Sep 2021 15:52:33 GMT strict-transport-security: - max-age=31536000; includeSubDomains; preload x-content-type-options: - nosniff x-envoy-upstream-service-time: - - '902' + - '700' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_llc.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_llc.yaml index ae90e71dfc59..45d018962798 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_llc.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_llc.yaml @@ -82,10 +82,10 @@ interactions: devices directly to your Surface Pro 4 using the USB port, Mini DisplayPort, or Bluetooth. Or, connect everything to a Surface Dock (sold separately). With Surface Dock, you can switch between fully connected and fully mobile - with a single connector.\",\n \"confidenceScore\": 0.46380000000000005,\n - \ \"id\": 64,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n - \ \"metadata\": {\n \"explicitlytaggedheading\": \"connect monitors, - accessories, and other devices\"\n },\n \"dialog\": {\n \"isContextOnly\": + with a single connector.\",\n \"confidenceScore\": 0.4067,\n \"id\": + 64,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": + {\n \"explicitlytaggedheading\": \"connect monitors, accessories, and + other devices\"\n },\n \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": [\n {\n \"displayOrder\": 0,\n \"qnaId\": 65,\n \"displayText\": \"Set up your workspace with Surface Dock\"\n },\n {\n \"displayOrder\": @@ -99,27 +99,27 @@ interactions: is for video only. Audio will play from your Surface speakers unless you\u2019ve connected external speakers. For more info about this, see [Surface sound,](http://www.microsoft.com/surface/support/hardware-and-drivers/sound-volume-and-speakers) [volume, and audio accessories](http://www.microsoft.com/surface/support/hardware-and-drivers/sound-volume-and-speakers) - on Surface.com.\",\n \"confidenceScore\": 0.4307,\n \"id\": 68,\n + on Surface.com.\",\n \"confidenceScore\": 0.3392,\n \"id\": 68,\n \ \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": {},\n \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": []\n }\n }\n ]\n}" headers: apim-request-id: - - 09599054-e8a3-4df2-a441-897e59381452 + - 020d4cd9-b1fe-49ce-8ce1-e1f95aefbbf3 content-length: - - '7136' + - '7123' content-type: - application/json; charset=utf-8 csp-billing-usage: - - CognitiveServices.TextAnalytics.QuestionAnsweringTransaction=1 + - CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 date: - - Tue, 21 Sep 2021 21:06:30 GMT + - Thu, 30 Sep 2021 15:52:34 GMT strict-transport-security: - max-age=31536000; includeSubDomains; preload x-content-type-options: - nosniff x-envoy-upstream-service-time: - - '493' + - '1590' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_llc_with_answerspan.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_llc_with_answerspan.yaml index 08f52c0c598e..525c23f2acd1 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_llc_with_answerspan.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_llc_with_answerspan.yaml @@ -77,18 +77,18 @@ interactions: \ \"qnaId\": 8,\n \"displayText\": \"Memory and storage\"\n \ },\n {\n \"displayOrder\": 3,\n \"qnaId\": 9,\n \"displayText\": \"Sensors\"\n }\n ]\n },\n - \ \"answerSpan\": {\n \"text\": \"**Ports and connectors**\\n\\nSurface - Pro 4 has the ports you expect in a full-feature laptop.\\n\\nFull-size USB - 3.0 port Connect a USB accessory like a mouse, printer, Ethernet adapter, - USB drive, or smartphone.\",\n \"confidenceScore\": 0.0106,\n \"offset\": - 0,\n \"length\": 206\n }\n },\n {\n \"questions\": - [\n \"Connect monitors, accessories, and other devices\"\n ],\n - \ \"answer\": \"**Connect monitors, accessories, and other devices**\\n\\nYou - can connect monitors, accessories, and other devices directly to your Surface - Pro 4 using the USB port, Mini DisplayPort, or Bluetooth. Or, connect everything - to a Surface Dock (sold separately). With Surface Dock, you can switch between - fully connected and fully mobile with a single connector.\",\n \"confidenceScore\": - 0.46380000000000005,\n \"id\": 64,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n + \ \"answerSpan\": {\n \"text\": \"\\nSurface Pro 4 has the ports + you expect in a full-feature laptop.\\n\\nFull-size USB 3.0 port Connect a + USB accessory like a mouse, printer, Ethernet adapter, USB drive, or smartphone\",\n + \ \"confidenceScore\": 0.5141,\n \"offset\": 25,\n \"length\": + 180\n }\n },\n {\n \"questions\": [\n \"Connect monitors, + accessories, and other devices\"\n ],\n \"answer\": \"**Connect + monitors, accessories, and other devices**\\n\\nYou can connect monitors, + accessories, and other devices directly to your Surface Pro 4 using the USB + port, Mini DisplayPort, or Bluetooth. Or, connect everything to a Surface + Dock (sold separately). With Surface Dock, you can switch between fully connected + and fully mobile with a single connector.\",\n \"confidenceScore\": 0.4067,\n + \ \"id\": 64,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \ \"metadata\": {\n \"explicitlytaggedheading\": \"connect monitors, accessories, and other devices\"\n },\n \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": [\n {\n \"displayOrder\": @@ -104,27 +104,27 @@ interactions: is for video only. Audio will play from your Surface speakers unless you\u2019ve connected external speakers. For more info about this, see [Surface sound,](http://www.microsoft.com/surface/support/hardware-and-drivers/sound-volume-and-speakers) [volume, and audio accessories](http://www.microsoft.com/surface/support/hardware-and-drivers/sound-volume-and-speakers) - on Surface.com.\",\n \"confidenceScore\": 0.4307,\n \"id\": 68,\n + on Surface.com.\",\n \"confidenceScore\": 0.3392,\n \"id\": 68,\n \ \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": {},\n \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": []\n }\n }\n ]\n}" headers: apim-request-id: - - 7d3e4c75-318d-47ac-a24f-0e6839903f5d + - 8ab8a1da-8fd6-4091-80e3-470885a6b2b7 content-length: - - '7474' + - '7435' content-type: - application/json; charset=utf-8 csp-billing-usage: - - CognitiveServices.TextAnalytics.QuestionAnsweringTransaction=1 + - CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 date: - - Tue, 21 Sep 2021 21:06:32 GMT + - Thu, 30 Sep 2021 15:52:35 GMT strict-transport-security: - max-age=31536000; includeSubDomains; preload x-content-type-options: - nosniff x-envoy-upstream-service-time: - - '902' + - '2624' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_only_id.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_only_id.yaml index b82688010904..e6932c6c456c 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_only_id.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_only_id.yaml @@ -29,21 +29,21 @@ interactions: []\n }\n }\n ]\n}" headers: apim-request-id: - - e03a4af6-be5a-4515-a848-981ca32279a2 + - 4f01bfd0-6d10-4fbd-a02c-81160bc374d2 content-length: - '583' content-type: - application/json; charset=utf-8 csp-billing-usage: - - CognitiveServices.TextAnalytics.QuestionAnsweringTransaction=1 + - CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 date: - - Tue, 21 Sep 2021 21:06:33 GMT + - Thu, 30 Sep 2021 15:52:34 GMT strict-transport-security: - max-age=31536000; includeSubDomains; preload x-content-type-options: - nosniff x-envoy-upstream-service-time: - - '337' + - '1071' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_overload.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_overload.yaml index e848833ab31d..e3d3aacec340 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_overload.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_overload.yaml @@ -25,41 +25,34 @@ interactions: your battery last\"\n ],\n \"answer\": \"**Make your battery last**\\n\\nFor info on how to care for your battery and power supply, conserve power, and make your Surface battery last longer, see [Surface battery and power](http://www.microsoft.com/surface/support/hardware-and-drivers/battery-and-power) - on Surface.com.\",\n \"confidenceScore\": 0.9290999999999999,\n \"id\": + on Surface.com.\",\n \"confidenceScore\": 0.9201999999999999,\n \"id\": 27,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": {\n \"explicitlytaggedheading\": \"make your battery last\"\n },\n \ \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": []\n }\n },\n {\n \"questions\": [\n \"Check the battery level\"\n ],\n \"answer\": \"**Check the battery level**\\n\\nYou can check the battery level from the lock screen or the desktop:\",\n \"confidenceScore\": - 0.3069,\n \"id\": 24,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n + 0.4412,\n \"id\": 24,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \ \"metadata\": {\n \"explicitlytaggedheading\": \"check the battery level\"\n },\n \"dialog\": {\n \"isContextOnly\": false,\n - \ \"prompts\": []\n }\n },\n {\n \"questions\": [\n - \ \"Desktop taskbar.\"\n ],\n \"answer\": \"**Desktop taskbar.**\\n\\nBattery - status appears at the right side of the taskbar. Select the battery icon for - info about the charging and battery status, including the percent remaining. - \u272A\",\n \"confidenceScore\": 0.2548,\n \"id\": 26,\n \"source\": - \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": {},\n \"dialog\": - {\n \"isContextOnly\": false,\n \"prompts\": []\n }\n }\n - \ ]\n}" + \ \"prompts\": []\n }\n }\n ]\n}" headers: apim-request-id: - - 8740053b-e4fa-4394-ba6c-28d0b064703c + - f02239ca-4edc-4348-b5d6-b3023765bddb content-length: - - '1621' + - '1140' content-type: - application/json; charset=utf-8 csp-billing-usage: - - CognitiveServices.TextAnalytics.QuestionAnsweringTransaction=1 + - CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 date: - - Tue, 21 Sep 2021 21:06:35 GMT + - Thu, 30 Sep 2021 15:52:34 GMT strict-transport-security: - max-age=31536000; includeSubDomains; preload x-content-type-options: - nosniff x-envoy-upstream-service-time: - - '395' + - '916' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_python_dict.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_python_dict.yaml index 3235745609d1..041d14502a21 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_python_dict.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_python_dict.yaml @@ -29,21 +29,21 @@ interactions: []\n }\n }\n ]\n}" headers: apim-request-id: - - 713fabed-16c6-4c14-858e-099bcfa4cbfc + - 845c4b78-915e-484c-af56-56ae05539a6e content-length: - '583' content-type: - application/json; charset=utf-8 csp-billing-usage: - - CognitiveServices.TextAnalytics.QuestionAnsweringTransaction=1 + - CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 date: - - Tue, 21 Sep 2021 21:06:36 GMT + - Thu, 30 Sep 2021 15:52:34 GMT strict-transport-security: - max-age=31536000; includeSubDomains; preload x-content-type-options: - nosniff x-envoy-upstream-service-time: - - '153' + - '1099' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_with_answerspan.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_with_answerspan.yaml index 7815ea378e3d..f90bbb484e56 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_with_answerspan.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_with_answerspan.yaml @@ -77,18 +77,18 @@ interactions: \ \"qnaId\": 8,\n \"displayText\": \"Memory and storage\"\n \ },\n {\n \"displayOrder\": 3,\n \"qnaId\": 9,\n \"displayText\": \"Sensors\"\n }\n ]\n },\n - \ \"answerSpan\": {\n \"text\": \"**Ports and connectors**\\n\\nSurface - Pro 4 has the ports you expect in a full-feature laptop.\\n\\nFull-size USB - 3.0 port Connect a USB accessory like a mouse, printer, Ethernet adapter, - USB drive, or smartphone.\",\n \"confidenceScore\": 0.0106,\n \"offset\": - 0,\n \"length\": 206\n }\n },\n {\n \"questions\": - [\n \"Connect monitors, accessories, and other devices\"\n ],\n - \ \"answer\": \"**Connect monitors, accessories, and other devices**\\n\\nYou - can connect monitors, accessories, and other devices directly to your Surface - Pro 4 using the USB port, Mini DisplayPort, or Bluetooth. Or, connect everything - to a Surface Dock (sold separately). With Surface Dock, you can switch between - fully connected and fully mobile with a single connector.\",\n \"confidenceScore\": - 0.46380000000000005,\n \"id\": 64,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n + \ \"answerSpan\": {\n \"text\": \"\\nSurface Pro 4 has the ports + you expect in a full-feature laptop.\\n\\nFull-size USB 3.0 port Connect a + USB accessory like a mouse, printer, Ethernet adapter, USB drive, or smartphone\",\n + \ \"confidenceScore\": 0.5141,\n \"offset\": 25,\n \"length\": + 180\n }\n },\n {\n \"questions\": [\n \"Connect monitors, + accessories, and other devices\"\n ],\n \"answer\": \"**Connect + monitors, accessories, and other devices**\\n\\nYou can connect monitors, + accessories, and other devices directly to your Surface Pro 4 using the USB + port, Mini DisplayPort, or Bluetooth. Or, connect everything to a Surface + Dock (sold separately). With Surface Dock, you can switch between fully connected + and fully mobile with a single connector.\",\n \"confidenceScore\": 0.4067,\n + \ \"id\": 64,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \ \"metadata\": {\n \"explicitlytaggedheading\": \"connect monitors, accessories, and other devices\"\n },\n \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": [\n {\n \"displayOrder\": @@ -96,6 +96,10 @@ interactions: workspace with Surface Dock\"\n },\n {\n \"displayOrder\": 1,\n \"qnaId\": 66,\n \"displayText\": \"Connect or project to a monitor, screen, or other display\"\n }\n ]\n + \ },\n \"answerSpan\": {\n \"text\": \"\\nYou can connect + monitors, accessories, and other devices directly to your Surface Pro 4 using + the USB port, Mini DisplayPort, or Bluetooth\",\n \"confidenceScore\": + 0.051399999999999994,\n \"offset\": 53,\n \"length\": 140\n \ }\n },\n {\n \"questions\": [\n \"Projector or monitor.\"\n \ ],\n \"answer\": \"If your monitor has a DisplayPort, you can connect it to your Surface using a DisplayPort to Mini DisplayPort cable (sold separately). @@ -104,27 +108,27 @@ interactions: is for video only. Audio will play from your Surface speakers unless you\u2019ve connected external speakers. For more info about this, see [Surface sound,](http://www.microsoft.com/surface/support/hardware-and-drivers/sound-volume-and-speakers) [volume, and audio accessories](http://www.microsoft.com/surface/support/hardware-and-drivers/sound-volume-and-speakers) - on Surface.com.\",\n \"confidenceScore\": 0.4307,\n \"id\": 68,\n + on Surface.com.\",\n \"confidenceScore\": 0.3392,\n \"id\": 68,\n \ \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": {},\n \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": []\n }\n }\n ]\n}" headers: apim-request-id: - - 0eb4c00c-dd83-45be-8d96-aba3077392c2 + - 33feb3cb-5959-4ca7-97de-8c95847f517e content-length: - - '7474' + - '7719' content-type: - application/json; charset=utf-8 csp-billing-usage: - - CognitiveServices.TextAnalytics.QuestionAnsweringTransaction=1 + - CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 date: - - Tue, 21 Sep 2021 21:06:37 GMT + - Thu, 30 Sep 2021 15:52:34 GMT strict-transport-security: - max-age=31536000; includeSubDomains; preload x-content-type-options: - nosniff x-envoy-upstream-service-time: - - '342' + - '1270' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_with_dictparams.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_with_dictparams.yaml index 9992a6c804fe..459558c35245 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_with_dictparams.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_with_dictparams.yaml @@ -25,41 +25,34 @@ interactions: your battery last\"\n ],\n \"answer\": \"**Make your battery last**\\n\\nFor info on how to care for your battery and power supply, conserve power, and make your Surface battery last longer, see [Surface battery and power](http://www.microsoft.com/surface/support/hardware-and-drivers/battery-and-power) - on Surface.com.\",\n \"confidenceScore\": 0.9290999999999999,\n \"id\": + on Surface.com.\",\n \"confidenceScore\": 0.9201999999999999,\n \"id\": 27,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": {\n \"explicitlytaggedheading\": \"make your battery last\"\n },\n \ \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": []\n }\n },\n {\n \"questions\": [\n \"Check the battery level\"\n ],\n \"answer\": \"**Check the battery level**\\n\\nYou can check the battery level from the lock screen or the desktop:\",\n \"confidenceScore\": - 0.3069,\n \"id\": 24,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n + 0.4412,\n \"id\": 24,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \ \"metadata\": {\n \"explicitlytaggedheading\": \"check the battery level\"\n },\n \"dialog\": {\n \"isContextOnly\": false,\n - \ \"prompts\": []\n }\n },\n {\n \"questions\": [\n - \ \"Desktop taskbar.\"\n ],\n \"answer\": \"**Desktop taskbar.**\\n\\nBattery - status appears at the right side of the taskbar. Select the battery icon for - info about the charging and battery status, including the percent remaining. - \u272A\",\n \"confidenceScore\": 0.2548,\n \"id\": 26,\n \"source\": - \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": {},\n \"dialog\": - {\n \"isContextOnly\": false,\n \"prompts\": []\n }\n }\n - \ ]\n}" + \ \"prompts\": []\n }\n }\n ]\n}" headers: apim-request-id: - - 5b72cd45-d5b9-492c-ad05-7172c2ae070d + - 1f863859-4839-430b-9e06-3461d04f010e content-length: - - '1621' + - '1140' content-type: - application/json; charset=utf-8 csp-billing-usage: - - CognitiveServices.TextAnalytics.QuestionAnsweringTransaction=1 + - CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 date: - - Tue, 21 Sep 2021 21:06:38 GMT + - Thu, 30 Sep 2021 15:52:35 GMT strict-transport-security: - max-age=31536000; includeSubDomains; preload x-content-type-options: - nosniff x-envoy-upstream-service-time: - - '365' + - '2626' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_with_followup.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_with_followup.yaml index 72af1ce6d157..96d3a557c24b 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_with_followup.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_with_followup.yaml @@ -25,41 +25,34 @@ interactions: your battery last\"\n ],\n \"answer\": \"**Make your battery last**\\n\\nFor info on how to care for your battery and power supply, conserve power, and make your Surface battery last longer, see [Surface battery and power](http://www.microsoft.com/surface/support/hardware-and-drivers/battery-and-power) - on Surface.com.\",\n \"confidenceScore\": 0.9290999999999999,\n \"id\": + on Surface.com.\",\n \"confidenceScore\": 0.9201999999999999,\n \"id\": 27,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": {\n \"explicitlytaggedheading\": \"make your battery last\"\n },\n \ \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": []\n }\n },\n {\n \"questions\": [\n \"Check the battery level\"\n ],\n \"answer\": \"**Check the battery level**\\n\\nYou can check the battery level from the lock screen or the desktop:\",\n \"confidenceScore\": - 0.3069,\n \"id\": 24,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n + 0.4412,\n \"id\": 24,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \ \"metadata\": {\n \"explicitlytaggedheading\": \"check the battery level\"\n },\n \"dialog\": {\n \"isContextOnly\": false,\n - \ \"prompts\": []\n }\n },\n {\n \"questions\": [\n - \ \"Desktop taskbar.\"\n ],\n \"answer\": \"**Desktop taskbar.**\\n\\nBattery - status appears at the right side of the taskbar. Select the battery icon for - info about the charging and battery status, including the percent remaining. - \u272A\",\n \"confidenceScore\": 0.2548,\n \"id\": 26,\n \"source\": - \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": {},\n \"dialog\": - {\n \"isContextOnly\": false,\n \"prompts\": []\n }\n }\n - \ ]\n}" + \ \"prompts\": []\n }\n }\n ]\n}" headers: apim-request-id: - - 555d76da-0f60-4c4c-8a93-2f3e263ca9c0 + - 227983f1-c75e-4ee2-910d-589011a7a251 content-length: - - '1621' + - '1140' content-type: - application/json; charset=utf-8 csp-billing-usage: - - CognitiveServices.TextAnalytics.QuestionAnsweringTransaction=1 + - CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 date: - - Tue, 21 Sep 2021 21:06:39 GMT + - Thu, 30 Sep 2021 15:52:35 GMT strict-transport-security: - max-age=31536000; includeSubDomains; preload x-content-type-options: - nosniff x-envoy-upstream-service-time: - - '322' + - '2660' status: code: 200 message: OK @@ -95,7 +88,7 @@ interactions: like a phone, while your Surface charges. The USB port on the power supply is only for charging, not for data transfer. If you want to use a USB device, plug it into the USB port on your Surface.\",\n \"confidenceScore\": - 0.6517000000000001,\n \"id\": 23,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n + 0.5296,\n \"id\": 23,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \ \"metadata\": {\n \"explicitlytaggedheading\": \"power and charging\"\n \ },\n \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": [\n {\n \"displayOrder\": 0,\n \"qnaId\": 24,\n @@ -105,34 +98,34 @@ interactions: 2,\n \"qnaId\": 26,\n \"displayText\": \"Desktop taskbar.\"\n \ },\n {\n \"displayOrder\": 3,\n \"qnaId\": 27,\n \"displayText\": \"Make your battery last\"\n }\n - \ ]\n },\n \"answerSpan\": {\n \"text\": \"two to four - hours\",\n \"confidenceScore\": 0.3086,\n \"offset\": 33,\n - \ \"length\": 18\n }\n },\n {\n \"questions\": [\n \"Charge + \ ]\n },\n \"answerSpan\": {\n \"text\": \" two to + four hours\",\n \"confidenceScore\": 0.3795,\n \"offset\": 32,\n + \ \"length\": 19\n }\n },\n {\n \"questions\": [\n \"Charge your Surface Pro 4\"\n ],\n \"answer\": \"**Charge your Surface Pro 4**\\n\\n1. Connect the two parts of the power cord.\\n\\n2. Connect the power cord securely to the charging port.\\n\\n3. Plug the power supply - into an electrical outlet.\",\n \"confidenceScore\": 0.30260000000000004,\n - \ \"id\": 19,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n - \ \"metadata\": {\n \"explicitlytaggedheading\": \"charge your - surface pro 4\"\n },\n \"dialog\": {\n \"isContextOnly\": - false,\n \"prompts\": []\n }\n }\n ]\n}" + into an electrical outlet.\",\n \"confidenceScore\": 0.2707,\n \"id\": + 19,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": + {\n \"explicitlytaggedheading\": \"charge your surface pro 4\"\n },\n + \ \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": + []\n }\n }\n ]\n}" headers: apim-request-id: - - 9ef0bd69-7736-4ed5-8c21-879df23aaa47 + - f95352a5-4e6d-4ec1-8809-d164a774dfe6 content-length: - - '2178' + - '2154' content-type: - application/json; charset=utf-8 csp-billing-usage: - - CognitiveServices.TextAnalytics.QuestionAnsweringTransaction=1 + - CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 date: - - Tue, 21 Sep 2021 21:06:41 GMT + - Thu, 30 Sep 2021 15:52:35 GMT strict-transport-security: - max-age=31536000; includeSubDomains; preload x-content-type-options: - nosniff x-envoy-upstream-service-time: - - '1046' + - '509' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase.yaml index bf7d70f91563..e522576f82a0 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase.yaml @@ -78,10 +78,10 @@ interactions: devices directly to your Surface Pro 4 using the USB port, Mini DisplayPort, or Bluetooth. Or, connect everything to a Surface Dock (sold separately). With Surface Dock, you can switch between fully connected and fully mobile - with a single connector.\",\n \"confidenceScore\": 0.46380000000000005,\n - \ \"id\": 64,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n - \ \"metadata\": {\n \"explicitlytaggedheading\": \"connect monitors, - accessories, and other devices\"\n },\n \"dialog\": {\n \"isContextOnly\": + with a single connector.\",\n \"confidenceScore\": 0.4067,\n \"id\": + 64,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": + {\n \"explicitlytaggedheading\": \"connect monitors, accessories, and + other devices\"\n },\n \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": [\n {\n \"displayOrder\": 0,\n \"qnaId\": 65,\n \"displayText\": \"Set up your workspace with Surface Dock\"\n },\n {\n \"displayOrder\": @@ -95,19 +95,19 @@ interactions: is for video only. Audio will play from your Surface speakers unless you\u2019ve connected external speakers. For more info about this, see [Surface sound,](http://www.microsoft.com/surface/support/hardware-and-drivers/sound-volume-and-speakers) [volume, and audio accessories](http://www.microsoft.com/surface/support/hardware-and-drivers/sound-volume-and-speakers) - on Surface.com.\",\n \"confidenceScore\": 0.4307,\n \"id\": 68,\n + on Surface.com.\",\n \"confidenceScore\": 0.3392,\n \"id\": 68,\n \ \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": {},\n \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": []\n }\n }\n ]\n}" headers: - apim-request-id: ef43aa6b-709e-4d07-a1ca-c4cf33586fc6 - content-length: '7136' + apim-request-id: 5971ea57-2aa9-4179-bda9-aba6b937380f + content-length: '7123' content-type: application/json; charset=utf-8 - csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTransaction=1 - date: Tue, 21 Sep 2021 21:06:43 GMT + csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 + date: Thu, 30 Sep 2021 15:52:36 GMT strict-transport-security: max-age=31536000; includeSubDomains; preload x-content-type-options: nosniff - x-envoy-upstream-service-time: '284' + x-envoy-upstream-service-time: '1153' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_filter.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_filter.yaml index 223d22e7228f..abb85ac4c446 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_filter.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_filter.yaml @@ -40,14 +40,14 @@ interactions: {\n \"isContextOnly\": false,\n \"prompts\": []\n }\n }\n \ ]\n}" headers: - apim-request-id: c381395f-d6a2-4c9c-9cd8-f80373269209 + apim-request-id: e958c124-6d15-41c7-93a5-0a242f6b01b1 content-length: '1622' content-type: application/json; charset=utf-8 csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 - date: Thu, 30 Sep 2021 15:37:26 GMT + date: Thu, 30 Sep 2021 15:52:35 GMT strict-transport-security: max-age=31536000; includeSubDomains; preload x-content-type-options: nosniff - x-envoy-upstream-service-time: '384' + x-envoy-upstream-service-time: '1503' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_llc.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_llc.yaml index 0de1a13a3c4b..f5d1f2db923a 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_llc.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_llc.yaml @@ -78,10 +78,10 @@ interactions: devices directly to your Surface Pro 4 using the USB port, Mini DisplayPort, or Bluetooth. Or, connect everything to a Surface Dock (sold separately). With Surface Dock, you can switch between fully connected and fully mobile - with a single connector.\",\n \"confidenceScore\": 0.46380000000000005,\n - \ \"id\": 64,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n - \ \"metadata\": {\n \"explicitlytaggedheading\": \"connect monitors, - accessories, and other devices\"\n },\n \"dialog\": {\n \"isContextOnly\": + with a single connector.\",\n \"confidenceScore\": 0.4067,\n \"id\": + 64,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": + {\n \"explicitlytaggedheading\": \"connect monitors, accessories, and + other devices\"\n },\n \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": [\n {\n \"displayOrder\": 0,\n \"qnaId\": 65,\n \"displayText\": \"Set up your workspace with Surface Dock\"\n },\n {\n \"displayOrder\": @@ -95,19 +95,19 @@ interactions: is for video only. Audio will play from your Surface speakers unless you\u2019ve connected external speakers. For more info about this, see [Surface sound,](http://www.microsoft.com/surface/support/hardware-and-drivers/sound-volume-and-speakers) [volume, and audio accessories](http://www.microsoft.com/surface/support/hardware-and-drivers/sound-volume-and-speakers) - on Surface.com.\",\n \"confidenceScore\": 0.4307,\n \"id\": 68,\n + on Surface.com.\",\n \"confidenceScore\": 0.3392,\n \"id\": 68,\n \ \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": {},\n \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": []\n }\n }\n ]\n}" headers: - apim-request-id: 1833a5eb-5934-4f16-abab-46148ceb44a1 - content-length: '7136' + apim-request-id: f2cf1974-868f-42c6-b183-ff7f5df0ebe4 + content-length: '7123' content-type: application/json; charset=utf-8 - csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTransaction=1 - date: Tue, 21 Sep 2021 21:06:46 GMT + csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 + date: Thu, 30 Sep 2021 15:52:35 GMT strict-transport-security: max-age=31536000; includeSubDomains; preload x-content-type-options: nosniff - x-envoy-upstream-service-time: '276' + x-envoy-upstream-service-time: '519' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_llc_with_answerspan.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_llc_with_answerspan.yaml index cc075a6d8e6f..862b6d6d3678 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_llc_with_answerspan.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_llc_with_answerspan.yaml @@ -73,18 +73,18 @@ interactions: \ \"qnaId\": 8,\n \"displayText\": \"Memory and storage\"\n \ },\n {\n \"displayOrder\": 3,\n \"qnaId\": 9,\n \"displayText\": \"Sensors\"\n }\n ]\n },\n - \ \"answerSpan\": {\n \"text\": \"**Ports and connectors**\\n\\nSurface - Pro 4 has the ports you expect in a full-feature laptop.\\n\\nFull-size USB - 3.0 port Connect a USB accessory like a mouse, printer, Ethernet adapter, - USB drive, or smartphone.\",\n \"confidenceScore\": 0.0106,\n \"offset\": - 0,\n \"length\": 206\n }\n },\n {\n \"questions\": - [\n \"Connect monitors, accessories, and other devices\"\n ],\n - \ \"answer\": \"**Connect monitors, accessories, and other devices**\\n\\nYou - can connect monitors, accessories, and other devices directly to your Surface - Pro 4 using the USB port, Mini DisplayPort, or Bluetooth. Or, connect everything - to a Surface Dock (sold separately). With Surface Dock, you can switch between - fully connected and fully mobile with a single connector.\",\n \"confidenceScore\": - 0.46380000000000005,\n \"id\": 64,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n + \ \"answerSpan\": {\n \"text\": \"\\nSurface Pro 4 has the ports + you expect in a full-feature laptop.\\n\\nFull-size USB 3.0 port Connect a + USB accessory like a mouse, printer, Ethernet adapter, USB drive, or smartphone\",\n + \ \"confidenceScore\": 0.5141,\n \"offset\": 25,\n \"length\": + 180\n }\n },\n {\n \"questions\": [\n \"Connect monitors, + accessories, and other devices\"\n ],\n \"answer\": \"**Connect + monitors, accessories, and other devices**\\n\\nYou can connect monitors, + accessories, and other devices directly to your Surface Pro 4 using the USB + port, Mini DisplayPort, or Bluetooth. Or, connect everything to a Surface + Dock (sold separately). With Surface Dock, you can switch between fully connected + and fully mobile with a single connector.\",\n \"confidenceScore\": 0.4067,\n + \ \"id\": 64,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \ \"metadata\": {\n \"explicitlytaggedheading\": \"connect monitors, accessories, and other devices\"\n },\n \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": [\n {\n \"displayOrder\": @@ -92,6 +92,10 @@ interactions: workspace with Surface Dock\"\n },\n {\n \"displayOrder\": 1,\n \"qnaId\": 66,\n \"displayText\": \"Connect or project to a monitor, screen, or other display\"\n }\n ]\n + \ },\n \"answerSpan\": {\n \"text\": \"\\nYou can connect + monitors, accessories, and other devices directly to your Surface Pro 4 using + the USB port, Mini DisplayPort, or Bluetooth\",\n \"confidenceScore\": + 0.051399999999999994,\n \"offset\": 53,\n \"length\": 140\n \ }\n },\n {\n \"questions\": [\n \"Projector or monitor.\"\n \ ],\n \"answer\": \"If your monitor has a DisplayPort, you can connect it to your Surface using a DisplayPort to Mini DisplayPort cable (sold separately). @@ -100,19 +104,19 @@ interactions: is for video only. Audio will play from your Surface speakers unless you\u2019ve connected external speakers. For more info about this, see [Surface sound,](http://www.microsoft.com/surface/support/hardware-and-drivers/sound-volume-and-speakers) [volume, and audio accessories](http://www.microsoft.com/surface/support/hardware-and-drivers/sound-volume-and-speakers) - on Surface.com.\",\n \"confidenceScore\": 0.4307,\n \"id\": 68,\n + on Surface.com.\",\n \"confidenceScore\": 0.3392,\n \"id\": 68,\n \ \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": {},\n \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": []\n }\n }\n ]\n}" headers: - apim-request-id: 3dbc4527-4e20-44b3-abbe-d380ea18ef2c - content-length: '7474' + apim-request-id: ec633ba0-764f-4865-8e8b-69ffbc1f74f5 + content-length: '7719' content-type: application/json; charset=utf-8 - csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTransaction=1 - date: Tue, 21 Sep 2021 21:06:47 GMT + csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 + date: Thu, 30 Sep 2021 15:52:37 GMT strict-transport-security: max-age=31536000; includeSubDomains; preload x-content-type-options: nosniff - x-envoy-upstream-service-time: '300' + x-envoy-upstream-service-time: '663' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_only_id.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_only_id.yaml index 7f4f92ee521c..c46b8b79716e 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_only_id.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_only_id.yaml @@ -24,14 +24,14 @@ interactions: \ \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": []\n }\n }\n ]\n}" headers: - apim-request-id: 24be7932-f7a1-4019-8472-32c2551d1d6e + apim-request-id: 824a47b2-1f4a-4056-8c26-ddba66a21497 content-length: '583' content-type: application/json; charset=utf-8 - csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTransaction=1 - date: Tue, 21 Sep 2021 21:06:49 GMT + csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 + date: Thu, 30 Sep 2021 15:52:35 GMT strict-transport-security: max-age=31536000; includeSubDomains; preload x-content-type-options: nosniff - x-envoy-upstream-service-time: '132' + x-envoy-upstream-service-time: '879' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_overload.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_overload.yaml index a258665e5354..c4cf69673348 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_overload.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_overload.yaml @@ -21,33 +21,26 @@ interactions: your battery last\"\n ],\n \"answer\": \"**Make your battery last**\\n\\nFor info on how to care for your battery and power supply, conserve power, and make your Surface battery last longer, see [Surface battery and power](http://www.microsoft.com/surface/support/hardware-and-drivers/battery-and-power) - on Surface.com.\",\n \"confidenceScore\": 0.9290999999999999,\n \"id\": + on Surface.com.\",\n \"confidenceScore\": 0.9201999999999999,\n \"id\": 27,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": {\n \"explicitlytaggedheading\": \"make your battery last\"\n },\n \ \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": []\n }\n },\n {\n \"questions\": [\n \"Check the battery level\"\n ],\n \"answer\": \"**Check the battery level**\\n\\nYou can check the battery level from the lock screen or the desktop:\",\n \"confidenceScore\": - 0.3069,\n \"id\": 24,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n + 0.4412,\n \"id\": 24,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \ \"metadata\": {\n \"explicitlytaggedheading\": \"check the battery level\"\n },\n \"dialog\": {\n \"isContextOnly\": false,\n - \ \"prompts\": []\n }\n },\n {\n \"questions\": [\n - \ \"Desktop taskbar.\"\n ],\n \"answer\": \"**Desktop taskbar.**\\n\\nBattery - status appears at the right side of the taskbar. Select the battery icon for - info about the charging and battery status, including the percent remaining. - \u272A\",\n \"confidenceScore\": 0.2548,\n \"id\": 26,\n \"source\": - \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": {},\n \"dialog\": - {\n \"isContextOnly\": false,\n \"prompts\": []\n }\n }\n - \ ]\n}" + \ \"prompts\": []\n }\n }\n ]\n}" headers: - apim-request-id: 8aa31a73-6acd-4f7a-85c2-dcecc522ae32 - content-length: '1621' + apim-request-id: cd3dad50-3644-4273-afc0-442c50d22419 + content-length: '1140' content-type: application/json; charset=utf-8 - csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTransaction=1 - date: Tue, 21 Sep 2021 21:06:50 GMT + csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 + date: Thu, 30 Sep 2021 15:52:35 GMT strict-transport-security: max-age=31536000; includeSubDomains; preload x-content-type-options: nosniff - x-envoy-upstream-service-time: '328' + x-envoy-upstream-service-time: '1047' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_python_dict.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_python_dict.yaml index 84d90331cb91..2b3cc394ee2c 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_python_dict.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_python_dict.yaml @@ -24,14 +24,14 @@ interactions: \ \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": []\n }\n }\n ]\n}" headers: - apim-request-id: c6c85372-bf1f-4f8c-98ce-8de52137882a + apim-request-id: 9980db27-58c1-485e-995a-933a4e41e08c content-length: '583' content-type: application/json; charset=utf-8 - csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTransaction=1 - date: Tue, 21 Sep 2021 21:06:51 GMT + csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 + date: Thu, 30 Sep 2021 15:52:34 GMT strict-transport-security: max-age=31536000; includeSubDomains; preload x-content-type-options: nosniff - x-envoy-upstream-service-time: '139' + x-envoy-upstream-service-time: '135' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_with_answerspan.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_with_answerspan.yaml index df113eda18b8..8e6127f52048 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_with_answerspan.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_with_answerspan.yaml @@ -73,18 +73,18 @@ interactions: \ \"qnaId\": 8,\n \"displayText\": \"Memory and storage\"\n \ },\n {\n \"displayOrder\": 3,\n \"qnaId\": 9,\n \"displayText\": \"Sensors\"\n }\n ]\n },\n - \ \"answerSpan\": {\n \"text\": \"**Ports and connectors**\\n\\nSurface - Pro 4 has the ports you expect in a full-feature laptop.\\n\\nFull-size USB - 3.0 port Connect a USB accessory like a mouse, printer, Ethernet adapter, - USB drive, or smartphone.\",\n \"confidenceScore\": 0.0106,\n \"offset\": - 0,\n \"length\": 206\n }\n },\n {\n \"questions\": - [\n \"Connect monitors, accessories, and other devices\"\n ],\n - \ \"answer\": \"**Connect monitors, accessories, and other devices**\\n\\nYou - can connect monitors, accessories, and other devices directly to your Surface - Pro 4 using the USB port, Mini DisplayPort, or Bluetooth. Or, connect everything - to a Surface Dock (sold separately). With Surface Dock, you can switch between - fully connected and fully mobile with a single connector.\",\n \"confidenceScore\": - 0.46380000000000005,\n \"id\": 64,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n + \ \"answerSpan\": {\n \"text\": \"\\nSurface Pro 4 has the ports + you expect in a full-feature laptop.\\n\\nFull-size USB 3.0 port Connect a + USB accessory like a mouse, printer, Ethernet adapter, USB drive, or smartphone\",\n + \ \"confidenceScore\": 0.5141,\n \"offset\": 25,\n \"length\": + 180\n }\n },\n {\n \"questions\": [\n \"Connect monitors, + accessories, and other devices\"\n ],\n \"answer\": \"**Connect + monitors, accessories, and other devices**\\n\\nYou can connect monitors, + accessories, and other devices directly to your Surface Pro 4 using the USB + port, Mini DisplayPort, or Bluetooth. Or, connect everything to a Surface + Dock (sold separately). With Surface Dock, you can switch between fully connected + and fully mobile with a single connector.\",\n \"confidenceScore\": 0.4067,\n + \ \"id\": 64,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \ \"metadata\": {\n \"explicitlytaggedheading\": \"connect monitors, accessories, and other devices\"\n },\n \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": [\n {\n \"displayOrder\": @@ -92,6 +92,10 @@ interactions: workspace with Surface Dock\"\n },\n {\n \"displayOrder\": 1,\n \"qnaId\": 66,\n \"displayText\": \"Connect or project to a monitor, screen, or other display\"\n }\n ]\n + \ },\n \"answerSpan\": {\n \"text\": \"\\nYou can connect + monitors, accessories, and other devices directly to your Surface Pro 4 using + the USB port, Mini DisplayPort, or Bluetooth\",\n \"confidenceScore\": + 0.051399999999999994,\n \"offset\": 53,\n \"length\": 140\n \ }\n },\n {\n \"questions\": [\n \"Projector or monitor.\"\n \ ],\n \"answer\": \"If your monitor has a DisplayPort, you can connect it to your Surface using a DisplayPort to Mini DisplayPort cable (sold separately). @@ -100,19 +104,19 @@ interactions: is for video only. Audio will play from your Surface speakers unless you\u2019ve connected external speakers. For more info about this, see [Surface sound,](http://www.microsoft.com/surface/support/hardware-and-drivers/sound-volume-and-speakers) [volume, and audio accessories](http://www.microsoft.com/surface/support/hardware-and-drivers/sound-volume-and-speakers) - on Surface.com.\",\n \"confidenceScore\": 0.4307,\n \"id\": 68,\n + on Surface.com.\",\n \"confidenceScore\": 0.3392,\n \"id\": 68,\n \ \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": {},\n \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": []\n }\n }\n ]\n}" headers: - apim-request-id: f107eb5a-8eb0-4d0c-8630-bf8a6e8ed463 - content-length: '7474' + apim-request-id: db614ffe-6d30-40e1-96a9-f90e41d9dd0d + content-length: '7719' content-type: application/json; charset=utf-8 - csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTransaction=1 - date: Tue, 21 Sep 2021 21:06:51 GMT + csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 + date: Thu, 30 Sep 2021 15:52:35 GMT strict-transport-security: max-age=31536000; includeSubDomains; preload x-content-type-options: nosniff - x-envoy-upstream-service-time: '325' + x-envoy-upstream-service-time: '633' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_with_dictparams.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_with_dictparams.yaml index 1f36421fa211..513de2a22841 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_with_dictparams.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_with_dictparams.yaml @@ -21,33 +21,26 @@ interactions: your battery last\"\n ],\n \"answer\": \"**Make your battery last**\\n\\nFor info on how to care for your battery and power supply, conserve power, and make your Surface battery last longer, see [Surface battery and power](http://www.microsoft.com/surface/support/hardware-and-drivers/battery-and-power) - on Surface.com.\",\n \"confidenceScore\": 0.9290999999999999,\n \"id\": + on Surface.com.\",\n \"confidenceScore\": 0.9201999999999999,\n \"id\": 27,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": {\n \"explicitlytaggedheading\": \"make your battery last\"\n },\n \ \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": []\n }\n },\n {\n \"questions\": [\n \"Check the battery level\"\n ],\n \"answer\": \"**Check the battery level**\\n\\nYou can check the battery level from the lock screen or the desktop:\",\n \"confidenceScore\": - 0.3069,\n \"id\": 24,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n + 0.4412,\n \"id\": 24,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \ \"metadata\": {\n \"explicitlytaggedheading\": \"check the battery level\"\n },\n \"dialog\": {\n \"isContextOnly\": false,\n - \ \"prompts\": []\n }\n },\n {\n \"questions\": [\n - \ \"Desktop taskbar.\"\n ],\n \"answer\": \"**Desktop taskbar.**\\n\\nBattery - status appears at the right side of the taskbar. Select the battery icon for - info about the charging and battery status, including the percent remaining. - \u272A\",\n \"confidenceScore\": 0.2548,\n \"id\": 26,\n \"source\": - \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": {},\n \"dialog\": - {\n \"isContextOnly\": false,\n \"prompts\": []\n }\n }\n - \ ]\n}" + \ \"prompts\": []\n }\n }\n ]\n}" headers: - apim-request-id: acaef643-3f2d-4397-aca0-2c4bcc8bb7a2 - content-length: '1621' + apim-request-id: e780b038-2930-45fc-99b3-35255fff74ec + content-length: '1140' content-type: application/json; charset=utf-8 - csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTransaction=1 - date: Tue, 21 Sep 2021 21:06:53 GMT + csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 + date: Thu, 30 Sep 2021 15:52:36 GMT strict-transport-security: max-age=31536000; includeSubDomains; preload x-content-type-options: nosniff - x-envoy-upstream-service-time: '250' + x-envoy-upstream-service-time: '578' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_with_followup.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_with_followup.yaml index 69a285e55600..fa6114118971 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_with_followup.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_with_followup.yaml @@ -21,33 +21,26 @@ interactions: your battery last\"\n ],\n \"answer\": \"**Make your battery last**\\n\\nFor info on how to care for your battery and power supply, conserve power, and make your Surface battery last longer, see [Surface battery and power](http://www.microsoft.com/surface/support/hardware-and-drivers/battery-and-power) - on Surface.com.\",\n \"confidenceScore\": 0.9290999999999999,\n \"id\": + on Surface.com.\",\n \"confidenceScore\": 0.9201999999999999,\n \"id\": 27,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": {\n \"explicitlytaggedheading\": \"make your battery last\"\n },\n \ \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": []\n }\n },\n {\n \"questions\": [\n \"Check the battery level\"\n ],\n \"answer\": \"**Check the battery level**\\n\\nYou can check the battery level from the lock screen or the desktop:\",\n \"confidenceScore\": - 0.3069,\n \"id\": 24,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n + 0.4412,\n \"id\": 24,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \ \"metadata\": {\n \"explicitlytaggedheading\": \"check the battery level\"\n },\n \"dialog\": {\n \"isContextOnly\": false,\n - \ \"prompts\": []\n }\n },\n {\n \"questions\": [\n - \ \"Desktop taskbar.\"\n ],\n \"answer\": \"**Desktop taskbar.**\\n\\nBattery - status appears at the right side of the taskbar. Select the battery icon for - info about the charging and battery status, including the percent remaining. - \u272A\",\n \"confidenceScore\": 0.2548,\n \"id\": 26,\n \"source\": - \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": {},\n \"dialog\": - {\n \"isContextOnly\": false,\n \"prompts\": []\n }\n }\n - \ ]\n}" + \ \"prompts\": []\n }\n }\n ]\n}" headers: - apim-request-id: 5a7bbcf4-75f5-4eeb-a994-b8bcd5d2907f - content-length: '1621' + apim-request-id: 4e07975b-1254-451c-8173-9fc8603cadca + content-length: '1140' content-type: application/json; charset=utf-8 - csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTransaction=1 - date: Tue, 21 Sep 2021 21:06:53 GMT + csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 + date: Thu, 30 Sep 2021 15:52:36 GMT strict-transport-security: max-age=31536000; includeSubDomains; preload x-content-type-options: nosniff - x-envoy-upstream-service-time: '251' + x-envoy-upstream-service-time: '368' status: code: 200 message: OK @@ -80,7 +73,7 @@ interactions: like a phone, while your Surface charges. The USB port on the power supply is only for charging, not for data transfer. If you want to use a USB device, plug it into the USB port on your Surface.\",\n \"confidenceScore\": - 0.6517000000000001,\n \"id\": 23,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n + 0.5296,\n \"id\": 23,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \ \"metadata\": {\n \"explicitlytaggedheading\": \"power and charging\"\n \ },\n \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": [\n {\n \"displayOrder\": 0,\n \"qnaId\": 24,\n @@ -90,26 +83,26 @@ interactions: 2,\n \"qnaId\": 26,\n \"displayText\": \"Desktop taskbar.\"\n \ },\n {\n \"displayOrder\": 3,\n \"qnaId\": 27,\n \"displayText\": \"Make your battery last\"\n }\n - \ ]\n },\n \"answerSpan\": {\n \"text\": \"two to four - hours\",\n \"confidenceScore\": 0.3086,\n \"offset\": 33,\n - \ \"length\": 18\n }\n },\n {\n \"questions\": [\n \"Charge + \ ]\n },\n \"answerSpan\": {\n \"text\": \" two to + four hours\",\n \"confidenceScore\": 0.3795,\n \"offset\": 32,\n + \ \"length\": 19\n }\n },\n {\n \"questions\": [\n \"Charge your Surface Pro 4\"\n ],\n \"answer\": \"**Charge your Surface Pro 4**\\n\\n1. Connect the two parts of the power cord.\\n\\n2. Connect the power cord securely to the charging port.\\n\\n3. Plug the power supply - into an electrical outlet.\",\n \"confidenceScore\": 0.30260000000000004,\n - \ \"id\": 19,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n - \ \"metadata\": {\n \"explicitlytaggedheading\": \"charge your - surface pro 4\"\n },\n \"dialog\": {\n \"isContextOnly\": - false,\n \"prompts\": []\n }\n }\n ]\n}" + into an electrical outlet.\",\n \"confidenceScore\": 0.2707,\n \"id\": + 19,\n \"source\": \"surface-pro-4-user-guide-EN.pdf\",\n \"metadata\": + {\n \"explicitlytaggedheading\": \"charge your surface pro 4\"\n },\n + \ \"dialog\": {\n \"isContextOnly\": false,\n \"prompts\": + []\n }\n }\n ]\n}" headers: - apim-request-id: 33ee27bc-abd8-493e-9ffb-ac0259f68ad7 - content-length: '2178' + apim-request-id: 7b827f35-7711-46af-8757-f33d0a2ff551 + content-length: '2154' content-type: application/json; charset=utf-8 - csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTransaction=1 - date: Tue, 21 Sep 2021 21:06:53 GMT + csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 + date: Thu, 30 Sep 2021 15:52:38 GMT strict-transport-security: max-age=31536000; includeSubDomains; preload x-content-type-options: nosniff - x-envoy-upstream-service-time: '338' + x-envoy-upstream-service-time: '571' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text.test_query_text.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text.test_query_text.yaml index 31912fc7ddc9..b1a0f0a77e70 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text.test_query_text.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text.test_query_text.yaml @@ -93,7 +93,7 @@ interactions: USB 3.1 Always-On, USB 3.1, Headphone/Mic, microSD RAM16GB RAM Upgradable to16GB Size12.1 x 8.3 x .57 inches Touchpad Size4.3 x 2.2 inches USB Ports3 Video Memory2GB Warranty/Supportone-year warranty. Weight2.8 pounds Wi-Fi802.11ac Wi-Fi ModelIntel - Wireless-AC 9560 "}], "language": "en", "stringIndexType": "TextElements_v8"}' + Wireless-AC 9560 "}], "language": "en", "stringIndexType": "UnicodeCodePoint"}' headers: Accept: - application/json @@ -102,7 +102,7 @@ interactions: Connection: - keep-alive Content-Length: - - '7447' + - '7448' Content-Type: - application/json User-Agent: @@ -119,7 +119,7 @@ interactions: Battery Life - Longest Lasting Laptop Batteries Competing laptops like the ZenBook S UX391UA (7:05), Surface Laptop 2 (9:22) and Notebook 9 Pro (8:53) outstayed the 4K Envy 13 but powered down long before the 1080p version.\",\n - \ \"confidenceScore\": 0.017458289861679077,\n \"id\": \"doc3\",\n + \ \"confidenceScore\": 0.01745828054845333,\n \"id\": \"doc3\",\n \ \"answerSpan\": {\n \"text\": \"Battery Life\",\n \"confidenceScore\": 0.26247412,\n \"offset\": 0,\n \"length\": 12\n },\n \"offset\": 1779,\n \"length\": 555\n },\n {\n \"answer\": \"Along with @@ -127,36 +127,36 @@ interactions: ultraportable chassis, fast performance, and powerful speakers. Best of all, the Envy 13 starts at a reasonable $799, which is hundreds less than the competition. In many ways, the Envy 13 is what we wanted the new MacBook Air to be.\",\n - \ \"confidenceScore\": 0.009401722811162472,\n \"id\": \"doc3\",\n + \ \"confidenceScore\": 0.00940172653645277,\n \"id\": \"doc3\",\n \ \"answerSpan\": {\n \"text\": \"battery life\",\n \"confidenceScore\": - 0.3530523,\n \"offset\": 27,\n \"length\": 13\n },\n \"offset\": + 0.35305238,\n \"offset\": 27,\n \"length\": 13\n },\n \"offset\": 4508,\n \"length\": 319\n },\n {\n \"answer\": \"We also recommend the Samsung Notebook 9 Pro, which has a similarly premium design but much better battery life than the 4K Envy. The Microsoft Surface Laptop 2 is another recommended alternative, though you might want to wait a few months for the rumored Surface Laptop 3. Overall, the HP Envy 13 is a fantastic laptop that checks all the right boxes --- as long as you buy the 1080p model.\",\n - \ \"confidenceScore\": 0.0070572528056800365,\n \"id\": \"doc3\",\n + \ \"confidenceScore\": 0.007057250943034887,\n \"id\": \"doc3\",\n \ \"answerSpan\": {\n \"text\": \"battery life\",\n \"confidenceScore\": - 0.5914322,\n \"offset\": 98,\n \"length\": 13\n },\n \"offset\": + 0.59143245,\n \"offset\": 98,\n \"length\": 13\n },\n \"offset\": 5391,\n \"length\": 393\n }\n ]\n}" headers: apim-request-id: - - 8606d2ff-3166-4f3d-bc8c-b89815b47dfa + - abf593a7-19a1-45a9-b94c-e590f8f3bf5a content-length: - - '2147' + - '2146' content-type: - application/json; charset=utf-8 csp-billing-usage: - - CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 + - CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=9 date: - - Tue, 21 Sep 2021 21:06:55 GMT + - Thu, 30 Sep 2021 15:52:33 GMT strict-transport-security: - max-age=31536000; includeSubDomains; preload x-content-type-options: - nosniff x-envoy-upstream-service-time: - - '733' + - '323' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text.test_query_text_llc.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text.test_query_text_llc.yaml index 17cc1c469747..3a55e7c933ba 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text.test_query_text_llc.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text.test_query_text_llc.yaml @@ -119,7 +119,7 @@ interactions: Battery Life - Longest Lasting Laptop Batteries Competing laptops like the ZenBook S UX391UA (7:05), Surface Laptop 2 (9:22) and Notebook 9 Pro (8:53) outstayed the 4K Envy 13 but powered down long before the 1080p version.\",\n - \ \"confidenceScore\": 0.017458289861679077,\n \"id\": \"doc3\",\n + \ \"confidenceScore\": 0.01745828054845333,\n \"id\": \"doc3\",\n \ \"answerSpan\": {\n \"text\": \"Battery Life\",\n \"confidenceScore\": 0.26247412,\n \"offset\": 0,\n \"length\": 12\n },\n \"offset\": 1779,\n \"length\": 555\n },\n {\n \"answer\": \"Along with @@ -127,9 +127,9 @@ interactions: ultraportable chassis, fast performance, and powerful speakers. Best of all, the Envy 13 starts at a reasonable $799, which is hundreds less than the competition. In many ways, the Envy 13 is what we wanted the new MacBook Air to be.\",\n - \ \"confidenceScore\": 0.00940172653645277,\n \"id\": \"doc3\",\n + \ \"confidenceScore\": 0.009401722811162472,\n \"id\": \"doc3\",\n \ \"answerSpan\": {\n \"text\": \"battery life\",\n \"confidenceScore\": - 0.35305238,\n \"offset\": 27,\n \"length\": 13\n },\n \"offset\": + 0.3530523,\n \"offset\": 27,\n \"length\": 13\n },\n \"offset\": 4508,\n \"length\": 319\n },\n {\n \"answer\": \"We also recommend the Samsung Notebook 9 Pro, which has a similarly premium design but much better battery life than the 4K Envy. The Microsoft Surface Laptop 2 is another @@ -142,21 +142,21 @@ interactions: 5391,\n \"length\": 393\n }\n ]\n}" headers: apim-request-id: - - 77da498d-0205-4cdb-a4ea-034ac73ea176 + - 63f09596-dbf2-44ac-a8f9-c3de2917c426 content-length: - - '2146' + - '2145' content-type: - application/json; charset=utf-8 csp-billing-usage: - - CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 + - CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=9 date: - - Tue, 21 Sep 2021 21:06:56 GMT + - Thu, 30 Sep 2021 15:52:33 GMT strict-transport-security: - max-age=31536000; includeSubDomains; preload x-content-type-options: - nosniff x-envoy-upstream-service-time: - - '474' + - '304' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text.test_query_text_overload.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text.test_query_text_overload.yaml index e4628e088f8f..fb3f72c08da0 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text.test_query_text_overload.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text.test_query_text_overload.yaml @@ -8,7 +8,7 @@ interactions: your Surface Pro 4 power supply to charge other devices, like a phone, while your Surface charges. The USB port on the power supply is only for charging, not for data transfer. If you want to use a USB device, plug it into the USB - port on your Surface."}], "stringIndexType": "TextElements_v8"}' + port on your Surface."}], "language": "en", "stringIndexType": "UnicodeCodePoint"}' headers: Accept: - application/json @@ -17,7 +17,7 @@ interactions: Connection: - keep-alive Content-Length: - - '688' + - '707' Content-Type: - application/json User-Agent: @@ -30,39 +30,39 @@ interactions: It takes two to four hours to charge the Surface Pro 4 battery fully from an empty state. It can take longer if you\u2019re using your Surface for power-intensive activities like gaming or video streaming while you\u2019re charging it.\",\n - \ \"confidenceScore\": 0.9298818111419678,\n \"id\": \"0\",\n \"answerSpan\": + \ \"confidenceScore\": 0.9298818707466125,\n \"id\": \"0\",\n \"answerSpan\": {\n \"text\": \"two to four hours\",\n \"confidenceScore\": 0.98579097,\n \"offset\": 28,\n \"length\": 18\n },\n \"offset\": 0,\n \"length\": 245\n },\n {\n \"answer\": \"It takes two to four hours to charge the Surface Pro 4 battery fully from an empty state. It can take longer if you\u2019re using your Surface for power-intensive activities like gaming or video streaming while you\u2019re charging it.\",\n \"confidenceScore\": - 0.9254359602928162,\n \"id\": \"0\",\n \"answerSpan\": {\n \"text\": + 0.9254360198974609,\n \"id\": \"0\",\n \"answerSpan\": {\n \"text\": \"two to four hours\",\n \"confidenceScore\": 0.98562825,\n \"offset\": 8,\n \"length\": 18\n },\n \"offset\": 20,\n \"length\": 225\n },\n {\n \"answer\": \"It can take longer if you\u2019re using your Surface for power-intensive activities like gaming or video streaming while you\u2019re charging it.\",\n \"confidenceScore\": 0.05503516271710396,\n \ \"id\": \"0\",\n \"answerSpan\": {\n \"text\": \"longer\",\n - \ \"confidenceScore\": 0.624118,\n \"offset\": 11,\n \"length\": + \ \"confidenceScore\": 0.62411773,\n \"offset\": 11,\n \"length\": 7\n },\n \"offset\": 110,\n \"length\": 135\n }\n ]\n}" headers: apim-request-id: - - 16114d30-1c1d-48e1-a023-4d4507a0d97a + - f0c97e63-de33-41db-bebd-3a34cc810fad content-length: - - '1479' + - '1481' content-type: - application/json; charset=utf-8 csp-billing-usage: - - CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 + - CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=2 date: - - Tue, 21 Sep 2021 21:06:57 GMT + - Thu, 30 Sep 2021 15:52:34 GMT strict-transport-security: - max-age=31536000; includeSubDomains; preload x-content-type-options: - nosniff x-envoy-upstream-service-time: - - '425' + - '255' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text.test_query_text_with_dictparams.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text.test_query_text_with_dictparams.yaml index 4679ebd184a1..72d83dc51e68 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text.test_query_text_with_dictparams.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text.test_query_text_with_dictparams.yaml @@ -8,7 +8,7 @@ interactions: your Surface Pro 4 power supply to charge other devices, like a phone, while your Surface charges. The USB port on the power supply is only for charging, not for data transfer. If you want to use a USB device, plug it into the USB - port on your Surface."}], "language": "en"}' + port on your Surface."}], "language": "en", "stringIndexType": "UnicodeCodePoint"}' headers: Accept: - application/json @@ -17,7 +17,7 @@ interactions: Connection: - keep-alive Content-Length: - - '668' + - '707' Content-Type: - application/json User-Agent: @@ -30,39 +30,39 @@ interactions: It takes two to four hours to charge the Surface Pro 4 battery fully from an empty state. It can take longer if you\u2019re using your Surface for power-intensive activities like gaming or video streaming while you\u2019re charging it.\",\n - \ \"confidenceScore\": 0.9298818111419678,\n \"id\": \"1\",\n \"answerSpan\": + \ \"confidenceScore\": 0.9298818707466125,\n \"id\": \"1\",\n \"answerSpan\": {\n \"text\": \"two to four hours\",\n \"confidenceScore\": 0.98579097,\n \"offset\": 28,\n \"length\": 18\n },\n \"offset\": 0,\n \"length\": 245\n },\n {\n \"answer\": \"It takes two to four hours to charge the Surface Pro 4 battery fully from an empty state. It can take longer if you\u2019re using your Surface for power-intensive activities like gaming or video streaming while you\u2019re charging it.\",\n \"confidenceScore\": - 0.9254360198974609,\n \"id\": \"1\",\n \"answerSpan\": {\n \"text\": - \"two to four hours\",\n \"confidenceScore\": 0.98562825,\n \"offset\": + 0.9254359602928162,\n \"id\": \"1\",\n \"answerSpan\": {\n \"text\": + \"two to four hours\",\n \"confidenceScore\": 0.9856282,\n \"offset\": 8,\n \"length\": 18\n },\n \"offset\": 20,\n \"length\": 225\n },\n {\n \"answer\": \"It can take longer if you\u2019re using your Surface for power-intensive activities like gaming or video streaming - while you\u2019re charging it.\",\n \"confidenceScore\": 0.05503516271710396,\n + while you\u2019re charging it.\",\n \"confidenceScore\": 0.05503518134355545,\n \ \"id\": \"1\",\n \"answerSpan\": {\n \"text\": \"longer\",\n \ \"confidenceScore\": 0.624118,\n \"offset\": 11,\n \"length\": 7\n },\n \"offset\": 110,\n \"length\": 135\n }\n ]\n}" headers: apim-request-id: - - 6be5c655-0bad-49d5-ba56-38ba2a890866 + - 00eefdf8-2d1a-4d4b-9d64-6d28ebc6b0a5 content-length: - - '1479' + - '1478' content-type: - application/json; charset=utf-8 csp-billing-usage: - - CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 + - CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=2 date: - - Tue, 21 Sep 2021 21:06:57 GMT + - Thu, 30 Sep 2021 15:52:34 GMT strict-transport-security: - max-age=31536000; includeSubDomains; preload x-content-type-options: - nosniff x-envoy-upstream-service-time: - - '271' + - '203' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text.test_query_text_with_str_records.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text.test_query_text_with_str_records.yaml index 60c095f1d278..906db8907bfc 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text.test_query_text_with_str_records.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text.test_query_text_with_str_records.yaml @@ -8,7 +8,7 @@ interactions: your Surface Pro 4 power supply to charge other devices, like a phone, while your Surface charges. The USB port on the power supply is only for charging, not for data transfer. If you want to use a USB device, plug it into the USB - port on your Surface."}], "language": "en"}' + port on your Surface."}], "language": "en", "stringIndexType": "UnicodeCodePoint"}' headers: Accept: - application/json @@ -17,7 +17,7 @@ interactions: Connection: - keep-alive Content-Length: - - '668' + - '707' Content-Type: - application/json User-Agent: @@ -38,7 +38,7 @@ interactions: It can take longer if you\u2019re using your Surface for power-intensive activities like gaming or video streaming while you\u2019re charging it.\",\n \"confidenceScore\": 0.9254359602928162,\n \"id\": \"0\",\n \"answerSpan\": {\n \"text\": - \"two to four hours\",\n \"confidenceScore\": 0.98562825,\n \"offset\": + \"two to four hours\",\n \"confidenceScore\": 0.9856282,\n \"offset\": 8,\n \"length\": 18\n },\n \"offset\": 20,\n \"length\": 225\n },\n {\n \"answer\": \"It can take longer if you\u2019re using your Surface for power-intensive activities like gaming or video streaming @@ -48,21 +48,21 @@ interactions: 7\n },\n \"offset\": 110,\n \"length\": 135\n }\n ]\n}" headers: apim-request-id: - - 49bbe0b7-74a9-416e-9a82-fffdcca416fd + - 390cb02b-4245-4719-8556-59acc1863554 content-length: - - '1479' + - '1478' content-type: - application/json; charset=utf-8 csp-billing-usage: - - CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 + - CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=2 date: - - Tue, 21 Sep 2021 21:06:58 GMT + - Thu, 30 Sep 2021 15:52:34 GMT strict-transport-security: - max-age=31536000; includeSubDomains; preload x-content-type-options: - nosniff x-envoy-upstream-service-time: - - '314' + - '243' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text_async.test_query_text.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text_async.test_query_text.yaml index 15245c82e840..33d966c39351 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text_async.test_query_text.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text_async.test_query_text.yaml @@ -93,12 +93,12 @@ interactions: USB 3.1 Always-On, USB 3.1, Headphone/Mic, microSD RAM16GB RAM Upgradable to16GB Size12.1 x 8.3 x .57 inches Touchpad Size4.3 x 2.2 inches USB Ports3 Video Memory2GB Warranty/Supportone-year warranty. Weight2.8 pounds Wi-Fi802.11ac Wi-Fi ModelIntel - Wireless-AC 9560 "}], "language": "en", "stringIndexType": "TextElements_v8"}' + Wireless-AC 9560 "}], "language": "en", "stringIndexType": "UnicodeCodePoint"}' headers: Accept: - application/json Content-Length: - - '7447' + - '7448' Content-Type: - application/json User-Agent: @@ -115,9 +115,9 @@ interactions: Battery Life - Longest Lasting Laptop Batteries Competing laptops like the ZenBook S UX391UA (7:05), Surface Laptop 2 (9:22) and Notebook 9 Pro (8:53) outstayed the 4K Envy 13 but powered down long before the 1080p version.\",\n - \ \"confidenceScore\": 0.017458291724324226,\n \"id\": \"doc3\",\n + \ \"confidenceScore\": 0.01745828054845333,\n \"id\": \"doc3\",\n \ \"answerSpan\": {\n \"text\": \"Battery Life\",\n \"confidenceScore\": - 0.26247388,\n \"offset\": 0,\n \"length\": 12\n },\n \"offset\": + 0.26247412,\n \"offset\": 0,\n \"length\": 12\n },\n \"offset\": 1779,\n \"length\": 555\n },\n {\n \"answer\": \"Along with 11-plus hours of battery life (on the FHD model), the Envy 13 has a sleek, ultraportable chassis, fast performance, and powerful speakers. Best of all, @@ -132,19 +132,19 @@ interactions: recommended alternative, though you might want to wait a few months for the rumored Surface Laptop 3. Overall, the HP Envy 13 is a fantastic laptop that checks all the right boxes --- as long as you buy the 1080p model.\",\n - \ \"confidenceScore\": 0.0070572528056800365,\n \"id\": \"doc3\",\n + \ \"confidenceScore\": 0.007057250943034887,\n \"id\": \"doc3\",\n \ \"answerSpan\": {\n \"text\": \"battery life\",\n \"confidenceScore\": - 0.5914322,\n \"offset\": 98,\n \"length\": 13\n },\n \"offset\": + 0.59143245,\n \"offset\": 98,\n \"length\": 13\n },\n \"offset\": 5391,\n \"length\": 393\n }\n ]\n}" headers: - apim-request-id: 6509de25-150a-4b5d-852b-deec6ec8cf2c - content-length: '2147' + apim-request-id: 51ce1817-cad9-4c5e-a2b3-4391b42b3211 + content-length: '2146' content-type: application/json; charset=utf-8 - csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 - date: Tue, 21 Sep 2021 21:07:00 GMT + csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=9 + date: Thu, 30 Sep 2021 15:52:35 GMT strict-transport-security: max-age=31536000; includeSubDomains; preload x-content-type-options: nosniff - x-envoy-upstream-service-time: '217' + x-envoy-upstream-service-time: '292' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text_async.test_query_text_llc.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text_async.test_query_text_llc.yaml index cd71362f8393..0d9cdddeb235 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text_async.test_query_text_llc.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text_async.test_query_text_llc.yaml @@ -115,9 +115,9 @@ interactions: Battery Life - Longest Lasting Laptop Batteries Competing laptops like the ZenBook S UX391UA (7:05), Surface Laptop 2 (9:22) and Notebook 9 Pro (8:53) outstayed the 4K Envy 13 but powered down long before the 1080p version.\",\n - \ \"confidenceScore\": 0.01745828054845333,\n \"id\": \"doc3\",\n + \ \"confidenceScore\": 0.01745828241109848,\n \"id\": \"doc3\",\n \ \"answerSpan\": {\n \"text\": \"Battery Life\",\n \"confidenceScore\": - 0.26247412,\n \"offset\": 0,\n \"length\": 12\n },\n \"offset\": + 0.26247388,\n \"offset\": 0,\n \"length\": 12\n },\n \"offset\": 1779,\n \"length\": 555\n },\n {\n \"answer\": \"Along with 11-plus hours of battery life (on the FHD model), the Envy 13 has a sleek, ultraportable chassis, fast performance, and powerful speakers. Best of all, @@ -132,19 +132,19 @@ interactions: recommended alternative, though you might want to wait a few months for the rumored Surface Laptop 3. Overall, the HP Envy 13 is a fantastic laptop that checks all the right boxes --- as long as you buy the 1080p model.\",\n - \ \"confidenceScore\": 0.0070572528056800365,\n \"id\": \"doc3\",\n + \ \"confidenceScore\": 0.007057250943034887,\n \"id\": \"doc3\",\n \ \"answerSpan\": {\n \"text\": \"battery life\",\n \"confidenceScore\": 0.59143245,\n \"offset\": 98,\n \"length\": 13\n },\n \"offset\": 5391,\n \"length\": 393\n }\n ]\n}" headers: - apim-request-id: f3ab3c91-1bfb-4c45-a752-ca79c3e0a987 - content-length: '2147' + apim-request-id: bc9b76a5-d8f4-401f-a0d0-1e55341a56d0 + content-length: '2146' content-type: application/json; charset=utf-8 - csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 - date: Tue, 21 Sep 2021 21:07:00 GMT + csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=9 + date: Thu, 30 Sep 2021 15:52:36 GMT strict-transport-security: max-age=31536000; includeSubDomains; preload x-content-type-options: nosniff - x-envoy-upstream-service-time: '318' + x-envoy-upstream-service-time: '186' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text_async.test_query_text_overload.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text_async.test_query_text_overload.yaml index 15d4d99520d4..c606f953a9d7 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text_async.test_query_text_overload.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text_async.test_query_text_overload.yaml @@ -8,12 +8,12 @@ interactions: your Surface Pro 4 power supply to charge other devices, like a phone, while your Surface charges. The USB port on the power supply is only for charging, not for data transfer. If you want to use a USB device, plug it into the USB - port on your Surface."}], "stringIndexType": "TextElements_v8"}' + port on your Surface."}], "language": "en", "stringIndexType": "UnicodeCodePoint"}' headers: Accept: - application/json Content-Length: - - '688' + - '707' Content-Type: - application/json User-Agent: @@ -26,7 +26,7 @@ interactions: It takes two to four hours to charge the Surface Pro 4 battery fully from an empty state. It can take longer if you\u2019re using your Surface for power-intensive activities like gaming or video streaming while you\u2019re charging it.\",\n - \ \"confidenceScore\": 0.9298818111419678,\n \"id\": \"0\",\n \"answerSpan\": + \ \"confidenceScore\": 0.9298818707466125,\n \"id\": \"0\",\n \"answerSpan\": {\n \"text\": \"two to four hours\",\n \"confidenceScore\": 0.98579097,\n \"offset\": 28,\n \"length\": 18\n },\n \"offset\": 0,\n \"length\": 245\n },\n {\n \"answer\": \"It takes two @@ -43,14 +43,14 @@ interactions: \ \"confidenceScore\": 0.62411773,\n \"offset\": 11,\n \"length\": 7\n },\n \"offset\": 110,\n \"length\": 135\n }\n ]\n}" headers: - apim-request-id: 5f3c0c70-7d76-41fe-84fe-39b61be4f30c + apim-request-id: cbb90985-1d4b-4b29-a55e-e2a6bb2ff93b content-length: '1481' content-type: application/json; charset=utf-8 - csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 - date: Tue, 21 Sep 2021 21:07:01 GMT + csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=2 + date: Thu, 30 Sep 2021 15:52:35 GMT strict-transport-security: max-age=31536000; includeSubDomains; preload x-content-type-options: nosniff - x-envoy-upstream-service-time: '210' + x-envoy-upstream-service-time: '175' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text_async.test_query_text_with_dictparams.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text_async.test_query_text_with_dictparams.yaml index 99885d8fbc99..4a8803314774 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text_async.test_query_text_with_dictparams.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text_async.test_query_text_with_dictparams.yaml @@ -8,12 +8,12 @@ interactions: your Surface Pro 4 power supply to charge other devices, like a phone, while your Surface charges. The USB port on the power supply is only for charging, not for data transfer. If you want to use a USB device, plug it into the USB - port on your Surface."}], "language": "en"}' + port on your Surface."}], "language": "en", "stringIndexType": "UnicodeCodePoint"}' headers: Accept: - application/json Content-Length: - - '668' + - '707' Content-Type: - application/json User-Agent: @@ -26,31 +26,31 @@ interactions: It takes two to four hours to charge the Surface Pro 4 battery fully from an empty state. It can take longer if you\u2019re using your Surface for power-intensive activities like gaming or video streaming while you\u2019re charging it.\",\n - \ \"confidenceScore\": 0.9298818111419678,\n \"id\": \"1\",\n \"answerSpan\": + \ \"confidenceScore\": 0.9298818707466125,\n \"id\": \"1\",\n \"answerSpan\": {\n \"text\": \"two to four hours\",\n \"confidenceScore\": 0.98579097,\n \"offset\": 28,\n \"length\": 18\n },\n \"offset\": 0,\n \"length\": 245\n },\n {\n \"answer\": \"It takes two to four hours to charge the Surface Pro 4 battery fully from an empty state. It can take longer if you\u2019re using your Surface for power-intensive activities like gaming or video streaming while you\u2019re charging it.\",\n \"confidenceScore\": - 0.9254359006881714,\n \"id\": \"1\",\n \"answerSpan\": {\n \"text\": + 0.9254359602928162,\n \"id\": \"1\",\n \"answerSpan\": {\n \"text\": \"two to four hours\",\n \"confidenceScore\": 0.9856282,\n \"offset\": 8,\n \"length\": 18\n },\n \"offset\": 20,\n \"length\": 225\n },\n {\n \"answer\": \"It can take longer if you\u2019re using your Surface for power-intensive activities like gaming or video streaming - while you\u2019re charging it.\",\n \"confidenceScore\": 0.055035144090652466,\n + while you\u2019re charging it.\",\n \"confidenceScore\": 0.05503518134355545,\n \ \"id\": \"1\",\n \"answerSpan\": {\n \"text\": \"longer\",\n - \ \"confidenceScore\": 0.62411773,\n \"offset\": 11,\n \"length\": + \ \"confidenceScore\": 0.624118,\n \"offset\": 11,\n \"length\": 7\n },\n \"offset\": 110,\n \"length\": 135\n }\n ]\n}" headers: - apim-request-id: 75d29f93-387d-42b6-92e9-d454c3b09683 - content-length: '1481' + apim-request-id: 5bd3db5f-1a20-4d42-8720-772e5f694ccd + content-length: '1478' content-type: application/json; charset=utf-8 - csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 - date: Tue, 21 Sep 2021 21:07:01 GMT + csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=2 + date: Thu, 30 Sep 2021 15:52:36 GMT strict-transport-security: max-age=31536000; includeSubDomains; preload x-content-type-options: nosniff - x-envoy-upstream-service-time: '228' + x-envoy-upstream-service-time: '633' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text_async.test_query_text_with_str_records.yaml b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text_async.test_query_text_with_str_records.yaml index a80212f864c3..4b1b34ebaadc 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text_async.test_query_text_with_str_records.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text_async.test_query_text_with_str_records.yaml @@ -8,12 +8,12 @@ interactions: your Surface Pro 4 power supply to charge other devices, like a phone, while your Surface charges. The USB port on the power supply is only for charging, not for data transfer. If you want to use a USB device, plug it into the USB - port on your Surface."}], "language": "en"}' + port on your Surface."}], "language": "en", "stringIndexType": "UnicodeCodePoint"}' headers: Accept: - application/json Content-Length: - - '668' + - '707' Content-Type: - application/json User-Agent: @@ -26,31 +26,31 @@ interactions: It takes two to four hours to charge the Surface Pro 4 battery fully from an empty state. It can take longer if you\u2019re using your Surface for power-intensive activities like gaming or video streaming while you\u2019re charging it.\",\n - \ \"confidenceScore\": 0.9298818111419678,\n \"id\": \"0\",\n \"answerSpan\": + \ \"confidenceScore\": 0.9298818707466125,\n \"id\": \"0\",\n \"answerSpan\": {\n \"text\": \"two to four hours\",\n \"confidenceScore\": 0.98579097,\n \"offset\": 28,\n \"length\": 18\n },\n \"offset\": 0,\n \"length\": 245\n },\n {\n \"answer\": \"It takes two to four hours to charge the Surface Pro 4 battery fully from an empty state. It can take longer if you\u2019re using your Surface for power-intensive activities like gaming or video streaming while you\u2019re charging it.\",\n \"confidenceScore\": - 0.9254359602928162,\n \"id\": \"0\",\n \"answerSpan\": {\n \"text\": + 0.9254360198974609,\n \"id\": \"0\",\n \"answerSpan\": {\n \"text\": \"two to four hours\",\n \"confidenceScore\": 0.98562825,\n \"offset\": 8,\n \"length\": 18\n },\n \"offset\": 20,\n \"length\": 225\n },\n {\n \"answer\": \"It can take longer if you\u2019re using your Surface for power-intensive activities like gaming or video streaming - while you\u2019re charging it.\",\n \"confidenceScore\": 0.055035144090652466,\n + while you\u2019re charging it.\",\n \"confidenceScore\": 0.05503518134355545,\n \ \"id\": \"0\",\n \"answerSpan\": {\n \"text\": \"longer\",\n - \ \"confidenceScore\": 0.62411773,\n \"offset\": 11,\n \"length\": + \ \"confidenceScore\": 0.624118,\n \"offset\": 11,\n \"length\": 7\n },\n \"offset\": 110,\n \"length\": 135\n }\n ]\n}" headers: - apim-request-id: 829dce06-09a4-4da9-9118-91a11be1b3e1 - content-length: '1482' + apim-request-id: 487b1ad3-a4b7-43d6-86aa-0b04254b2eef + content-length: '1479' content-type: application/json; charset=utf-8 - csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 - date: Tue, 21 Sep 2021 21:07:02 GMT + csp-billing-usage: CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=2 + date: Thu, 30 Sep 2021 15:52:35 GMT strict-transport-security: max-age=31536000; includeSubDomains; preload x-content-type-options: nosniff - x-envoy-upstream-service-time: '178' + x-envoy-upstream-service-time: '199' status: code: 200 message: OK diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase.py index afef84a377ef..86b66635e210 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase.py @@ -241,7 +241,7 @@ def test_query_knowledgebase_with_dictparams(self, qna_account, qna_key, qna_pro deployment_name='test' ) - assert len(output.answers) == 3 + assert len(output.answers) == 2 confident_answers = [a for a in output.answers if a.confidence_score > 0.9] assert len(confident_answers) == 1 assert confident_answers[0].source == "surface-pro-4-user-guide-EN.pdf" @@ -265,7 +265,7 @@ def test_query_knowledgebase_overload(self, qna_account, qna_key, qna_project): include_unstructured_sources=True ) - assert len(output.answers) == 3 + assert len(output.answers) == 2 confident_answers = [a for a in output.answers if a.confidence_score > 0.9] assert len(confident_answers) == 1 assert confident_answers[0].source == "surface-pro-4-user-guide-EN.pdf" @@ -319,9 +319,9 @@ def test_query_knowledgebase_with_followup(self, qna_account, qna_key, qna_proje ) assert len(output.answers) == 2 - confident_answers = [a for a in output.answers if a.confidence_score > 0.6] + confident_answers = [a for a in output.answers if a.confidence_score > 0.5] assert len(confident_answers) == 1 - assert confident_answers[0].answer_span.text == "two to four hours" + assert confident_answers[0].answer_span.text == " two to four hours" @GlobalQuestionAnsweringAccountPreparer() diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase_async.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase_async.py index 880b2b1ad392..e90f684f1be3 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase_async.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase_async.py @@ -242,7 +242,7 @@ async def test_query_knowledgebase_with_dictparams(self, qna_account, qna_key, q deployment_name='test' ) - assert len(output.answers) == 3 + assert len(output.answers) == 2 confident_answers = [a for a in output.answers if a.confidence_score > 0.9] assert len(confident_answers) == 1 assert confident_answers[0].source == "surface-pro-4-user-guide-EN.pdf" @@ -266,7 +266,7 @@ async def test_query_knowledgebase_overload(self, qna_account, qna_key, qna_proj include_unstructured_sources=True ) - assert len(output.answers) == 3 + assert len(output.answers) == 2 confident_answers = [a for a in output.answers if a.confidence_score > 0.9] assert len(confident_answers) == 1 assert confident_answers[0].source == "surface-pro-4-user-guide-EN.pdf" @@ -320,9 +320,9 @@ async def test_query_knowledgebase_with_followup(self, qna_account, qna_key, qna ) assert len(output.answers) == 2 - confident_answers = [a for a in output.answers if a.confidence_score > 0.6] + confident_answers = [a for a in output.answers if a.confidence_score > 0.5] assert len(confident_answers) == 1 - assert confident_answers[0].answer_span.text == "two to four hours" + assert confident_answers[0].answer_span.text == " two to four hours" @GlobalQuestionAnsweringAccountPreparer() async def test_query_knowledgebase_only_id(self, qna_account, qna_key, qna_project): From 83e2124f8fa714f5d6e4add2eb393c9eccf0d061 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Thu, 30 Sep 2021 12:17:29 -0400 Subject: [PATCH 16/20] make metadata swagger transform transform into list of list --- .../ai/language/questionanswering/models/_models_py3.py | 6 +++--- .../azure-ai-language-questionanswering/swagger/README.md | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models_py3.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models_py3.py index b6aae092759f..83829e675a0d 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models_py3.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/models/_models_py3.py @@ -483,7 +483,7 @@ class MetadataFilter(msrest.serialization.Model): """Find QnAs that are associated with the given list of metadata. :ivar metadata: - :vartype metadata: list[str] + :vartype metadata: list[tuple[str]] :ivar logical_operation: Operation used to join metadata filters. Possible values include: "AND", "OR". :vartype logical_operation: str or @@ -498,13 +498,13 @@ class MetadataFilter(msrest.serialization.Model): def __init__( self, *, - metadata: Optional[List[Tuple[str, str]]] = None, + metadata: Optional[List[Tuple[str]]] = None, logical_operation: Optional[Union[str, "LogicalOperationKind"]] = None, **kwargs ): """ :keyword metadata: - :paramtype metadata: list[tuple[str, str]] + :paramtype metadata: list[tuple[str]] :keyword logical_operation: Operation used to join metadata filters. Possible values include: "AND", "OR". :paramtype logical_operation: str or diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/swagger/README.md b/sdk/cognitivelanguage/azure-ai-language-questionanswering/swagger/README.md index 0fa8ecfb82f5..2ba0ad9472a9 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/swagger/README.md +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/swagger/README.md @@ -116,6 +116,7 @@ directive: where: $["definitions"] transform: > delete $["MetadataFilter"]["properties"]["metadata"]["items"]["$ref"]; - $["MetadataFilter"]["properties"]["metadata"]["items"]["type"] = "string"; + $["MetadataFilter"]["properties"]["metadata"]["items"]["type"] = "array"; + $["MetadataFilter"]["properties"]["metadata"]["items"]["items"] = {"type": "string"}; delete $["MetadataRecord"]; ``` \ No newline at end of file From 4d919e81588fa0f37acc1ef7ea05d2a666a00c7a Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Thu, 30 Sep 2021 12:17:42 -0400 Subject: [PATCH 17/20] update changelo --- .../CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/CHANGELOG.md b/sdk/cognitivelanguage/azure-ai-language-questionanswering/CHANGELOG.md index 8df38ca5c8f8..27f993fddf5d 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/CHANGELOG.md +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/CHANGELOG.md @@ -5,10 +5,23 @@ * We are now targeting service version `2021-07-15-preview` ### Breaking changes + * The method `QuestionAnsweringClient.query_knowledgebase` has been renamed to `query_knowledge_base`. +* Options bag model `KnowledgeBaseQueryOptions` for `query_knowledge_base` is renamed to `QueryKnowledgeBaseOptions` +* Options bag model `TextQueryOptions` for `query_text` is renamed to `QueryTextOptions` +* The filters model `StrictFilters` is renamed to `QueryFilters` +* Enum `CompoundOperationKind` is renamed to `LogicalOperationKind` +* We have removed the `string_index_type` input to all models and operations. We have also removed the `StringIndexType` enum. +* The type of input `metadata` to `MetadataFilter` has changed from a dictionary of strings to a list of key-value tuples. +For example, the input has changed from `{"key": "value"}` to `[("key", "value")]`. +* The input to the `query_knowledge_base` and `query_text` overloads that take in a positional model for the body should be +considered positional only. ### Features Added + * The method `QuestionAnsweringClient.query_text` now supports a list of records as strings, where the ID value will be automatically populated. +* Added kwarg `default_language` onto `QuestionAnsweringClient`, which has default value `'en'`. The default language for any operation call will +be this default language value. ## 1.0.0b1 (2021-07-27) From 02ea20cec01dd5ebe3ed3658efde5eb5a5710f13 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Thu, 30 Sep 2021 12:20:03 -0400 Subject: [PATCH 18/20] add disclaimer about 2.7 and add 3.10 to setup.py --- .../azure-ai-language-questionanswering/README.md | 4 ++++ .../azure-ai-language-questionanswering/setup.py | 1 + 2 files changed, 5 insertions(+) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/README.md b/sdk/cognitivelanguage/azure-ai-language-questionanswering/README.md index 183d65726684..2e3979bc06b8 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/README.md +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/README.md @@ -6,6 +6,10 @@ Question Answering is a cloud-based API service that lets you create a conversat [Source code][questionanswering_client_src] | [Package (PyPI)][questionanswering_pypi_package] | [API reference documentation][questionanswering_refdocs] | [Product documentation][questionanswering_docs] | [Samples][questionanswering_samples] +## _Disclaimer_ + +_Azure SDK Python packages support for Python 2.7 is ending 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_ + ## Getting started ### Prerequisites diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/setup.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/setup.py index 30a3e31665b1..43de47ef0e69 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/setup.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/setup.py @@ -53,6 +53,7 @@ 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', 'License :: OSI Approved :: MIT License', ], packages=find_packages(exclude=[ From 53e867d81bb1e0e659f8ae7ddc008a2868913e2b Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Thu, 30 Sep 2021 13:58:28 -0400 Subject: [PATCH 19/20] post body -> POST body --- .../azure/ai/language/questionanswering/_patch.py | 2 +- .../questionanswering/aio/operations/_operations.py | 8 ++++---- .../language/questionanswering/operations/_operations.py | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_patch.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_patch.py index d2ed46a3e32d..884a16bb9db0 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_patch.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_patch.py @@ -40,7 +40,7 @@ def _validate_text_records(records): def _get_positional_body(*args, **kwargs): """Verify args and kwargs are valid, and then return the positional body, if users passed it in.""" if len(args) > 1: - raise TypeError("There can only be one positional argument, which is the post body of this request.") + raise TypeError("There can only be one positional argument, which is the POST body of this request.") if args and "options" in kwargs: raise TypeError( "You have already supplied the request body as a positional parameter, you can not supply it as a kwarg as well." diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py index 9bc2e8e55d4c..0c6cde294709 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_operations.py @@ -40,7 +40,7 @@ async def query_knowledge_base( ) -> "_models.KnowledgeBaseAnswers": """Answers the specified question using your knowledge base. - :param options: Positional-only post body of the request. + :param options: Positional-only POST body of the request. :type options: ~azure.ai.language.questionanswering.models.QueryKnowledgeBaseOptions :keyword project_name: The name of the project to use. @@ -112,7 +112,7 @@ async def query_knowledge_base( ) -> "_models.KnowledgeBaseAnswers": """Answers the specified question using your knowledge base. - :param options: Post body of the request. Provide either `options`, OR + :param options: POST body of the request. Provide either `options`, OR individual keyword arguments. If both are provided, only the options object will be used. :type options: ~azure.ai.language.questionanswering.models.QueryKnowledgeBaseOptions @@ -201,7 +201,7 @@ async def query_knowledge_base( async def query_text(self, options: "_models.QueryTextOptions", **kwargs: Any) -> "_models.TextAnswers": """Answers the specified question using the provided text in the body. - :param options: Positional-only post body of the request. + :param options: Positional-only POST body of the request. :type options: ~azure.ai.language.questionanswering.models.QueryTextOptions :return: TextAnswers :rtype: ~azure.ai.language.questionanswering.models.TextAnswers @@ -239,7 +239,7 @@ async def query_text( ) -> "_models.TextAnswers": """Answers the specified question using the provided text in the body. - :param options: Post body of the request. Provide either `options`, OR + :param options: POST body of the request. Provide either `options`, OR individual keyword arguments. If both are provided, only the options object will be used. :type options: ~azure.ai.language.questionanswering.models.QueryTextOptions :keyword question: User question to query against the given text records. Provide either `options`, OR diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py index ed30f42bcdad..a18c2b15911b 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py @@ -108,7 +108,7 @@ def query_knowledge_base( # type: (...) -> "_models.KnowledgeBaseAnswers" """Answers the specified question using your knowledge base. - :param options: Positional-only post body of the request. + :param options: Positional-only POST body of the request. :type options: ~azure.ai.language.questionanswering.models.QueryKnowledgeBaseOptions :keyword project_name: The name of the project to use. @@ -170,7 +170,7 @@ def query_knowledge_base( # type: (...) -> "_models.KnowledgeBaseAnswers" """Answers the specified question using your knowledge base. - :param options: Post body of the request. Provide either `options`, OR + :param options: POST body of the request. Provide either `options`, OR individual keyword arguments. If both are provided, only the options object will be used. :type options: ~azure.ai.language.questionanswering.models.QueryKnowledgeBaseOptions @@ -264,7 +264,7 @@ def query_text( # type: (...) -> "_models.TextAnswers" """Answers the specified question using the provided text in the body. - :param options: Positional-only post body of the request. + :param options: Positional-only POST body of the request. :type options: ~azure.ai.language.questionanswering.models.QueryTextOptions :return: TextAnswers :rtype: ~azure.ai.language.questionanswering.models.TextAnswers @@ -302,7 +302,7 @@ def query_text( # type: (...) -> "_models.TextAnswers" """Answers the specified question using the provided text in the body. - :param options: Post body of the request. Provide either `options`, OR + :param options: POST body of the request. Provide either `options`, OR individual keyword arguments. If both are provided, only the options object will be used. :type options: ~azure.ai.language.questionanswering.models.QueryTextOptions :keyword question: User question to query against the given text records. Provide either `options`, From d73c6352148416e1d2df34294ef56ff2c5b871c2 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Thu, 30 Sep 2021 13:59:48 -0400 Subject: [PATCH 20/20] document as keyword argument instead of kwarg --- .../azure-ai-language-questionanswering/CHANGELOG.md | 2 +- .../azure/ai/language/questionanswering/_patch.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/CHANGELOG.md b/sdk/cognitivelanguage/azure-ai-language-questionanswering/CHANGELOG.md index 27f993fddf5d..ec9dd35f032e 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/CHANGELOG.md +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/CHANGELOG.md @@ -20,7 +20,7 @@ considered positional only. ### Features Added * The method `QuestionAnsweringClient.query_text` now supports a list of records as strings, where the ID value will be automatically populated. -* Added kwarg `default_language` onto `QuestionAnsweringClient`, which has default value `'en'`. The default language for any operation call will +* Added keyword argument `default_language` onto `QuestionAnsweringClient`, which has default value `'en'`. The default language for any operation call will be this default language value. diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_patch.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_patch.py index 884a16bb9db0..c6d13a81ffd0 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_patch.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_patch.py @@ -43,7 +43,8 @@ def _get_positional_body(*args, **kwargs): raise TypeError("There can only be one positional argument, which is the POST body of this request.") if args and "options" in kwargs: raise TypeError( - "You have already supplied the request body as a positional parameter, you can not supply it as a kwarg as well." + "You have already supplied the request body as a positional parameter, " + "you can not supply it as a keyword argument as well." ) return args[0] if args else None