Skip to content
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

feat: Added support for CQA with unit tests. #4162

Merged
merged 23 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
307f063
Added support for CQA with unit tests.
Arsh-Kashyap Mar 16, 2022
d6b3c60
Merge branch 'main' into Arsh-Kashyap/LanguageService
Arsh-Kashyap Mar 16, 2022
059624d
Merge branch 'main' into Arsh-Kashyap/LanguageService
Arsh-Kashyap Mar 17, 2022
dd6ebed
Edited package.json
Arsh-Kashyap Mar 17, 2022
9274bfe
Merge branch 'Arsh-Kashyap/LanguageService' of https://github.com/Ars…
Arsh-Kashyap Mar 17, 2022
ca406e0
Code refactored and version updated.
Arsh-Kashyap Mar 17, 2022
fa8a85d
Increased compatibility with sample.
Arsh-Kashyap Mar 21, 2022
4b212f1
Changed qnaServiceType to enum from string
Arsh-Kashyap Mar 22, 2022
5f0ea08
Reverted package.json
Arsh-Kashyap Mar 25, 2022
27dae99
Updated documentational comments.
Arsh-Kashyap Mar 25, 2022
9993234
Updated tests for QnACardBuilder.
Arsh-Kashyap Mar 25, 2022
ed75c75
Resolved conflicts.
Arsh-Kashyap Mar 25, 2022
481e8a8
Updated QnAMaker tests.
Arsh-Kashyap Mar 25, 2022
e4e5d6d
Merge branch 'main' of https://github.com/microsoft/botbuilder-js int…
Arsh-Kashyap Mar 29, 2022
762e9e4
Ensured backward compat in qnaCardBuilder.ts
Arsh-Kashyap Mar 30, 2022
937fad7
Updated reference to serviceType
Arsh-Kashyap Mar 30, 2022
0139560
Updated api signature for botbuilder-ai
Arsh-Kashyap Mar 31, 2022
e646b0a
Updated test for increasing coverage.
Arsh-Kashyap Apr 1, 2022
47dccaa
Updated tests for increasing coverage.
Arsh-Kashyap Apr 1, 2022
4228ad0
Updated exports with newly added files.
Arsh-Kashyap Apr 1, 2022
38e74b5
Updated api signature.
Arsh-Kashyap Apr 1, 2022
e008d13
Undo eslint changes and update comments.
Arsh-Kashyap Apr 7, 2022
a0885e1
Applied eslint
Arsh-Kashyap Apr 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 145 additions & 9 deletions libraries/botbuilder-ai/etc/botbuilder-ai.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ import { WaterfallStepContext } from 'botbuilder-dialogs';
// @public
export class ActiveLearningUtils {
static getLowScoreVariation(qnaSearchResults: QnAMakerResult[]): QnAMakerResult[];
static MaximumScoreForLowScoreVariation: number;
static MinimumScoreForLowScoreVariation: number;
static readonly MaximumScoreForLowScoreVariation = 95;
static readonly MaxLowScoreVariationMultiplier = 1;
static readonly MinimumScoreForLowScoreVariation = 20;
static readonly PreviousLowScoreVariationMultiplier = 0.7;
}

// @public
Expand All @@ -52,6 +54,49 @@ export enum Anchor {
Start = "start"
}

// @public
export interface AnswerSpanResponse {
endIndex?: number;
score: number;
startIndex?: number;
text: string;
}

// Warning: (ae-forgotten-export) The symbol "QnAMakerClient" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "QnAMakerTelemetryClient" needs to be exported by the entry point index.d.ts
//
// @public
export class CustomQuestionAnswering implements QnAMakerClient_2, QnAMakerTelemetryClient_2 {
constructor(endpoint: QnAMakerEndpoint, options?: QnAMakerOptions, telemetryClient?: BotTelemetryClient, logPersonalInformation?: boolean);
callTrain(feedbackRecords: FeedbackRecords): Promise<void>;
protected fillQnAEvent(qnaResults: QnAMakerResult[], turnContext: TurnContext, telemetryProperties?: Record<string, string>, telemetryMetrics?: Record<string, number>): Promise<[Record<string, string>, Record<string, number>]>;
getAnswers(context: TurnContext, options?: QnAMakerOptions, telemetryProperties?: {
[key: string]: string;
}, telemetryMetrics?: {
[key: string]: number;
}): Promise<QnAMakerResult[]>;
getAnswersRaw(context: TurnContext, options: QnAMakerOptions, telemetryProperties: {
[key: string]: string;
}, telemetryMetrics: {
[key: string]: number;
}): Promise<QnAMakerResults>;
getKnowledgebaseAnswersRaw(context: TurnContext, options: QnAMakerOptions, telemetryProperties: {
[key: string]: string;
}, telemetryMetrics: {
[key: string]: number;
}): Promise<QnAMakerResults>;
getLowScoreVariation(queryResult: QnAMakerResult[]): QnAMakerResult[];
// (undocumented)
get logPersonalInformation(): boolean;
protected onQnaResults(qnaResults: QnAMakerResult[], turnContext: TurnContext, telemetryProperties?: {
[key: string]: string;
}, telemetryMetrics?: {
[key: string]: number;
}): Promise<void>;
// (undocumented)
get telemetryClient(): BotTelemetryClient;
}

// @public
export interface DateTimeSpec {
timex: string[];
Expand Down Expand Up @@ -84,6 +129,16 @@ export interface FeedbackRecords {
feedbackRecords: FeedbackRecord[];
}

// @public
export interface Filters {
// (undocumented)
logicalOperation: string;
// (undocumented)
metadataFilter: MetadataFilter;
// (undocumented)
sourceFilter: Array<string>;
}

// @public
export interface GeographyV2 {
location: string;
Expand Down Expand Up @@ -125,6 +180,44 @@ export enum JoinOperator {
OR = "OR"
}

// @public
export interface KnowledgeBaseAnswer {
// (undocumented)
answer: string;
// (undocumented)
answerSpan: KnowledgeBaseAnswerSpan;
// (undocumented)
confidenceScore: number;
// (undocumented)
dialog: QnAResponseContext;
// (undocumented)
id: number;
// (undocumented)
metadata: Map<string, string>;
// (undocumented)
questions: string[];
// (undocumented)
source: string;
}

// @public
export interface KnowledgeBaseAnswers {
// (undocumented)
answers: KnowledgeBaseAnswer[];
}

// @public
export interface KnowledgeBaseAnswerSpan {
// (undocumented)
confidenceScore: number;
// (undocumented)
length: number;
// (undocumented)
offset: number;
// (undocumented)
text: string;
}

// @public
export interface ListElement {
canonicalForm?: string;
Expand Down Expand Up @@ -311,6 +404,17 @@ export class LuisTelemetryConstants {
static readonly sentimentScoreProperty = "sentimentScore";
}

// @public
export interface MetadataFilter {
// (undocumented)
logicalOperation: string;
// (undocumented)
metadata: Array<{
key: string;
value: string;
}>;
}

// @public
export interface NumberWithUnits {
number?: number;
Expand All @@ -325,6 +429,7 @@ export interface OrdinalV2 {

// @public
export class QnACardBuilder {
static getQnAAnswerCard(result: QnAMakerResult, displayPreciseAnswerOnly: boolean): Partial<Activity>;
static getQnAPromptsCard(result: QnAMakerResult): Partial<Activity>;
static getSuggestionsCard(suggestionsList: string[], cardTitle: string, cardNoMatchText: string): Partial<Activity>;
}
Expand All @@ -338,13 +443,18 @@ export class QnAMaker implements QnAMakerClient, QnAMakerTelemetryClient {
callTrain(feedbackRecords: FeedbackRecords): Promise<void>;
protected fillQnAEvent(qnaResults: QnAMakerResult[], turnContext: TurnContext, telemetryProperties?: Record<string, string>, telemetryMetrics?: Record<string, number>): Promise<[Record<string, string>, Record<string, number>]>;
// @deprecated
generateAnswer(question: string | undefined, top?: number, scoreThreshold?: number): Promise<QnAMakerResult[]>;
generateAnswer(question: string | undefined, top?: number, _scoreThreshold?: number): Promise<QnAMakerResult[]>;
getAnswers(context: TurnContext, options?: QnAMakerOptions, telemetryProperties?: {
[key: string]: string;
}, telemetryMetrics?: {
[key: string]: number;
}): Promise<QnAMakerResult[]>;
getAnswersRaw(context: TurnContext, options?: QnAMakerOptions, telemetryProperties?: {
getAnswersRaw(context: TurnContext, options: QnAMakerOptions, telemetryProperties: {
[key: string]: string;
}, telemetryMetrics: {
[key: string]: number;
}): Promise<QnAMakerResults>;
getLegacyAnswersRaw(context: TurnContext, options?: QnAMakerOptions, telemetryProperties?: {
[key: string]: string;
}, telemetryMetrics?: {
[key: string]: number;
Expand Down Expand Up @@ -399,23 +509,27 @@ export class QnAMakerComponentRegistration extends ComponentRegistration {
export class QnAMakerDialog extends WaterfallDialog implements QnAMakerDialogConfiguration {
// (undocumented)
static $kind: string;
constructor(knowledgeBaseId?: string, endpointKey?: string, hostname?: string, noAnswer?: Activity, threshold?: number, activeLearningCardTitle?: string, cardNoMatchText?: string, top?: number, cardNoMatchResponse?: Activity, strictFilters?: QnAMakerMetadata[], dialogId?: string, strictFiltersJoinOperator?: JoinOperator);
constructor(knowledgeBaseId?: string, endpointKey?: string, hostname?: string, noAnswer?: Activity, threshold?: number, suggestionsActivityFactory?: QnASuggestionsActivityFactory, cardNoMatchText?: string, top?: number, cardNoMatchResponse?: Activity, strictFilters?: QnAMakerMetadata[], dialogId?: string, strictFiltersJoinOperator?: JoinOperator);
constructor(knowledgeBaseId?: string, endpointKey?: string, hostname?: string, noAnswer?: Activity, threshold?: number, activeLearningCardTitle?: string, cardNoMatchText?: string, top?: number, cardNoMatchResponse?: Activity, rankerType?: RankerTypes, strictFilters?: QnAMakerMetadata[], dialogId?: string, strictFiltersJoinOperator?: JoinOperator, enablePreciseAnswer?: boolean, displayPreciseAnswerOnly?: boolean, qnaServiceType?: ServiceType);
constructor(knowledgeBaseId?: string, endpointKey?: string, hostname?: string, noAnswer?: Activity, threshold?: number, suggestionsActivityFactory?: QnASuggestionsActivityFactory, cardNoMatchText?: string, top?: number, cardNoMatchResponse?: Activity, rankerType?: RankerTypes, strictFilters?: QnAMakerMetadata[], dialogId?: string, strictFiltersJoinOperator?: JoinOperator, enablePreciseAnswer?: boolean, displayPreciseAnswerOnly?: boolean, qnaServiceType?: ServiceType);
activeLearningCardTitle: StringExpression;
beginDialog(dc: DialogContext, options?: object): Promise<DialogTurnResult>;
cardNoMatchResponse: TemplateInterface<Partial<Activity>, DialogStateManager>;
cardNoMatchText: StringExpression;
continueDialog(dc: DialogContext): Promise<DialogTurnResult>;
protected defaultThreshold: number;
protected defaultTopN: number;
displayPreciseAnswerOnly: boolean;
protected displayQnAResult(step: WaterfallStepContext): Promise<DialogTurnResult>;
enablePreciseAnswer: boolean;
endpointKey: StringExpression;
filters: Filters;
// (undocumented)
getConverter(property: keyof QnAMakerDialogConfiguration): Converter | ConverterFactory;
protected getQnAMakerClient(dc: DialogContext): Promise<QnAMakerClient>;
protected getQnAMakerOptions(dc: DialogContext): Promise<QnAMakerOptions>;
protected getQnAResponseOptions(dc: DialogContext): Promise<QnAMakerDialogResponseOptions>;
hostname: StringExpression;
includeUnstructuredSources: boolean;
isTest: boolean;
knowledgeBaseId: StringExpression;
logPersonalInformation: BoolExpression;
Expand All @@ -424,11 +538,13 @@ export class QnAMakerDialog extends WaterfallDialog implements QnAMakerDialogCon
protected options: string;
protected previousQnAId: string;
protected qnAContextData: string;
qnaServiceType: ServiceType;
rankerType: EnumExpression<RankerTypes>;
strictFilters: ArrayExpression<QnAMakerMetadata>;
strictFilters: QnAMakerMetadata[];
strictFiltersJoinOperator: JoinOperator;
threshold: NumberExpression;
top: IntExpression;
}
}

// @public
export interface QnAMakerDialogOptions {
Expand All @@ -441,6 +557,7 @@ export interface QnAMakerDialogResponseOptions {
activeLearningCardTitle: string;
cardNoMatchResponse: Partial<Activity>;
cardNoMatchText: string;
displayPreciseAnswerOnly: boolean;
noAnswer: Partial<Activity>;
}

Expand All @@ -449,6 +566,7 @@ export interface QnAMakerEndpoint {
endpointKey: string;
host: string;
knowledgeBaseId: string;
qnaServiceType?: ServiceType;
}

// @public
Expand All @@ -460,6 +578,10 @@ export interface QnAMakerMetadata {
// @public
export interface QnAMakerOptions {
context?: QnARequestContext;
enablePreciseAnswer?: boolean;
// (undocumented)
filters?: Filters;
includeUnstructuredSources?: boolean;
isTest?: boolean;
metadataBoost?: QnAMakerMetadata[];
qnaId?: number;
Expand All @@ -471,6 +593,14 @@ export interface QnAMakerOptions {
top?: number;
}

// @public
export interface QnAMakerPrompt {
displayOrder: number;
displayText: string;
qna?: object;
qnaId: number;
}

// @public
export class QnAMakerRecognizer extends Recognizer implements QnAMakerRecognizerConfiguration {
// (undocumented)
Expand Down Expand Up @@ -537,6 +667,7 @@ export interface QnAMakerRecognizerConfiguration extends RecognizerConfiguration
// @public
export interface QnAMakerResult {
answer: string;
answerSpan?: AnswerSpanResponse;
context?: QnAResponseContext;
id?: number;
metadata?: any;
Expand Down Expand Up @@ -583,7 +714,6 @@ export interface QnARequestContext {

// @public
export interface QnAResponseContext {
// Warning: (ae-forgotten-export) The symbol "QnAMakerPrompt" needs to be exported by the entry point index.d.ts
prompts: QnAMakerPrompt[];
}

Expand All @@ -597,6 +727,12 @@ export enum RankerTypes {
questionOnly = "QuestionOnly"
}

// @public
export enum ServiceType {
language = "Language",
qnaMaker = "QnAMaker"
}

// @public
export function validateDynamicList(dynamicList: DynamicList): void;

Expand Down
Loading