diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/CHANGELOG.md b/sdk/cognitivelanguage/azure-ai-language-questionanswering/CHANGELOG.md index 8df38ca5c8f8..ec9dd35f032e 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 keyword argument `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) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/README.md b/sdk/cognitivelanguage/azure-ai-language-questionanswering/README.md index 06fb24064963..2e3979bc06b8 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/README.md +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/README.md @@ -6,13 +6,17 @@ 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 -* 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 +60,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 +68,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 +80,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 +94,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 +117,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 +129,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 +140,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 +165,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 +178,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 +193,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 +207,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/_patch.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_patch.py index 7308492dcdab..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 @@ -36,3 +36,27 @@ def _validate_text_records(records): else: request_batch.append(doc) 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: + raise TypeError( + "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 + +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/_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 6775164a54ba..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 @@ -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, _verify_qna_id_and_question T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -32,23 +32,22 @@ class QuestionAnsweringClientOperationsMixin: @overload async def query_knowledge_base( self, - knowledge_base_query_options: "_models.KnowledgeBaseQueryOptions", + options: "_models.QueryKnowledgeBaseOptions", *, project_name: str, - deployment_name: Optional[str] = None, + deployment_name: str, **kwargs: Any ) -> "_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: - ~azure.ai.language.questionanswering.models.KnowledgeBaseQueryOptions + :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. :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, @@ -67,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 @@ -95,14 +94,12 @@ 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. :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 """ @@ -115,17 +112,17 @@ 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: - ~azure.ai.language.questionanswering.models.KnowledgeBaseQueryOptions + :type options: + ~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. :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. @@ -139,40 +136,37 @@ 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. :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 """ - if args: - knowledge_base_query_options = args[0] - else: - knowledge_base_query_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.QueryKnowledgeBaseOptions( + 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), + filters=kwargs.pop("filters", None), + 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", {})) 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") + json = self._serialize.body(options, "QueryKnowledgeBaseOptions") request = build_query_knowledge_base_request( content_type=content_type, @@ -186,9 +180,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 +198,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, options: "_models.QueryTextOptions", **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) + :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 :raises: ~azure.core.exceptions.HttpResponseError """ @@ -227,7 +216,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. @@ -240,13 +228,7 @@ 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 - :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 """ @@ -257,48 +239,38 @@ 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.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 - :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 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 - :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 """ - if args: - text_query_options = args[0] - else: - text_query_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.QueryTextOptions( + question=kwargs.pop("question"), + records=kwargs.pop("records"), + language=kwargs.pop("language", self._default_language), + ) 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, "QueryTextOptions") request = build_query_text_request( content_type=content_type, @@ -310,9 +282,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..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 @@ -17,12 +17,12 @@ 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 StrictFilters + 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 @@ -35,20 +35,19 @@ 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 StrictFilters # 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 ( - CompoundOperationKind, ErrorCode, InnerErrorCode, + LogicalOperationKind, RankerType, - StringIndexType, ) __all__ = [ @@ -62,16 +61,15 @@ "KnowledgeBaseAnswerPrompt", "KnowledgeBaseAnswerRequestContext", "KnowledgeBaseAnswers", - "KnowledgeBaseQueryOptions", "MetadataFilter", - "StrictFilters", + "QueryFilters", + "QueryKnowledgeBaseOptions", + "QueryTextOptions", "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..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 @@ -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,39 +409,108 @@ 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) -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[tuple[str]] + :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]]"}, + "logical_operation": {"key": "logicalOperation", "type": "str"}, + } + + def __init__(self, **kwargs): + """ + :keyword metadata: + :paramtype metadata: list[tuple[str]] + :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.logical_operation = kwargs.get("logical_operation", None) + + +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, **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.logical_operation = kwargs.get("logical_operation", None) + + +class QueryKnowledgeBaseOptions(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,13 +525,40 @@ 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): - super(KnowledgeBaseQueryOptions, self).__init__(**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) @@ -375,75 +566,71 @@ 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) -class MetadataFilter(msrest.serialization.Model): - """Find QnAs that are associated with the given list of metadata. +class QueryTextOptions(msrest.serialization.Model): + """The question and text record parameters to answer. - :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 + 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 """ - _attribute_map = { - "metadata": {"key": "metadata", "type": "{str}"}, - "compound_operation": {"key": "compoundOperation", "type": "str"}, + _validation = { + "question": {"required": True}, + "records": {"required": True}, } - def __init__(self, **kwargs): - super(MetadataFilter, self).__init__(**kwargs) - self.metadata = kwargs.get("metadata", None) - self.compound_operation = kwargs.get("compound_operation", None) - - -class StrictFilters(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. - Possible values include: "AND", "OR". - :paramtype compound_operation: str or - ~azure.ai.language.questionanswering.models.CompoundOperationKind - """ - _attribute_map = { - "metadata_filter": {"key": "metadataFilter", "type": "MetadataFilter"}, - "source_filter": {"key": "sourceFilter", "type": "[str]"}, - "compound_operation": {"key": "compoundOperation", "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, **kwargs): - super(StrictFilters, 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) + """ + :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 + """ + super(QueryTextOptions, self).__init__(**kwargs) + self.question = kwargs["question"] + self.records = kwargs["records"] + self.language = kwargs.get("language", None) + self.string_index_type = "UnicodeCodePoint" 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 +647,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 +673,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,60 +682,23 @@ 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) -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. - - :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 - """ - - _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): - 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. 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 +712,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..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 @@ -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 @@ -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,39 +471,121 @@ 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 -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[tuple[str]] + :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]]"}, + "logical_operation": {"key": "logicalOperation", "type": "str"}, + } + + def __init__( + self, + *, + metadata: Optional[List[Tuple[str]]] = None, + logical_operation: Optional[Union[str, "LogicalOperationKind"]] = None, + **kwargs + ): + """ + :keyword metadata: + :paramtype metadata: list[tuple[str]] + :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 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. - :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 +600,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,12 +615,39 @@ 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 ): - super(KnowledgeBaseQueryOptions, self).__init__(**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 = qna_id self.question = question self.top = top @@ -451,88 +655,71 @@ 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 -class MetadataFilter(msrest.serialization.Model): - """Find QnAs that are associated with the given list of metadata. +class QueryTextOptions(msrest.serialization.Model): + """The question and text record parameters to answer. - :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 + 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 """ - _attribute_map = { - "metadata": {"key": "metadata", "type": "{str}"}, - "compound_operation": {"key": "compoundOperation", "type": "str"}, + _validation = { + "question": {"required": True}, + "records": {"required": True}, } - def __init__( - self, - *, - metadata: Optional[Dict[str, str]] = None, - compound_operation: Optional[Union[str, "CompoundOperationKind"]] = None, - **kwargs - ): - super(MetadataFilter, self).__init__(**kwargs) - self.metadata = metadata - self.compound_operation = compound_operation - - -class StrictFilters(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. - Possible values include: "AND", "OR". - :paramtype compound_operation: str or - ~azure.ai.language.questionanswering.models.CompoundOperationKind - """ - _attribute_map = { - "metadata_filter": {"key": "metadataFilter", "type": "MetadataFilter"}, - "source_filter": {"key": "sourceFilter", "type": "[str]"}, - "compound_operation": {"key": "compoundOperation", "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, - compound_operation: Optional[Union[str, "CompoundOperationKind"]] = None, - **kwargs - ): - super(StrictFilters, self).__init__(**kwargs) - self.metadata_filter = metadata_filter - self.source_filter = source_filter - self.compound_operation = compound_operation + 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 + :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 + """ + super(QueryTextOptions, self).__init__(**kwargs) + self.question = question + self.records = records + self.language = language + self.string_index_type = "UnicodeCodePoint" 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 +746,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 +772,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,68 +781,23 @@ 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 -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. - - :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 - """ - - _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 - ): - 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. 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 +811,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..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 @@ -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,26 +35,15 @@ 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.""" 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/azure/ai/language/questionanswering/operations/_operations.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_operations.py index 4f8f585e2a7e..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 @@ -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, _verify_qna_id_and_question if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -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 @@ -103,21 +102,20 @@ class QuestionAnsweringClientOperationsMixin(object): @overload def query_knowledge_base( self, - knowledge_base_query_options, # type: "_models.KnowledgeBaseQueryOptions" + options, # type: "_models.QueryKnowledgeBaseOptions" **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: - ~azure.ai.language.questionanswering.models.KnowledgeBaseQueryOptions + :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. :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 """ @@ -152,14 +150,13 @@ 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. :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 """ @@ -167,21 +164,21 @@ def query_knowledge_base( def query_knowledge_base( self, - *args, # type: "_models.KnowledgeBaseQueryOptions" + *args, # type: "_models.QueryKnowledgeBaseOptions" **kwargs # type: Any ): # 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: - ~azure.ai.language.questionanswering.models.KnowledgeBaseQueryOptions + :type options: + ~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. :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. @@ -197,40 +194,37 @@ 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. :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 """ - if args: - knowledge_base_query_options = args[0] - else: - knowledge_base_query_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.QueryKnowledgeBaseOptions( + 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), + filters=kwargs.pop("filters", None), + 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", {})) 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") + json = self._serialize.body(options, "QueryKnowledgeBaseOptions") request = build_query_knowledge_base_request( content_type=content_type, @@ -244,7 +238,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]: @@ -264,16 +258,15 @@ def query_knowledge_base( @overload def query_text( self, - text_query_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 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) + :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 :raises: ~azure.core.exceptions.HttpResponseError """ @@ -295,13 +288,7 @@ 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 - :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 """ @@ -309,54 +296,44 @@ def query_text( def query_text( self, - *args, # type: "_models.TextQueryOptions" + *args, # type: "_models.QueryTextOptions" **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. 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.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 - :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 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 - :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 """ - if args: - text_query_options = args[0] - else: - text_query_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.QueryTextOptions( + question=kwargs.pop("question"), + records=kwargs.pop("records"), + language=kwargs.pop("language", self._default_language), + ) 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, "QueryTextOptions") request = build_query_text_request( content_type=content_type, @@ -368,7 +345,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]: 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/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_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/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/setup.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/setup.py index 976409977724..43de47ef0e69 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/setup.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/setup.py @@ -53,20 +53,21 @@ '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=[ '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/sdk/cognitivelanguage/azure-ai-language-questionanswering/swagger/README.md b/sdk/cognitivelanguage/azure-ai-language-questionanswering/swagger/README.md index 631ff0b2fbb5..2ba0ad9472a9 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 @@ -58,3 +58,65 @@ 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"; +``` + +### 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"; +``` + +### Delete `StringIndexType` + +```yaml +directive: + - from: swagger-document + 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"] = "array"; + $["MetadataFilter"]["properties"]["metadata"]["items"]["items"] = {"type": "string"}; + delete $["MetadataRecord"]; +``` \ No newline at end of file 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 new file mode 100644 index 000000000000..29691ffe60eb --- /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: + - 7884df53-4df8-488a-b78c-692ac7f4f783 + content-length: + - '1622' + content-type: + - application/json; charset=utf-8 + csp-billing-usage: + - CognitiveServices.TextAnalytics.QuestionAnsweringTextRecords=1 + date: + - 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: + - '700' + status: + code: 200 + message: OK +version: 1 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 new file mode 100644 index 000000000000..abb85ac4c446 --- /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: 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:52:35 GMT + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '1503' + 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/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 dd279adccf87..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 @@ -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 @@ -16,9 +16,12 @@ 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, + MetadataFilter, + LogicalOperationKind, + QueryFilters, ) @@ -125,7 +128,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 +169,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( @@ -238,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" @@ -262,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" @@ -271,7 +274,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 +296,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=", @@ -316,16 +319,16 @@ 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() 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 ) @@ -349,4 +352,56 @@ 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_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_knowledgebase_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' + ) + + @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 fda1d6cb265d..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 @@ -16,9 +16,12 @@ from asynctestcase import AsyncQuestionAnsweringTest from azure.ai.language.questionanswering.models import ( - KnowledgeBaseQueryOptions, + 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 @@ -127,7 +130,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 +171,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( @@ -239,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" @@ -263,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" @@ -272,7 +275,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 +297,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=", @@ -317,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): @@ -348,3 +351,55 @@ async def test_query_knowledgebase_python_dict(self, qna_account, qna_key, qna_p ) assert len(output.answers) == 1 + + 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_knowledgebase_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' + ) + + @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"] + ) 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..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( @@ -180,3 +180,10 @@ 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") 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..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( @@ -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") diff --git a/shared_requirements.txt b/shared_requirements.txt index 11035e2303e0..66d9e014b64e 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -151,7 +151,7 @@ backports.functools-lru-cache>=1.6.4 #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