diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/CHANGELOG.md b/sdk/cognitivelanguage/azure-ai-language-questionanswering/CHANGELOG.md index 204bcaba541c..d0b11136cae8 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/CHANGELOG.md +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## 1.0.0b1 (unreleased) +## 1.0.0b1 (2021-07-27) ### Features Added -* Initial release. +* Initial release - supports querying from text records and knowledge bases. diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/README.md b/sdk/cognitivelanguage/azure-ai-language-questionanswering/README.md index b35f26e1f310..740c535acdc1 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/README.md +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/README.md @@ -26,7 +26,7 @@ pip install azure-ai-language-questionanswering ### Authenticate the client -In order to interact with the Question Answering service, you'll need to create an instance of the [`QuestionAnsweringClient`][questionanswering_client_class] class. You will need an **endpoint**, and an **API key** instantiate a client object. For more information regarding authenticating with Cognitive Services, see [Authenticate requests to Azure Cognitive Services][cognitive_auth]. +In order to interact with the Question Answering service, you'll need to create an instance of the [QuestionAnsweringClient][questionanswering_client_class] class. You will need an **endpoint**, and an **API key** to instantiate a client object. For more information regarding authenticating with Cognitive Services, see [Authenticate requests to Azure Cognitive Services][cognitive_auth]. #### Get an API key @@ -56,7 +56,7 @@ client = QuestionAnsweringClient(endpoint, credential) ### QuestionAnsweringClient -The [`QuestionAnsweringClient`][questionanswering_client_class] is the primary interface for asking questions using a knowledge base with your own information, or text input using pre-trained models. +The [QuestionAnsweringClient][questionanswering_client_class] is the primary interface for asking questions using a knowledge base with your own information, or text input using pre-trained models. For asynchronous operations, an async `QuestionAnsweringClient` is in the `azure.ai.language.questionanswering.aio` namespace. ## Examples @@ -140,7 +140,7 @@ Optional keyword arguments can be passed in at the client and per-operation leve ### 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. +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. For example, if you submit a question to a non-existant knowledge base, a `400` error is returned indicating "Bad Request". 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 c38beab9a4a0..3845ead22d0a 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 @@ -25,10 +25,10 @@ class QuestionAnsweringClient(QuestionAnsweringClientOperationsMixin): - """The language service API is a suite of natural language processing (NLP) skills built with best-in-class Microsoft machine learning algorithms. The API can be used to analyze unstructured text for tasks such as sentiment analysis, key phrase extraction, language detection and question answering. Further documentation can be found in :code:`https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview`. + """The language service API is a suite of natural language processing (NLP) skills built with best-in-class Microsoft machine learning algorithms. The API can be used to analyze unstructured text for tasks such as sentiment analysis, key phrase extraction, language detection and question answering. Further documentation can be found in https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview. :param endpoint: Supported Cognitive Services endpoint (e.g., - https://:code:``.api.cognitiveservices.azure.com). + https://.api.cognitiveservices.azure.com). :type endpoint: str :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.AzureKeyCredential @@ -57,21 +57,8 @@ def send_request( ): # type: (...) -> HttpResponse """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 = 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. - :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. 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 516c3e4685c8..6185b8aeaa1e 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 @@ -20,10 +20,10 @@ class QuestionAnsweringClient(QuestionAnsweringClientOperationsMixin): - """The language service API is a suite of natural language processing (NLP) skills built with best-in-class Microsoft machine learning algorithms. The API can be used to analyze unstructured text for tasks such as sentiment analysis, key phrase extraction, language detection and question answering. Further documentation can be found in :code:`https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview`. + """The language service API is a suite of natural language processing (NLP) skills built with best-in-class Microsoft machine learning algorithms. The API can be used to analyze unstructured text for tasks such as sentiment analysis, key phrase extraction, language detection and question answering. Further documentation can be found in https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview. :param endpoint: Supported Cognitive Services endpoint (e.g., - https://:code:``.api.cognitiveservices.azure.com). + https://.api.cognitiveservices.azure.com). :type endpoint: str :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.AzureKeyCredential @@ -41,10 +41,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. - 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. :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest 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 d00528f98e57..fdee9098cb24 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 @@ -111,6 +111,43 @@ async def query_knowledgebase( *args, **kwargs: Any ) -> "_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 + 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 + :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 + 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. + :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 + """ if args: knowledge_base_query_options = args[0] else: @@ -216,6 +253,30 @@ async def query_text( async def query_text( self, *args, **kwargs: Any ) -> "_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 + 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 + 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 + 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) + :rtype: ~azure.ai.language.questionanswering.models.TextAnswers + :raises: ~azure.core.exceptions.HttpResponseError + """ if args: text_query_options = args[0] else: 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 7ef8222e0664..7f76c69ab66f 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 @@ -102,6 +102,43 @@ def query_knowledgebase( **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 + 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 + :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 + 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. + :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 + """ if args: knowledge_base_query_options = args[0] else: @@ -207,6 +244,30 @@ def query_text( **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 + 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 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 + individual keyword arguments. If both are provided, only the options object will be used. + :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 + """ if args: text_query_options = args[0] else: diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/README.md b/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/README.md index ae1e8d2cb2c1..5a5bfede5c9d 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/README.md +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/README.md @@ -35,7 +35,7 @@ These sample programs show common scenarios for the QuestionAnswering client's o ## Setup -1. Install the Azure QuestionAnswering client library for Python with [pip][pip]): +1. Install the Azure QuestionAnswering client library for Python with [pip][pip]: ```bash pip install --pre azure-ai-language-questionanswering ``` diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/setup.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/setup.py index ff44705781b0..c5c359fe8608 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/setup.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/setup.py @@ -61,13 +61,14 @@ # 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', 'azure.ai', 'azure.ai.language', ]), install_requires=[ 'azure-core<2.0.0,>=1.16.0', - "msrest>=0.6.21" + 'msrest>=0.6.21', + 'chardet>=3.0.2,<5' ], extras_require={ ":python_version<'3.0'": ['futures', 'azure-ai-language-nspkg'], diff --git a/sdk/nspkg/azure-ai-language-nspkg/CHANGELOG.md b/sdk/nspkg/azure-ai-language-nspkg/CHANGELOG.md index b9f7cb3c5975..f5d45f31a7da 100644 --- a/sdk/nspkg/azure-ai-language-nspkg/CHANGELOG.md +++ b/sdk/nspkg/azure-ai-language-nspkg/CHANGELOG.md @@ -1,3 +1,3 @@ # Release History -## 1.0.0 (unreleased) +## 1.0.0 (2021-07-27) diff --git a/sdk/nspkg/ci.yml b/sdk/nspkg/ci.yml index 6b64ffa1c6b1..b88454fd1a75 100644 --- a/sdk/nspkg/ci.yml +++ b/sdk/nspkg/ci.yml @@ -40,6 +40,9 @@ extends: - name: azure-ai-translation-nspkg safeName: azureaitranslationnspkg skipVerifyChangeLog: true + - name: azure-ai-language-nspkg + safeName: azureailanguagenspkg + skipVerifyChangeLog: true - name: azure-communication-nspkg safeName: azurecommunicationnspkg skipVerifyChangeLog: true diff --git a/shared_requirements.txt b/shared_requirements.txt index 3a1b2804d60f..2dce0bfc19d2 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -127,6 +127,7 @@ six>=1.11.0 isodate>=0.6.0 avro<2.0.0,>=1.10.0 pyjwt>=1.7.1 +chardet<5,>=3.0.2 #override azure azure-keyvault~=1.0 #override azure-mgmt-core azure-core<2.0.0,>=1.15.0 #override azure-containerregistry azure-core>=1.4.0,<2.0.0