@@ -45,7 +45,7 @@ def __init__(
45
45
self ._is_legacy_protocol : bool = self ._endpoint .host .endswith ('v3.0' )
46
46
47
47
self ._options : QnAMakerOptions = options or QnAMakerOptions ()
48
- self .validate_options (self ._options )
48
+ self ._validate_options (self ._options )
49
49
50
50
self ._telemetry_client = telemetry_client or NullTelemetryClient ()
51
51
self ._log_personal_information = log_personal_information or False
@@ -187,16 +187,16 @@ async def get_answers(
187
187
"""
188
188
189
189
190
- hydrated_options = self .hydrate_options (options )
191
- self .validate_options (hydrated_options )
190
+ hydrated_options = self ._hydrate_options (options )
191
+ self ._validate_options (hydrated_options )
192
192
193
- result = self .query_qna_service (context .activity , hydrated_options )
193
+ result = self ._query_qna_service (context .activity , hydrated_options )
194
194
195
- await self .emit_trace_info (context , result , hydrated_options )
195
+ await self ._emit_trace_info (context , result , hydrated_options )
196
196
197
197
return result
198
198
199
- def validate_options (self , options : QnAMakerOptions ):
199
+ def _validate_options (self , options : QnAMakerOptions ):
200
200
if not options .score_threshold :
201
201
options .score_threshold = 0.3
202
202
@@ -210,9 +210,9 @@ def validate_options(self, options: QnAMakerOptions):
210
210
raise ValueError ('QnAMakerOptions.top should be an integer greater than 0' )
211
211
212
212
if not options .strict_filters :
213
- options .strict_filters = [Metadata ]
213
+ options .strict_filters = []
214
214
215
- def hydrate_options (self , query_options : QnAMakerOptions ) -> QnAMakerOptions :
215
+ def _hydrate_options (self , query_options : QnAMakerOptions ) -> QnAMakerOptions :
216
216
"""
217
217
Combines QnAMakerOptions passed into the QnAMaker constructor with the options passed as arguments into get_answers().
218
218
@@ -238,7 +238,7 @@ def hydrate_options(self, query_options: QnAMakerOptions) -> QnAMakerOptions:
238
238
239
239
return hydrated_options
240
240
241
- def query_qna_service (self , message_activity : Activity , options : QnAMakerOptions ) -> [QueryResult ]:
241
+ def _query_qna_service (self , message_activity : Activity , options : QnAMakerOptions ) -> [QueryResult ]:
242
242
url = f'{ self ._endpoint .host } /knowledgebases/{ self ._endpoint .knowledge_base_id } /generateAnswer'
243
243
244
244
question = {
@@ -250,15 +250,15 @@ def query_qna_service(self, message_activity: Activity, options: QnAMakerOptions
250
250
251
251
serialized_content = json .dumps (question )
252
252
253
- headers = self .get_headers ()
253
+ headers = self ._get_headers ()
254
254
255
255
response = requests .post (url , data = serialized_content , headers = headers )
256
256
257
- result = self .format_qna_result (response , options )
257
+ result = self ._format_qna_result (response , options )
258
258
259
259
return result
260
260
261
- async def emit_trace_info (self , turn_context : TurnContext , result : [QueryResult ], options : QnAMakerOptions ):
261
+ async def _emit_trace_info (self , turn_context : TurnContext , result : [QueryResult ], options : QnAMakerOptions ):
262
262
trace_info = QnAMakerTraceInfo (
263
263
message = turn_context .activity ,
264
264
query_results = result ,
@@ -278,7 +278,7 @@ async def emit_trace_info(self, turn_context: TurnContext, result: [QueryResult]
278
278
279
279
await turn_context .send_activity (trace_activity )
280
280
281
- def format_qna_result (self , qna_result : requests .Response , options : QnAMakerOptions ) -> [QueryResult ]:
281
+ def _format_qna_result (self , qna_result : requests .Response , options : QnAMakerOptions ) -> [QueryResult ]:
282
282
result = qna_result .json ()
283
283
284
284
answers_within_threshold = [
@@ -297,7 +297,7 @@ def format_qna_result(self, qna_result: requests.Response, options: QnAMakerOpti
297
297
298
298
return answers_as_query_results
299
299
300
- def get_headers (self ):
300
+ def _get_headers (self ):
301
301
headers = { 'Content-Type' : 'application/json' }
302
302
303
303
if self ._is_legacy_protocol :
0 commit comments