-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[QnA] Release prep #19947
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[QnA] Release prep #19947
Changes from all commits
405ee75
a5b025f
ee858a6
8ce285f
6502e8f
d6f43cf
a523c73
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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:`<a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview">https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview</a>`. | ||
| """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. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: for review purposes, would be great - if heredoc supports it (I actually don't know) - if this was separated on multiple lines. GH doesn't make this easy to review otherwise.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah - this is in autorest, there were a couple of docs quirks I had to manually edit - but they're rendering okay. |
||
|
|
||
| :param endpoint: Supported Cognitive Services endpoint (e.g., | ||
| https://:code:`<resource-name>`.api.cognitiveservices.azure.com). | ||
| https://<resource-name>.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) | ||
| <HttpRequest [POST], url: '/:query-knowledgebases'> | ||
| >>> response = client.send_request(request) | ||
| <HttpResponse: 200 OK> | ||
|
|
||
| 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. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I take it these can't also just be strings, right? From the implementation I don't see any auto-incrementing like Text Analytics did, which I copied for .NET. Probably don't need to worry about it now, but you might open an issue to consider for beta 2.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I will open an issue for this. |
||
| :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: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,6 +102,43 @@ def query_knowledgebase( | |
| **kwargs # type: Any | ||
| ): | ||
| # type: (...) -> "_models.KnowledgeBaseAnswers" | ||
| """Answers the specified question using your knowledge base. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't the method now be
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmmm that's a good point - I think this happened because my swagger readme file was redefining the operations IDs of the APIs - and so the capitalization change in the operation was ignored. I will open an issue for this. |
||
|
|
||
| :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: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: trailing comma makes the diff cleaner next time, like you did on line 66 above. |
||
| ], | ||
| extras_require={ | ||
| ":python_version<'3.0'": ['futures', 'azure-ai-language-nspkg'], | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| # Release History | ||
|
|
||
| ## 1.0.0 (unreleased) | ||
| ## 1.0.0 (2021-07-27) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. I should probably do something like that.