66# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77# --------------------------------------------------------------------------
88import functools
9- from typing import Any , Callable , Dict , Generic , Optional , TypeVar
9+ from typing import Any , Callable , Dict , Generic , Optional , TypeVar , overload , Union , List
1010import warnings
1111
1212from azure .core .exceptions import (
2020from azure .core .pipeline .transport import AsyncHttpResponse
2121from azure .core .rest import HttpRequest
2222
23- from ... import models as _models , rest as rest
23+ from ... import models as _models , _rest as rest
2424
2525T = TypeVar ("T" )
2626ClsType = Optional [Callable [[PipelineResponse [HttpRequest , AsyncHttpResponse ], T , Dict [str , Any ]], Any ]]
2727
2828
2929class QuestionAnsweringClientOperationsMixin :
30+ @overload
3031 async def query_knowledgebase (
3132 self ,
3233 knowledge_base_query_options : "_models.KnowledgeBaseQueryOptions" ,
@@ -37,8 +38,6 @@ async def query_knowledgebase(
3738 ) -> "_models.KnowledgeBaseAnswers" :
3839 """Answers the specified question using your knowledge base.
3940
40- Answers the specified question using your knowledge base.
41-
4241 :param knowledge_base_query_options: Post body of the request.
4342 :type knowledge_base_query_options:
4443 ~azure.ai.language.questionanswering.models.KnowledgeBaseQueryOptions
@@ -51,10 +50,88 @@ async def query_knowledgebase(
5150 :rtype: ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswers
5251 :raises: ~azure.core.exceptions.HttpResponseError
5352 """
53+ ...
54+
55+ @overload
56+ async def query_knowledgebase (
57+ self ,
58+ * ,
59+ project_name : str ,
60+ deployment_name : Optional [str ] = None ,
61+ qna_id : Optional [int ] = None ,
62+ question : Optional [str ] = None ,
63+ top : Optional [int ] = None ,
64+ user_id : Optional [str ] = None ,
65+ confidence_score_threshold : Optional [float ] = None ,
66+ context : Optional ["_models.KnowledgeBaseAnswerRequestContext" ] = None ,
67+ ranker_type : Optional [Union [str , "_models.RankerType" ]] = None ,
68+ strict_filters : Optional ["_models.StrictFilters" ] = None ,
69+ answer_span_request : Optional ["_models.AnswerSpanRequest" ] = None ,
70+ include_unstructured_sources : Optional [bool ] = None ,
71+ ** kwargs : Any
72+ ) -> "_models.KnowledgeBaseAnswers" :
73+ """Answers the specified question using your knowledge base.
74+
75+ :keyword project_name: The name of the project to use.
76+ :paramtype project_name: str
77+ :keyword deployment_name: The name of the specific deployment of the project to use.
78+ :paramtype deployment_name: str
79+ :keyword qna_id: Exact QnA ID to fetch from the knowledge base, this field takes priority over
80+ question.
81+ :paramtype qna_id: int
82+ :keyword question: User question to query against the knowledge base.
83+ :paramtype question: str
84+ :keyword top: Max number of answers to be returned for the question.
85+ :paramtype top: int
86+ :keyword user_id: Unique identifier for the user.
87+ :paramtype user_id: str
88+ :keyword confidence_score_threshold: Minimum threshold score for answers, value ranges from 0 to
89+ 1.
90+ :paramtype confidence_score_threshold: float
91+ :keyword context: Context object with previous QnA's information.
92+ :paramtype context: ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswerRequestContext
93+ :keyword ranker_type: (Optional) Set to 'QuestionOnly' for using a question only Ranker. Possible
94+ values include: "Default", "QuestionOnly".
95+ :paramtype ranker_type: str or ~azure.ai.language.questionanswering.models.RankerType
96+ :keyword strict_filters: Filter QnAs based on give metadata list and knowledge base source names.
97+ :paramtype strict_filters: ~azure.ai.language.questionanswering.models.StrictFilters
98+ :keyword answer_span_request: To configure Answer span prediction feature.
99+ :paramtype answer_span_request: ~azure.ai.language.questionanswering.models.AnswerSpanRequest
100+ :keyword include_unstructured_sources: (Optional) Flag to enable Query over Unstructured Sources.
101+ :paramtype include_unstructured_sources: bool
102+ :keyword callable cls: A custom type or function that will be passed the direct response
103+ :return: KnowledgeBaseAnswers, or the result of cls(response)
104+ :rtype: ~azure.ai.language.questionanswering.models.KnowledgeBaseAnswers
105+ :raises: ~azure.core.exceptions.HttpResponseError
106+ """
107+ ...
108+
109+ async def query_knowledgebase (
110+ self ,
111+ * args ,
112+ ** kwargs : Any
113+ ) -> "_models.KnowledgeBaseAnswers" :
114+ if args :
115+ knowledge_base_query_options = args [0 ]
116+ else :
117+ knowledge_base_query_options = _models .KnowledgeBaseQueryOptions (
118+ qna_id = kwargs .pop ("qna_id" , None ),
119+ question = kwargs .pop ("question" , None ),
120+ top = kwargs .pop ("top" , None ),
121+ user_id = kwargs .pop ("user_id" , None ),
122+ confidence_score_threshold = kwargs .pop ("confidence_score_threshold" , None ),
123+ context = kwargs .pop ("context" , None ),
124+ ranker_type = kwargs .pop ("ranker_type" , None ),
125+ strict_filters = kwargs .pop ("strict_filters" , None ),
126+ answer_span_request = kwargs .pop ("answer_span_request" , None ),
127+ include_unstructured_sources = kwargs .pop ("include_unstructured_sources" , None )
128+ )
54129 cls = kwargs .pop ("cls" , None ) # type: ClsType["_models.KnowledgeBaseAnswers"]
55130 error_map = {401 : ClientAuthenticationError , 404 : ResourceNotFoundError , 409 : ResourceExistsError }
56131 error_map .update (kwargs .pop ("error_map" , {}))
57132 content_type = kwargs .pop ("content_type" , "application/json" ) # type: Optional[str]
133+ project_name = kwargs .pop ("project_name" ) # type: str
134+ deployment_name = kwargs .pop ("deployment_name" , None ) # type: Optional[str]
58135
59136 json = self ._serialize .body (knowledge_base_query_options , "KnowledgeBaseQueryOptions" )
60137
@@ -89,18 +166,65 @@ async def query_knowledgebase(
89166
90167 query_knowledgebase .metadata = {"url" : "/:query-knowledgebases" } # type: ignore
91168
92- async def query_text (self , text_query_options : "_models.TextQueryOptions" , ** kwargs : Any ) -> "_models.TextAnswers" :
169+ @overload
170+ async def query_text (
171+ self , text_query_options : "_models.TextQueryOptions" , ** kwargs : Any
172+ ) -> "_models.TextAnswers" :
93173 """Answers the specified question using the provided text in the body.
94174
95- Answers the specified question using the provided text in the body.
96-
97175 :param text_query_options: Post body of the request.
98176 :type text_query_options: ~azure.ai.language.questionanswering.models.TextQueryOptions
99177 :keyword callable cls: A custom type or function that will be passed the direct response
100178 :return: TextAnswers, or the result of cls(response)
101179 :rtype: ~azure.ai.language.questionanswering.models.TextAnswers
102180 :raises: ~azure.core.exceptions.HttpResponseError
103181 """
182+ ...
183+
184+ @overload
185+ async def query_text (
186+ self ,
187+ * ,
188+ question : str ,
189+ records : List ["_models.TextRecord" ],
190+ language : Optional [str ] = None ,
191+ string_index_type : Optional [Union [str , "_models.StringIndexType" ]] = "TextElements_v8" ,
192+ ** kwargs : Any
193+ ) -> "_models.TextAnswers" :
194+ """Answers the specified question using the provided text in the body.
195+
196+ :keyword question: Required. User question to query against the given text records.
197+ :paramtype question: str
198+ :keyword records: Required. Text records to be searched for given question.
199+ :paramtype records: list[~azure.ai.language.questionanswering.models.TextRecord]
200+ :keyword language: Language of the text records. This is BCP-47 representation of a language. For
201+ example, use "en" for English; "es" for Spanish etc. If not set, use "en" for English as
202+ default.
203+ :paramtype language: str
204+ :keyword string_index_type: Specifies the method used to interpret string offsets. Defaults to
205+ Text Elements (Graphemes) according to Unicode v8.0.0. For additional information see
206+ https://aka.ms/text-analytics-offsets. Possible values include: "TextElements_v8",
207+ "UnicodeCodePoint", "Utf16CodeUnit". Default value: "TextElements_v8".
208+ :paramtype string_index_type: str or ~azure.ai.language.questionanswering.models.StringIndexType
209+ :keyword callable cls: A custom type or function that will be passed the direct response
210+ :return: TextAnswers, or the result of cls(response)
211+ :rtype: ~azure.ai.language.questionanswering.models.TextAnswers
212+ :raises: ~azure.core.exceptions.HttpResponseError
213+ """
214+ ...
215+
216+ async def query_text (
217+ self , * args , ** kwargs : Any
218+ ) -> "_models.TextAnswers" :
219+ if args :
220+ text_query_options = args [0 ]
221+ else :
222+ text_query_options = _models .TextQueryOptions (
223+ question = kwargs .pop ("question" ),
224+ records = kwargs .pop ("records" ),
225+ language = kwargs .pop ("language" , None ),
226+ string_index_type = kwargs .pop ("string_index_type" , "TextElements_v8" )
227+ )
104228 cls = kwargs .pop ("cls" , None ) # type: ClsType["_models.TextAnswers"]
105229 error_map = {401 : ClientAuthenticationError , 404 : ResourceNotFoundError , 409 : ResourceExistsError }
106230 error_map .update (kwargs .pop ("error_map" , {}))
0 commit comments