diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/README.md b/sdk/cognitivelanguage/azure-ai-language-questionanswering/README.md index 4ed465a32252..b35f26e1f310 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/README.md +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/README.md @@ -80,8 +80,8 @@ params = qna.KnowledgeBaseQueryOptions( ) output = client.query_knowledgebase( + params, project_name="FAQ", - knowledge_base_query_options=params ) for candidate in output.answers: print("({}) {}".format(candidate.confidence_score, candidate.answer)) @@ -105,8 +105,8 @@ params = qna.models.KnowledgeBaseQueryOptions( ) output = client.query_knowledgebase( - project_name="FAQ", - knowledge_base_query_options=params + params, + project_name="FAQ" ) for candidate in output.answers: print("({}) {}".format(candidate.confidence_score, candidate.answer)) @@ -128,8 +128,8 @@ params = qna.KnowledgeBaseQueryOptions( ) output = await client.query_knowledgebase( - project_name="FAQ", - knowledge_base_query_options=params + params, + project_name="FAQ" ) ``` @@ -149,8 +149,8 @@ from azure.core.exceptions import HttpResponseError try: client.query_knowledgebase( - project_name="invalid-knowledge-base", - knowledge_base_query_options=params + params, + project_name="invalid-knowledge-base" ) except HttpResponseError as error: print("Query failed: {}".format(error.message)) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/rest/__init__.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_rest/__init__.py similarity index 100% rename from sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/rest/__init__.py rename to sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_rest/__init__.py diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/rest/_request_builders.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_rest/_request_builders.py similarity index 100% rename from sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/rest/_request_builders.py rename to sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_rest/_request_builders.py diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/rest/_request_builders_py3.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_rest/_request_builders_py3.py similarity index 100% rename from sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/rest/_request_builders_py3.py rename to sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_rest/_request_builders_py3.py 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 09131557630d..516c3e4685c8 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 @@ -42,17 +42,7 @@ def __init__(self, endpoint: str, credential: AzureKeyCredential, **kwargs: Any) def send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - We have helper methods to create requests specific to this service in `azure.ai.language.questionanswering.rest`. - Use these helper methods to create the request you pass to this method. See our example below: - - >>> from azure.ai.language.questionanswering.rest import build_query_knowledgebase_request - >>> request = build_query_knowledgebase_request(project_name=project_name, json=json, content=content, deployment_name=deployment_name, **kwargs) - - >>> response = await client.send_request(request) - - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart - For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` and pass it in. diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_question_answering_client_operations.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_question_answering_client_operations.py index ae6ee524394c..d00528f98e57 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_question_answering_client_operations.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/aio/operations/_question_answering_client_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, overload, Union, List import warnings from azure.core.exceptions import ( @@ -20,13 +20,14 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest -from ... import models as _models, rest as rest +from ... import models as _models, _rest as rest T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class QuestionAnsweringClientOperationsMixin: + @overload async def query_knowledgebase( self, knowledge_base_query_options: "_models.KnowledgeBaseQueryOptions", @@ -37,8 +38,6 @@ async def query_knowledgebase( ) -> "_models.KnowledgeBaseAnswers": """Answers the specified question using your knowledge base. - 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 @@ -51,10 +50,88 @@ async def query_knowledgebase( :rtype: ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswers :raises: ~azure.core.exceptions.HttpResponseError """ + ... + + @overload + async def query_knowledgebase( + self, + *, + project_name: str, + deployment_name: Optional[str] = None, + qna_id: Optional[int] = None, + question: Optional[str] = None, + top: Optional[int] = None, + user_id: Optional[str] = None, + 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, + answer_span_request: Optional["_models.AnswerSpanRequest"] = None, + include_unstructured_sources: Optional[bool] = None, + **kwargs: Any + ) -> "_models.KnowledgeBaseAnswers": + """Answers the specified question using your knowledge base. + + :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. + :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 + :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 + """ + ... + + async def query_knowledgebase( + self, + *args, + **kwargs: Any + ) -> "_models.KnowledgeBaseAnswers": + 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) + ) 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] json = self._serialize.body(knowledge_base_query_options, "KnowledgeBaseQueryOptions") @@ -89,11 +166,12 @@ async def query_knowledgebase( query_knowledgebase.metadata = {"url": "/:query-knowledgebases"} # type: ignore - async def query_text(self, text_query_options: "_models.TextQueryOptions", **kwargs: Any) -> "_models.TextAnswers": + @overload + async def query_text( + self, text_query_options: "_models.TextQueryOptions", **kwargs: Any + ) -> "_models.TextAnswers": """Answers the specified question using the provided text in the body. - 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 @@ -101,6 +179,52 @@ async def query_text(self, text_query_options: "_models.TextQueryOptions", **kwa :rtype: ~azure.ai.language.questionanswering.models.TextAnswers :raises: ~azure.core.exceptions.HttpResponseError """ + ... + + @overload + async def query_text( + self, + *, + 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. + + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TextAnswers, or the result of cls(response) + :rtype: ~azure.ai.language.questionanswering.models.TextAnswers + :raises: ~azure.core.exceptions.HttpResponseError + """ + ... + + async def query_text( + self, *args, **kwargs: Any + ) -> "_models.TextAnswers": + 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") + ) cls = kwargs.pop("cls", None) # type: ClsType["_models.TextAnswers"] error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop("error_map", {})) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_question_answering_client_operations.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_question_answering_client_operations.py index 67f3b791ab01..7ef8222e0664 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_question_answering_client_operations.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/operations/_question_answering_client_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import functools -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, overload import warnings from azure.core.exceptions import ( @@ -20,7 +20,7 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest -from .. import models as _models, rest as rest +from .. import models as _models, _rest as rest if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -31,6 +31,7 @@ class QuestionAnsweringClientOperationsMixin(object): + @overload def query_knowledgebase( self, knowledge_base_query_options, # type: "_models.KnowledgeBaseQueryOptions" @@ -39,8 +40,6 @@ def query_knowledgebase( # type: (...) -> "_models.KnowledgeBaseAnswers" """Answers the specified question using your knowledge base. - 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 @@ -53,6 +52,71 @@ def query_knowledgebase( :rtype: ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswers :raises: ~azure.core.exceptions.HttpResponseError """ + pass + + @overload + def query_knowledgebase( + self, + **kwargs # type: Any + ): + # type: (...) -> "_models.KnowledgeBaseAnswers" + """Answers the specified question using your knowledge base. + + :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. + :paramtype question: str + :keyword qna_id: Exact QnA ID to fetch from the knowledge base, this field takes priority over + question. + :paramtype qna_id: int + :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 + :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 + """ + pass + + def query_knowledgebase( + self, + *args, # type: "_models.KnowledgeBaseQueryOptions" + **kwargs # type: Any + ): + # type: (...) -> "_models.KnowledgeBaseAnswers" + 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) + ) cls = kwargs.pop("cls", None) # type: ClsType["_models.KnowledgeBaseAnswers"] error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop("error_map", {})) @@ -91,6 +155,7 @@ def query_knowledgebase( query_knowledgebase.metadata = {"url": "/:query-knowledgebases"} # type: ignore + @overload def query_text( self, text_query_options, # type: "_models.TextQueryOptions" @@ -99,8 +164,6 @@ def query_text( # type: (...) -> "_models.TextAnswers" """Answers the specified question using the provided text in the body. - 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 @@ -108,6 +171,51 @@ def query_text( :rtype: ~azure.ai.language.questionanswering.models.TextAnswers :raises: ~azure.core.exceptions.HttpResponseError """ + pass + + @overload + def query_text( + self, + **kwargs # type: Any + ): + # type: (...) -> "_models.TextAnswers" + """Answers the specified question using the provided text in the body. + + :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.TextInput] + :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) + :rtype: ~azure.ai.language.questionanswering.models.TextAnswers + :raises: ~azure.core.exceptions.HttpResponseError + """ + pass + + def query_text( + self, + *args, # type: "_models.TextQueryOptions" + **kwargs # type: Any + ): + # type: (...) -> "_models.TextAnswers" + 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") + ) cls = kwargs.pop("cls", None) # type: ClsType["_models.TextAnswers"] error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop("error_map", {})) 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 63fa238f7eda..059bf3e17e73 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 @@ -48,8 +48,8 @@ async def sample_chit_chat(): ) output = await client.query_knowledgebase( + first_question, project_name=knowledgebase_project, - knowledge_base_query_options=first_question, deployment_name="test" ) best_candidate = [a for a in output.answers if a.confidence_score > 0.9][0] @@ -73,8 +73,8 @@ async def sample_chit_chat(): ) output = await client.query_knowledgebase( + followup_question, project_name=knowledgebase_project, - knowledge_base_query_options=followup_question, deployment_name="test" ) print("Q: {}".format(followup_question.question)) 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 5f983bef4ccb..fdaee2ee65e5 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 @@ -48,8 +48,8 @@ async def sample_query_knowledgebase(): ) output = await client.query_knowledgebase( + input, project_name=knowledgebase_project, - knowledge_base_query_options=input, deployment_name="test" ) best_candidate = [a for a in output.answers if a.confidence_score > 0.9][0] 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 499b63d7fe50..48c7be634897 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/sample_chat.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/sample_chat.py @@ -46,8 +46,8 @@ def sample_chit_chat(): ) output = client.query_knowledgebase( + first_question, project_name=knowledgebase_project, - knowledge_base_query_options=first_question, deployment_name="test" ) best_candidate = [a for a in output.answers if a.confidence_score > 0.9][0] @@ -71,8 +71,8 @@ def sample_chit_chat(): ) output = client.query_knowledgebase( + followup_question, project_name=knowledgebase_project, - knowledge_base_query_options=followup_question, deployment_name="test" ) print("Q: {}".format(followup_question.question)) 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 b499197cba26..da25074b7ace 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 @@ -46,8 +46,8 @@ def sample_query_knowledgebase(): ) output = client.query_knowledgebase( + input, project_name=knowledgebase_project, - knowledge_base_query_options=input, deployment_name="test" ) best_candidate = [a for a in output.answers if a.confidence_score > 0.9][0] 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 new file mode 100644 index 000000000000..0519019043d5 --- /dev/null +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase.test_query_knowledgebase_overload.yaml @@ -0,0 +1,64 @@ +interactions: +- request: + body: '{"question": "How long should my Surface battery last?", "top": 3, "userId": + "sd53lsY=", "confidenceScoreThreshold": 0.2, "answerSpanRequest": {"enable": + true, "confidenceScoreThreshold": 0.2, "topAnswersWithSpan": 1}, "includeUnstructuredSources": + true}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '254' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-language-questionanswering/1.0.0b1 Python/3.7.4 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://test-resource.api.cognitive.microsoft.com/language/:query-knowledgebases?projectName=test-project&deploymentName=test&api-version=2021-05-01-preview + response: + body: + string: "{\n \"answers\": [\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.9292,\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.3583,\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.2229,\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: + - 6364fbb3-83b7-4d3d-815c-6663f41e1ae4 + content-length: + - '1609' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 13 Jul 2021 17:24:02 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '384' + status: + code: 200 + message: OK +version: 1 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 new file mode 100644 index 000000000000..b4617b51ea19 --- /dev/null +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_knowledgebase_async.test_query_knowledgebase_overload.yaml @@ -0,0 +1,54 @@ +interactions: +- request: + body: '{"question": "How long should my Surface battery last?", "top": 3, "userId": + "sd53lsY=", "confidenceScoreThreshold": 0.2, "answerSpanRequest": {"enable": + true, "confidenceScoreThreshold": 0.2, "topAnswersWithSpan": 1}, "includeUnstructuredSources": + true}' + headers: + Accept: + - application/json + Content-Length: + - '254' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-language-questionanswering/1.0.0b1 Python/3.7.4 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://test-resource.api.cognitive.microsoft.com/language/:query-knowledgebases?projectName=test-project&deploymentName=test&api-version=2021-05-01-preview + response: + body: + string: "{\n \"answers\": [\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.9292,\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.3583,\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.2229,\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: 96655173-855c-4e32-bff0-4025625ad191 + content-length: '1609' + content-type: application/json; charset=utf-8 + date: Tue, 13 Jul 2021 17:24:11 GMT + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '314' + 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-05-01-preview +version: 1 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 new file mode 100644 index 000000000000..74e875f88e16 --- /dev/null +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text.test_query_text_overload.yaml @@ -0,0 +1,161 @@ +interactions: +- request: + body: '{"question": "What is the meaning of life?", "records": [{"id": "doc1", + "text": "abc Graphics Surprise, surprise -- our 4K "}, {"id": "doc2", "text": + "e graphics card. While the Nvidia GeForce MX250 GPU isn''t meant for demanding + gaming, it is a step up from integrated graphics as proven by comparing it to + the UHD 620 GPU in the FHD model. The MX250-equipped Envy 13 scored a 116,575 + on the Ice Storm Unlimited benchmark while the base model scored a 82,270. Upgrading + to the discrete graphics gives the Envy 13 better performance than the Notebook + 9 Pro (61,662; UHD 620), Surface Laptop 2 (71,647; UHD 620) and the premium + laptop average (86,937). While the Nvidia GeForce MX250 GPU isn''t meant for + demanding gaming, it is a step up from integrated graphics as proven by comparing + it to the UHD 620 GPU in the FHD model. We played the racing game Dirt 3 at + 92 frames per second on "}, {"id": "doc3", "text": "Graphics Surprise, surprise + -- our 4K Envy 13 came with a discrete graphics card. While the Nvidia GeForce + MX250 GPU isn''t meant for demanding gaming, it is a step up from integrated + graphics as proven by comparing it to the UHD 620 GPU in the FHD model. The + MX250-equipped Envy 13 scored a 116,575 on the Ice Storm Unlimited benchmark + while the base model scored a 82,270. Upgrading to the discrete graphics gives + the Envy 13 better performance than the Notebook 9 Pro (61,662; UHD 620), Surface + Laptop 2 (71,647; UHD 620) and the premium laptop average (86,937). While + the Nvidia GeForce MX250 GPU isn''t meant for demanding gaming, it is a step + up from integrated graphics as proven by comparing it to the UHD 620 GPU in + the FHD model. We played the racing game Dirt 3 at 92 frames per second on + the MX250 model, which is well above our 30-fps playability, the category average + (69 fps) and what the Surface Laptop 2 (82 fps) achieved. The ZenBook S UX391UA + (45 fps) fell flat on this real-world test but ran better than the base model + Envy 13 (31 fps). Audio I had a good ol'' time groovin'' to the sound of the + Envy 13''s crisp speakers. HP went all out with the Envy, placing dual speakers + on the underside of the chassis along with a third, top-firing driver above + the keyboard. Devon Gilfillian''s funky jam \"Here and Now\" boomed smooth, + soulful tunes throughout my small apartment. The twang of the electric guitar + played nicely with the thudding percussion but never overshadowed Gilfillian + or the female backup vocals. Bang & Olufsen software comes preinstalled on + the Envy 13, with equalizer controls so you can adjust the bass, midrange and + treble to your liking. But even out of the box, you''ll enjoy great sound without + having to bust out your headphones. Battery Life Get an Envy 13 with the 1080p + non-touch display if battery life is important to you. The FHD model endured + for 11 hours and 11 minutes whereas the 4K model lasted only 4 hours and 36 + minutes on our battery test, which involves continuous web browsing over Wi-Fi + at 150 nits of brightness. MORE: Laptops with Best 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. Webcam The 720p webcam on the + Envy 13 is nothing to write home about. A selfie I snapped in my dimly lit room + was covered in a haze of visual noise. My beard and hair were unkempt blobs, + while my eyes looked like they were drawn on by a pointillist painter. If there''s + one positive, it''s that the lens captures natural colors and even extracted + the different shades of gray in my T-shirt. On the right edge of the Envy + 13 is a physical kill switch that cuts the power to the webcam so you can feel + reassured that nobody is snooping on you. Heat Leave the lapdesk at home + - you don''t have to worry about the Envy 13 overheating. After I played + a 15-minute, full-HD video in full screen, the touchpad on the HP Envy 13 with + a Core i7 CPU rose to only 83 degrees Fahrenheit while the keyboard (87 degrees) + and underside (90 degrees) also remained well below our 95-degree comfort threshold. + Even the toastiest part of the machine, the lower-left edge on the underside, + topped out at 94 degrees. Software and Warranty It''s a shame that a laptop + with such beautiful hardware ships with such ugly software. Pre-installed on + this machine are entirely too many programs that could either be packaged together + or omitted altogether. HP provides an app called Audio Switch, which simply + lets you switch your audio input/output between the internal speakers and headphones. + As the same implies, HP''s Command Center is where you can get information about + your Envy 13 but also switch the thermal profiles between comfort and performance. + Along with support documentation, HP also bundles in a setup program called + JumpStart, a program for connecting printers and a redundant system-info app + called Event Utility. Also installed on the Envy 13''s Windows 10 Home OS + are several Microsoft apps, including Simple Solitaire, Candy Crush Friends + and Your Phone. Other third-party apps include Booking.com, Netflix and McAfee + Security. HP ships the Envy 13 with a one-year warranty. See how HP did on + our Tech Support Showdown and Best and Worst Brands ranking. Bottom Line The + Envy 13 has cemented its standing as the ultimate laptop for college students + or travelers. 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, 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. The new HP Envy 13 is everything I was hoping the new MacBook Air + would be: fast, attractive and affordable. Just be sure to buy the right model. + We strongly recommend the 1080p version over the 4K model because it lasts several + hours longer on a charge and costs less. In fact, if we were reviewing the 4K + model separately, we''d only give it a 3.5 rating. You should also consider + the Envy 13 with a 10th Gen CPU, although we haven''t gotten the chance to review + it yet. If you absolutely need a high-res display, the 4K Envy 13 is one of + many good options. 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. Credit: Laptop Mag HP Envy 13 (2019) Specs BluetoothBluetooth + 5.0 BrandHP CPUIntel Core i7-8565U Card SlotsmicroSD Company Websitehttps://www8.hp.com/us/en/home.html + Display Size13.3 Graphics CardNvidia GeForce MX250 Hard Drive Size512GB Hard + Drive TypePCIe NVMe M.2 Highest Available Resolution3840 x 2160 Native Resolution3840 + x 2160 Operating SystemWindows 10 Home Ports (excluding USB)USB 3.1 with Type-C, + 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"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '7447' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-language-questionanswering/1.0.0b1 Python/3.7.4 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://test-resource.api.cognitive.microsoft.com/language/:query-text?api-version=2021-05-01-preview + response: + body: + string: "{\n \"answers\": [\n {\n \"answer\": \"Battery Life Get an + Envy 13 with the 1080p non-touch display if battery life is important to you. + \ The FHD model endured for 11 hours and 11 minutes whereas the 4K model + lasted only 4 hours and 36 minutes on our battery test, which involves continuous + web browsing over Wi-Fi at 150 nits of brightness. MORE: Laptops with Best + 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 + \ \"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 + 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, + 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 + \ \"answerSpan\": {\n \"text\": \"battery life\",\n \"confidenceScore\": + 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 + \ \"answerSpan\": {\n \"text\": \"battery life\",\n \"confidenceScore\": + 0.5914322,\n \"offset\": 98,\n \"length\": 13\n },\n \"offset\": + 5391,\n \"length\": 393\n }\n ]\n}" + headers: + apim-request-id: + - 1166df47-3640-4276-ba1b-8352467aabde + content-length: + - '2147' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 13 Jul 2021 17:24:16 GMT + strict-transport-security: + - max-age=31536000; includeSubDomains; preload + x-content-type-options: + - nosniff + x-envoy-upstream-service-time: + - '263' + status: + code: 200 + message: OK +version: 1 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 new file mode 100644 index 000000000000..45124a7a4e5b --- /dev/null +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/recordings/test_query_text_async.test_query_text_overload.yaml @@ -0,0 +1,151 @@ +interactions: +- request: + body: '{"question": "What is the meaning of life?", "records": [{"id": "doc1", + "text": "abc Graphics Surprise, surprise -- our 4K "}, {"id": "doc2", "text": + "e graphics card. While the Nvidia GeForce MX250 GPU isn''t meant for demanding + gaming, it is a step up from integrated graphics as proven by comparing it to + the UHD 620 GPU in the FHD model. The MX250-equipped Envy 13 scored a 116,575 + on the Ice Storm Unlimited benchmark while the base model scored a 82,270. Upgrading + to the discrete graphics gives the Envy 13 better performance than the Notebook + 9 Pro (61,662; UHD 620), Surface Laptop 2 (71,647; UHD 620) and the premium + laptop average (86,937). While the Nvidia GeForce MX250 GPU isn''t meant for + demanding gaming, it is a step up from integrated graphics as proven by comparing + it to the UHD 620 GPU in the FHD model. We played the racing game Dirt 3 at + 92 frames per second on "}, {"id": "doc3", "text": "Graphics Surprise, surprise + -- our 4K Envy 13 came with a discrete graphics card. While the Nvidia GeForce + MX250 GPU isn''t meant for demanding gaming, it is a step up from integrated + graphics as proven by comparing it to the UHD 620 GPU in the FHD model. The + MX250-equipped Envy 13 scored a 116,575 on the Ice Storm Unlimited benchmark + while the base model scored a 82,270. Upgrading to the discrete graphics gives + the Envy 13 better performance than the Notebook 9 Pro (61,662; UHD 620), Surface + Laptop 2 (71,647; UHD 620) and the premium laptop average (86,937). While + the Nvidia GeForce MX250 GPU isn''t meant for demanding gaming, it is a step + up from integrated graphics as proven by comparing it to the UHD 620 GPU in + the FHD model. We played the racing game Dirt 3 at 92 frames per second on + the MX250 model, which is well above our 30-fps playability, the category average + (69 fps) and what the Surface Laptop 2 (82 fps) achieved. The ZenBook S UX391UA + (45 fps) fell flat on this real-world test but ran better than the base model + Envy 13 (31 fps). Audio I had a good ol'' time groovin'' to the sound of the + Envy 13''s crisp speakers. HP went all out with the Envy, placing dual speakers + on the underside of the chassis along with a third, top-firing driver above + the keyboard. Devon Gilfillian''s funky jam \"Here and Now\" boomed smooth, + soulful tunes throughout my small apartment. The twang of the electric guitar + played nicely with the thudding percussion but never overshadowed Gilfillian + or the female backup vocals. Bang & Olufsen software comes preinstalled on + the Envy 13, with equalizer controls so you can adjust the bass, midrange and + treble to your liking. But even out of the box, you''ll enjoy great sound without + having to bust out your headphones. Battery Life Get an Envy 13 with the 1080p + non-touch display if battery life is important to you. The FHD model endured + for 11 hours and 11 minutes whereas the 4K model lasted only 4 hours and 36 + minutes on our battery test, which involves continuous web browsing over Wi-Fi + at 150 nits of brightness. MORE: Laptops with Best 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. Webcam The 720p webcam on the + Envy 13 is nothing to write home about. A selfie I snapped in my dimly lit room + was covered in a haze of visual noise. My beard and hair were unkempt blobs, + while my eyes looked like they were drawn on by a pointillist painter. If there''s + one positive, it''s that the lens captures natural colors and even extracted + the different shades of gray in my T-shirt. On the right edge of the Envy + 13 is a physical kill switch that cuts the power to the webcam so you can feel + reassured that nobody is snooping on you. Heat Leave the lapdesk at home + - you don''t have to worry about the Envy 13 overheating. After I played + a 15-minute, full-HD video in full screen, the touchpad on the HP Envy 13 with + a Core i7 CPU rose to only 83 degrees Fahrenheit while the keyboard (87 degrees) + and underside (90 degrees) also remained well below our 95-degree comfort threshold. + Even the toastiest part of the machine, the lower-left edge on the underside, + topped out at 94 degrees. Software and Warranty It''s a shame that a laptop + with such beautiful hardware ships with such ugly software. Pre-installed on + this machine are entirely too many programs that could either be packaged together + or omitted altogether. HP provides an app called Audio Switch, which simply + lets you switch your audio input/output between the internal speakers and headphones. + As the same implies, HP''s Command Center is where you can get information about + your Envy 13 but also switch the thermal profiles between comfort and performance. + Along with support documentation, HP also bundles in a setup program called + JumpStart, a program for connecting printers and a redundant system-info app + called Event Utility. Also installed on the Envy 13''s Windows 10 Home OS + are several Microsoft apps, including Simple Solitaire, Candy Crush Friends + and Your Phone. Other third-party apps include Booking.com, Netflix and McAfee + Security. HP ships the Envy 13 with a one-year warranty. See how HP did on + our Tech Support Showdown and Best and Worst Brands ranking. Bottom Line The + Envy 13 has cemented its standing as the ultimate laptop for college students + or travelers. 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, 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. The new HP Envy 13 is everything I was hoping the new MacBook Air + would be: fast, attractive and affordable. Just be sure to buy the right model. + We strongly recommend the 1080p version over the 4K model because it lasts several + hours longer on a charge and costs less. In fact, if we were reviewing the 4K + model separately, we''d only give it a 3.5 rating. You should also consider + the Envy 13 with a 10th Gen CPU, although we haven''t gotten the chance to review + it yet. If you absolutely need a high-res display, the 4K Envy 13 is one of + many good options. 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. Credit: Laptop Mag HP Envy 13 (2019) Specs BluetoothBluetooth + 5.0 BrandHP CPUIntel Core i7-8565U Card SlotsmicroSD Company Websitehttps://www8.hp.com/us/en/home.html + Display Size13.3 Graphics CardNvidia GeForce MX250 Hard Drive Size512GB Hard + Drive TypePCIe NVMe M.2 Highest Available Resolution3840 x 2160 Native Resolution3840 + x 2160 Operating SystemWindows 10 Home Ports (excluding USB)USB 3.1 with Type-C, + 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"}' + headers: + Accept: + - application/json + Content-Length: + - '7447' + Content-Type: + - application/json + User-Agent: + - azsdk-python-ai-language-questionanswering/1.0.0b1 Python/3.7.4 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://test-resource.api.cognitive.microsoft.com/language/:query-text?api-version=2021-05-01-preview + response: + body: + string: "{\n \"answers\": [\n {\n \"answer\": \"Battery Life Get an + Envy 13 with the 1080p non-touch display if battery life is important to you. + \ The FHD model endured for 11 hours and 11 minutes whereas the 4K model + lasted only 4 hours and 36 minutes on our battery test, which involves continuous + web browsing over Wi-Fi at 150 nits of brightness. MORE: Laptops with Best + 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 + \ \"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 + 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, + 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 + \ \"answerSpan\": {\n \"text\": \"battery life\",\n \"confidenceScore\": + 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 + 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.007057250943034887,\n \"id\": \"doc3\",\n + \ \"answerSpan\": {\n \"text\": \"battery life\",\n \"confidenceScore\": + 0.5914322,\n \"offset\": 98,\n \"length\": 13\n },\n \"offset\": + 5391,\n \"length\": 393\n }\n ]\n}" + headers: + apim-request-id: 82332b85-228b-41c2-b65d-a7b893a52dff + content-length: '2146' + content-type: application/json; charset=utf-8 + date: Tue, 13 Jul 2021 17:24:19 GMT + strict-transport-security: max-age=31536000; includeSubDomains; preload + x-content-type-options: nosniff + x-envoy-upstream-service-time: '254' + status: + code: 200 + message: OK + url: https://wuppe.api.cognitive.microsoft.com/language/:query-text?api-version=2021-05-01-preview +version: 1 diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase.py index 7fdd5e175663..e48e4dc00b82 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 @@ -14,7 +14,7 @@ ) from azure.ai.language.questionanswering import QuestionAnsweringClient -from azure.ai.language.questionanswering.rest import * +from azure.ai.language.questionanswering._rest import * from azure.ai.language.questionanswering.models import ( KnowledgeBaseQueryOptions, KnowledgeBaseAnswerRequestContext, @@ -136,9 +136,9 @@ def test_query_knowledgebase(self, qna_account, qna_key, qna_project): with client: output = client.query_knowledgebase( + query_params, project_name=qna_project, - deployment_name='test', - knowledge_base_query_options=query_params + deployment_name='test' ) assert output.answers @@ -182,9 +182,9 @@ def test_query_knowledgebase_with_answerspan(self, qna_account, qna_key, qna_pro with client: output = client.query_knowledgebase( + query_params, project_name=qna_project, - deployment_name='test', - knowledge_base_query_options=query_params + deployment_name='test' ) assert output.answers @@ -231,11 +231,35 @@ def test_query_knowledgebase_with_dictparams(self, qna_account, qna_key, qna_pro "includeUnstructuredSources": True } + with client: + output = client.query_knowledgebase( + query_params, + project_name=qna_project, + deployment_name='test' + ) + + assert len(output.answers) == 3 + 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" + + @GlobalQuestionAnsweringAccountPreparer() + def test_query_knowledgebase_overload(self, qna_account, qna_key, qna_project): + client = QuestionAnsweringClient(qna_account, AzureKeyCredential(qna_key)) with client: output = client.query_knowledgebase( project_name=qna_project, deployment_name='test', - knowledge_base_query_options=query_params + question="How long should my Surface battery last?", + top=3, + user_id="sd53lsY=", + confidence_score_threshold=0.2, + answer_span_request=AnswerSpanRequest( + enable=True, + confidence_score_threshold=0.2, + top_answers_with_span=1 + ), + include_unstructured_sources=True ) assert len(output.answers) == 3 @@ -261,9 +285,9 @@ def test_query_knowledgebase_with_followup(self, qna_account, qna_key, qna_proje ) output = client.query_knowledgebase( + query_params, project_name=qna_project, - deployment_name='test', - knowledge_base_query_options=query_params + deployment_name='test' ) confident_answers = [a for a in output.answers if a.confidence_score > 0.9] assert len(confident_answers) == 1 @@ -286,9 +310,9 @@ def test_query_knowledgebase_with_followup(self, qna_account, qna_key, qna_proje include_unstructured_sources=True ) output = client.query_knowledgebase( + query_params, project_name=qna_project, - deployment_name='test', - knowledge_base_query_options=query_params + deployment_name='test' ) assert len(output.answers) == 2 @@ -306,9 +330,9 @@ def test_query_knowledgebase_only_id(self, qna_account, qna_key, qna_project): ) output = client.query_knowledgebase( + query_params, project_name=qna_project, - deployment_name='test', - knowledge_base_query_options=query_params + deployment_name='test' ) assert len(output.answers) == 1 @@ -320,9 +344,9 @@ def test_query_knowledgebase_python_dict(self, qna_account, qna_key, qna_project query_params = {"qna_id": 19} output = client.query_knowledgebase( + query_params, project_name=qna_project, - deployment_name='test', - knowledge_base_query_options=query_params + deployment_name='test' ) assert len(output.answers) == 1 \ No newline at end of file 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 fe671c39b49a..d3aa12ca20c1 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 @@ -21,7 +21,7 @@ AnswerSpanRequest, ) from azure.ai.language.questionanswering.aio import QuestionAnsweringClient -from azure.ai.language.questionanswering.rest import * +from azure.ai.language.questionanswering._rest import * class QnAKnowledgeBaseTestsAsync(AsyncQuestionAnsweringTest): @@ -138,9 +138,9 @@ async def test_query_knowledgebase(self, qna_account, qna_key, qna_project): async with client: output = await client.query_knowledgebase( + query_params, project_name=qna_project, - deployment_name='test', - knowledge_base_query_options=query_params + deployment_name='test' ) assert output.answers @@ -184,9 +184,9 @@ async def test_query_knowledgebase_with_answerspan(self, qna_account, qna_key, q async with client: output = await client.query_knowledgebase( + query_params, project_name=qna_project, - deployment_name='test', - knowledge_base_query_options=query_params + deployment_name='test' ) assert output.answers @@ -232,11 +232,35 @@ async def test_query_knowledgebase_with_dictparams(self, qna_account, qna_key, q "includeUnstructuredSources": True } + async with client: + output = await client.query_knowledgebase( + query_params, + project_name=qna_project, + deployment_name='test' + ) + + assert len(output.answers) == 3 + 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" + + @GlobalQuestionAnsweringAccountPreparer() + async def test_query_knowledgebase_overload(self, qna_account, qna_key, qna_project): + client = QuestionAnsweringClient(qna_account, AzureKeyCredential(qna_key)) async with client: output = await client.query_knowledgebase( project_name=qna_project, deployment_name='test', - knowledge_base_query_options=query_params + question="How long should my Surface battery last?", + top=3, + user_id="sd53lsY=", + confidence_score_threshold=0.2, + answer_span_request=AnswerSpanRequest( + enable=True, + confidence_score_threshold=0.2, + top_answers_with_span=1 + ), + include_unstructured_sources=True ) assert len(output.answers) == 3 @@ -262,9 +286,9 @@ async def test_query_knowledgebase_with_followup(self, qna_account, qna_key, qna ) output = await client.query_knowledgebase( + query_params, project_name=qna_project, - deployment_name='test', - knowledge_base_query_options=query_params + deployment_name='test' ) confident_answers = [a for a in output.answers if a.confidence_score > 0.9] assert len(confident_answers) == 1 @@ -287,9 +311,9 @@ async def test_query_knowledgebase_with_followup(self, qna_account, qna_key, qna include_unstructured_sources=True ) output = await client.query_knowledgebase( + query_params, project_name=qna_project, - deployment_name='test', - knowledge_base_query_options=query_params + deployment_name='test' ) assert len(output.answers) == 2 @@ -304,9 +328,9 @@ async def test_query_knowledgebase_only_id(self, qna_account, qna_key, qna_proje query_params = {"qnaId": 19} output = await client.query_knowledgebase( + query_params, project_name=qna_project, - deployment_name='test', - knowledge_base_query_options=query_params + deployment_name='test' ) assert len(output.answers) == 1 @@ -318,9 +342,9 @@ async def test_query_knowledgebase_python_dict(self, qna_account, qna_key, qna_p query_params = {"qna_id": 19} output = await client.query_knowledgebase( + query_params, project_name=qna_project, - deployment_name='test', - knowledge_base_query_options=query_params + deployment_name='test' ) assert len(output.answers) == 1 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 d1c73d036cac..488306fa2510 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 @@ -13,7 +13,7 @@ ) from azure.ai.language.questionanswering import QuestionAnsweringClient -from azure.ai.language.questionanswering.rest import * +from azure.ai.language.questionanswering._rest import * from azure.ai.language.questionanswering.models import ( TextQueryOptions, TextRecord 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 667a8fbd5c36..9f1cfa1f6e10 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 @@ -13,7 +13,7 @@ ) from azure.ai.language.questionanswering.aio import QuestionAnsweringClient -from azure.ai.language.questionanswering.rest import * +from azure.ai.language.questionanswering._rest import * from azure.ai.language.questionanswering.models import ( TextQueryOptions, TextRecord