private async Task <QueryResults> QueryQnaServiceAsync(Activity messageActivity, QnAMakerOptions options) { var requestUrl = $"{_endpoint.Host}/knowledgebases/{_endpoint.KnowledgeBaseId}/generateanswer"; AnswerSpanRequest answerSpanRequest = null; if (options.EnablePreciseAnswer) { answerSpanRequest = new AnswerSpanRequest(); answerSpanRequest.Enable = options.EnablePreciseAnswer; } var jsonRequest = JsonConvert.SerializeObject( new { question = messageActivity.Text, top = options.Top, strictFilters = options.StrictFilters, scoreThreshold = options.ScoreThreshold, context = options.Context, qnaId = options.QnAId, isTest = options.IsTest, rankerType = options.RankerType, StrictFiltersCompoundOperationType = options.StrictFiltersJoinOperator, answerSpanRequest = answerSpanRequest }, Formatting.None); var httpRequestHelper = new HttpRequestUtils(_httpClient); var response = await httpRequestHelper.ExecuteHttpRequestAsync(requestUrl, jsonRequest, _endpoint).ConfigureAwait(false); var result = await FormatQnaResultAsync(response, options).ConfigureAwait(false); return(result); }
private async Task QueryTrainAsync(FeedbackRecords feedbackRecords) { var requestUrl = $"{_endpoint.Host}/knowledgebases/{_endpoint.KnowledgeBaseId}/train"; var jsonRequest = JsonConvert.SerializeObject(feedbackRecords, Formatting.None); var httpRequestHelper = new HttpRequestUtils(httpClient); var response = await httpRequestHelper.ExecuteHttpRequestAsync(requestUrl, jsonRequest, _endpoint).ConfigureAwait(false); }
private async Task <QueryResult[]> QueryQnaServiceAsync(Activity messageActivity, QnAMakerOptions options) { var requestUrl = $"{_endpoint.Host}/knowledgebases/{_endpoint.KnowledgeBaseId}/generateanswer"; var jsonRequest = JsonConvert.SerializeObject( new { question = messageActivity.Text, top = options.Top, strictFilters = options.StrictFilters, metadataBoost = options.MetadataBoost, scoreThreshold = options.ScoreThreshold, }, Formatting.None); var httpRequestHelper = new HttpRequestUtils(httpClient); var response = await httpRequestHelper.ExecuteHttpRequestAsync(requestUrl, jsonRequest, _endpoint).ConfigureAwait(false); var result = await FormatQnaResultAsync(response, options).ConfigureAwait(false); return(result); }