Upravit

Sdílet prostřednictvím


QnAMaker class

Query a QnA Maker knowledge base for answers and provide feedbacks.

Constructors

QnAMaker(QnAMakerEndpoint, QnAMakerOptions, BotTelemetryClient, boolean)

Creates a new QnAMaker instance.

Properties

logPersonalInformation

Gets a value indicating whether determines whether to log personal information that came from the user.

telemetryClient

Gets the currently configured BotTelemetryClient that logs the events.

Methods

answer(TurnContext)

Calls generateAnswer() and sends the resulting answer as a reply to the user.

callTrain(FeedbackRecords)

Send feedback to the knowledge base.

generateAnswer(string | undefined, number, number)

Calls the QnA Maker service to generate answer(s) for a question.

getAnswers(TurnContext, QnAMakerOptions, [key: string]: string, [key: string]: number)

Calls the QnA Maker service to generate answer(s) for a question.

getAnswersRaw(TurnContext, QnAMakerOptions, [key: string]: string, [key: string]: number)

Generates an answer from the knowledge base.

getLegacyAnswersRaw(TurnContext, QnAMakerOptions, [key: string]: string, [key: string]: number)

Generates an answer from the QnA Maker knowledge base.

getLowScoreVariation(QnAMakerResult[])

Filters the ambiguous question for active learning.

Constructor Details

QnAMaker(QnAMakerEndpoint, QnAMakerOptions, BotTelemetryClient, boolean)

Creates a new QnAMaker instance.

new QnAMaker(endpoint: QnAMakerEndpoint, options?: QnAMakerOptions, telemetryClient?: BotTelemetryClient, logPersonalInformation?: boolean)

Parameters

endpoint
QnAMakerEndpoint

The endpoint of the knowledge base to query.

options
QnAMakerOptions

(Optional) additional settings used to configure the instance.

telemetryClient

BotTelemetryClient

The BotTelemetryClient used for logging telemetry events.

logPersonalInformation

boolean

Set to true to include personally identifiable information in telemetry events.

Property Details

logPersonalInformation

Gets a value indicating whether determines whether to log personal information that came from the user.

boolean logPersonalInformation

Property Value

boolean

True if will log personal information into the BotTelemetryClient.TrackEvent method; otherwise the properties will be filtered.

telemetryClient

Gets the currently configured BotTelemetryClient that logs the events.

BotTelemetryClient telemetryClient

Property Value

BotTelemetryClient

The currently configured BotTelemetryClient that logs the QnaMessage event.

Method Details

answer(TurnContext)

Warning

This API is now deprecated.

Instead, favor using QnAMaker.getAnswers() to generate answers for a question.

Calls generateAnswer() and sends the resulting answer as a reply to the user.

function answer(context: TurnContext): Promise<boolean>

Parameters

context

TurnContext

Context for the current turn of conversation with the user.

Returns

Promise<boolean>

A promise resolving to true if an answer was sent

callTrain(FeedbackRecords)

Send feedback to the knowledge base.

function callTrain(feedbackRecords: FeedbackRecords): Promise<void>

Parameters

feedbackRecords
FeedbackRecords

Feedback records.

Returns

Promise<void>

A promise representing the async operation

generateAnswer(string | undefined, number, number)

Warning

This API is now deprecated.

Instead, favor using QnAMaker.getAnswers() to generate answers for a question.

Calls the QnA Maker service to generate answer(s) for a question.

function generateAnswer(question: string | undefined, top?: number, _scoreThreshold?: number): Promise<QnAMakerResult[]>

Parameters

question

string | undefined

The question to answer.

top

number

(Optional) number of answers to return. Defaults to a value of 1.

_scoreThreshold

number

(Optional) minimum answer score needed to be considered a match to questions. Defaults to a value of 0.001.

Returns

Promise<QnAMakerResult[]>

A promise resolving to the QnAMaker results

getAnswers(TurnContext, QnAMakerOptions, [key: string]: string, [key: string]: number)

Calls the QnA Maker service to generate answer(s) for a question.

function getAnswers(context: TurnContext, options?: QnAMakerOptions, telemetryProperties?: [key: string]: string, telemetryMetrics?: [key: string]: number): Promise<QnAMakerResult[]>

Parameters

context

TurnContext

The Turn Context that contains the user question to be queried against your knowledge base.

options
QnAMakerOptions

(Optional) The options for the QnA Maker knowledge base. If null, constructor option is used for this instance.

telemetryProperties

[key: string]: string

Additional properties to be logged to telemetry with the QnaMessage event.

telemetryMetrics

[key: string]: number

Additional metrics to be logged to telemetry with the QnaMessage event.

Returns

Promise<QnAMakerResult[]>

A promise resolving to the QnAMaker result

getAnswersRaw(TurnContext, QnAMakerOptions, [key: string]: string, [key: string]: number)

Generates an answer from the knowledge base.

function getAnswersRaw(context: TurnContext, options: QnAMakerOptions, telemetryProperties: [key: string]: string, telemetryMetrics: [key: string]: number): Promise<QnAMakerResults>

Parameters

context

TurnContext

The TurnContext that contains the user question to be queried against your knowledge base.

options
QnAMakerOptions

Optional. The QnAMakerOptions for the QnA Maker knowledge base. If null, constructor option is used for this instance.

telemetryProperties

[key: string]: string

Optional. Additional properties to be logged to telemetry with the QnaMessage event.

telemetryMetrics

[key: string]: number

Optional. Additional metrics to be logged to telemetry with the QnaMessage event.

Returns

Promise<QnAMakerResults>

A list of answers for the user query, sorted in decreasing order of ranking score.

getLegacyAnswersRaw(TurnContext, QnAMakerOptions, [key: string]: string, [key: string]: number)

Generates an answer from the QnA Maker knowledge base.

function getLegacyAnswersRaw(context: TurnContext, options?: QnAMakerOptions, telemetryProperties?: [key: string]: string, telemetryMetrics?: [key: string]: number): Promise<QnAMakerResults>

Parameters

context

TurnContext

The TurnContext that contains the user question to be queried against your knowledge base.

options
QnAMakerOptions

Optional. The QnAMakerOptions for the QnA Maker knowledge base. If null, constructor option is used for this instance.

telemetryProperties

[key: string]: string

Optional. Additional properties to be logged to telemetry with the QnaMessage event.

telemetryMetrics

[key: string]: number

Optional. Additional metrics to be logged to telemetry with the QnaMessage event.

Returns

Promise<QnAMakerResults>

A list of answers for the user query, sorted in decreasing order of ranking score.

getLowScoreVariation(QnAMakerResult[])

Filters the ambiguous question for active learning.

function getLowScoreVariation(queryResult: QnAMakerResult[]): QnAMakerResult[]

Parameters

queryResult

QnAMakerResult[]

User query output.

Returns

the filtered results