@microsoft/agents-hosting-dialogs 0.6.1 → 0.6.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/choices/findChoices.d.ts +25 -0
- package/dist/src/choices/findChoices.js.map +1 -1
- package/dist/src/choices/findValues.d.ts +61 -6
- package/dist/src/choices/findValues.js +2 -1
- package/dist/src/choices/findValues.js.map +1 -1
- package/dist/src/choices/recognizeChoices.js +2 -2
- package/dist/src/choices/recognizeChoices.js.map +1 -1
- package/dist/src/dialogEvent.d.ts +14 -8
- package/dist/src/dialogManager.d.ts +34 -0
- package/dist/src/dialogManager.js.map +1 -1
- package/dist/src/dialogSet.d.ts +39 -2
- package/dist/src/dialogSet.js.map +1 -1
- package/dist/src/dialogTurnStateConstants.d.ts +1 -0
- package/dist/src/dialogTurnStateConstants.js +1 -0
- package/dist/src/dialogTurnStateConstants.js.map +1 -1
- package/dist/src/memory/dialogStateManager.d.ts +40 -5
- package/dist/src/memory/dialogStateManager.js +1 -1
- package/dist/src/memory/dialogStateManager.js.map +1 -1
- package/dist/src/prompts/confirmPrompt.d.ts +49 -0
- package/dist/src/prompts/confirmPrompt.js.map +1 -1
- package/dist/src/prompts/prompt.d.ts +2 -1
- package/dist/src/prompts/prompt.js.map +1 -1
- package/dist/src/prompts/promptCultureModels.d.ts +64 -30
- package/dist/src/prompts/promptCultureModels.js.map +1 -1
- package/dist/src/recognizer.d.ts +17 -0
- package/dist/src/recognizer.js +1 -0
- package/dist/src/recognizer.js.map +1 -1
- package/dist/src/recognizerResult.d.ts +26 -0
- package/dist/src/recognizerResult.js +26 -0
- package/dist/src/recognizerResult.js.map +1 -1
- package/package.json +2 -2
- package/src/choices/findChoices.ts +28 -0
- package/src/choices/findValues.ts +61 -6
- package/src/choices/recognizeChoices.ts +1 -1
- package/src/dialogEvent.ts +14 -8
- package/src/dialogManager.ts +38 -0
- package/src/dialogSet.ts +39 -2
- package/src/dialogTurnStateConstants.ts +1 -0
- package/src/memory/dialogStateManager.ts +40 -5
- package/src/prompts/confirmPrompt.ts +53 -2
- package/src/prompts/prompt.ts +2 -1
- package/src/prompts/promptCultureModels.ts +69 -30
- package/src/recognizer.ts +17 -0
- package/src/recognizerResult.ts +26 -0
|
@@ -90,7 +90,8 @@ export interface PromptRecognizerResult<T> {
|
|
|
90
90
|
/**
|
|
91
91
|
* Function signature for providing a custom prompt validator.
|
|
92
92
|
*
|
|
93
|
-
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
94
95
|
* type PromptValidator<T> = (prompt: PromptValidatorContext<T>) => Promise<boolean>;
|
|
95
96
|
* ```
|
|
96
97
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../src/prompts/prompt.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,8DAAuE;AACvE,wCAAwE;AACxE,sCAAkC;AAMlC,gEAAgF;AAEhF;;;GAGG;AACH,IAAY,SA8BX;AA9BD,WAAY,SAAS;IACnB;;SAEK;IACL,yCAAI,CAAA;IAEJ;;SAEK;IACL,yCAAI,CAAA;IAEJ;;SAEK;IACL,6CAAM,CAAA;IAEN;;SAEK;IACL,yCAAI,CAAA;IAEJ;;SAEK;IACL,+DAAe,CAAA;IAEf;;SAEK;IACL,iDAAQ,CAAA;AACV,CAAC,EA9BW,SAAS,yBAAT,SAAS,QA8BpB;
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../src/prompts/prompt.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,8DAAuE;AACvE,wCAAwE;AACxE,sCAAkC;AAMlC,gEAAgF;AAEhF;;;GAGG;AACH,IAAY,SA8BX;AA9BD,WAAY,SAAS;IACnB;;SAEK;IACL,yCAAI,CAAA;IAEJ;;SAEK;IACL,yCAAI,CAAA;IAEJ;;SAEK;IACL,6CAAM,CAAA;IAEN;;SAEK;IACL,yCAAI,CAAA;IAEJ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E,SAAS,EAAE,OAAO,CAAC,CAAA;gBAC5E,MAAK;QACT,CAAC;QAED,mDAAmD;QACnD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/B,kEAAkE;YAClE,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAa,CAAA;YACvD,MAAM,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAA;YACtB,IACE,GAAG,CAAC,gBAAgB;gBACZ,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,OAAO,CAAC;gBAC3C,GAAG,CAAC,gBAAgB,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAC/C,CAAC;gBACD,MAAM,CAAC,gBAAgB,GAAG,GAAG,CAAC,gBAAgB,CAAA;YAChD,CAAC;YAED,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC;gBACpB,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;oBACvB,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;gBACjE,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,WAAW,GAAG,GAAG,CAAC,WAAW,CAAA;gBACtC,CAAC;YACH,CAAC;YAED,OAAO,MAAM,CAAA;QACf,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,SAAS,GAAG,4BAAU,CAAC,cAAc,CAAA;YAEzC,OAAO,GAAG,CAAA;QACZ,CAAC;IACH,CAAC;CACF;AAnRD,wBAmRC"}
|
|
@@ -1,45 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a culture-specific model that defines localization settings for prompts.
|
|
3
|
+
* This interface provides language-specific formatting rules and translations for
|
|
4
|
+
* interactive prompts such as choice lists and confirmation dialogs.
|
|
5
|
+
*/
|
|
1
6
|
export interface PromptCultureModel {
|
|
2
7
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
* The locale identifier for this culture model.
|
|
9
|
+
* This follows the standard IETF language tag format (e.g., "en-US", "fr-FR", "ja-JP").
|
|
10
|
+
* Used to identify the target language and region for localization.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* "en-US" // English (United States)
|
|
14
|
+
* @example
|
|
15
|
+
* "fr-FR" // French (France)
|
|
16
|
+
* @example
|
|
17
|
+
* "ja-JP" // Japanese (Japan)
|
|
18
|
+
*/
|
|
8
19
|
locale: string;
|
|
9
20
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
21
|
+
* The separator string used to delimit items in a list when presenting choices.
|
|
22
|
+
* This is typically used between items in the middle of a list, not before the final item.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ", " // English: "apple, banana, orange"
|
|
26
|
+
* @example
|
|
27
|
+
* "、 " // Japanese: "りんご、 バナナ、 オレンジ"
|
|
28
|
+
*/
|
|
15
29
|
separator: string;
|
|
16
30
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
31
|
+
* The conjunction string used before the final item in a two-item list.
|
|
32
|
+
* This is used when presenting exactly two choices to the user.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* " or " // English: "apple or banana"
|
|
36
|
+
* @example
|
|
37
|
+
* " ou " // French: "pomme ou banane"
|
|
38
|
+
* @example
|
|
39
|
+
* " または " // Japanese: "りんご または バナナ"
|
|
40
|
+
*/
|
|
22
41
|
inlineOr: string;
|
|
23
42
|
/**
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
43
|
+
* The conjunction string used before the final item in a list of three or more items.
|
|
44
|
+
* This combines with the separator to create properly formatted choice lists.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ", or " // English: "apple, banana, or orange"
|
|
48
|
+
* @example
|
|
49
|
+
* ", ou " // French: "pomme, banane, ou orange"
|
|
50
|
+
* @example
|
|
51
|
+
* "、 または " // Japanese: "りんご、 バナナ、 または オレンジ"
|
|
52
|
+
*/
|
|
29
53
|
inlineOrMore: string;
|
|
30
54
|
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
55
|
+
* The affirmative response word in the target language.
|
|
56
|
+
* Used in confirmation prompts and boolean choice scenarios.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* "Yes" // English
|
|
60
|
+
* @example
|
|
61
|
+
* "Oui" // French
|
|
62
|
+
* @example
|
|
63
|
+
* "はい" // Japanese
|
|
64
|
+
*/
|
|
36
65
|
yesInLanguage: string;
|
|
37
66
|
/**
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
67
|
+
* The negative response word in the target language.
|
|
68
|
+
* Used in confirmation prompts and boolean choice scenarios.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* "No" // English
|
|
72
|
+
* @example
|
|
73
|
+
* "Non" // French
|
|
74
|
+
* @example
|
|
75
|
+
* "いいえ" // Japanese
|
|
76
|
+
*/
|
|
43
77
|
noInLanguage: string;
|
|
44
78
|
}
|
|
45
79
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promptCultureModels.js","sourceRoot":"","sources":["../../../src/prompts/promptCultureModels.ts"],"names":[],"mappings":";;;AAAA,8EAA2D;
|
|
1
|
+
{"version":3,"file":"promptCultureModels.js","sourceRoot":"","sources":["../../../src/prompts/promptCultureModels.ts"],"names":[],"mappings":";;;AAAA,8EAA2D;AAsF3D;;GAEG;AACH,MAAa,mBAAmB;IA6G9B;;;;;SAKK;IACG,MAAM,CAAC,wBAAwB;QACrC,OAAO,IAAI,CAAC,oBAAoB,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAU,EAAE,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B,YAAY,EAAE,IAAI;CACnB,CAAA;AAuCD;;;;KAIK;AACE,wCAAoB,GAAG,GAAyB,EAAE,CAAC;IACxD,mBAAmB,CAAC,OAAO;IAC3B,mBAAmB,CAAC,KAAK;IACzB,mBAAmB,CAAC,OAAO;IAC3B,mBAAmB,CAAC,MAAM;IAC1B,mBAAmB,CAAC,MAAM;IAC1B,mBAAmB,CAAC,OAAO;IAC3B,mBAAmB,CAAC,QAAQ;IAC5B,mBAAmB,CAAC,UAAU;IAC9B,mBAAmB,CAAC,OAAO;CAC5B,CAAA"}
|
package/dist/src/recognizer.d.ts
CHANGED
|
@@ -6,12 +6,29 @@ import { Activity } from '@microsoft/agents-activity';
|
|
|
6
6
|
import { Configurable } from './configurable';
|
|
7
7
|
import { DialogContext } from './dialogContext';
|
|
8
8
|
import { RecognizerResult } from './recognizerResult';
|
|
9
|
+
/**
|
|
10
|
+
* Configuration options for a recognizer instance.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* This interface defines the configuration properties that can be used to customize
|
|
14
|
+
* the behavior and identification of a recognizer. Recognizers use this configuration
|
|
15
|
+
* to set up their basic properties and operational parameters.
|
|
16
|
+
*/
|
|
9
17
|
export interface RecognizerConfiguration {
|
|
18
|
+
/**
|
|
19
|
+
* Optional unique identifier for the recognizer instance.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* The id property allows you to distinguish between multiple recognizer instances
|
|
23
|
+
* and can be useful for logging, debugging, and telemetry purposes. If not provided,
|
|
24
|
+
* the recognizer will operate without a specific identifier.
|
|
25
|
+
*/
|
|
10
26
|
id?: string;
|
|
11
27
|
}
|
|
12
28
|
/**
|
|
13
29
|
* Base class for implementing custom recognizers to identify intents and entities from user input.
|
|
14
30
|
*
|
|
31
|
+
* @remarks
|
|
15
32
|
* Recognizers process user input, such as text or speech, and return structured data representing
|
|
16
33
|
* the recognized intents, entities, and other relevant information. This class provides a foundation
|
|
17
34
|
* for creating custom recognizers by defining common methods and properties.
|
package/dist/src/recognizer.js
CHANGED
|
@@ -10,6 +10,7 @@ const recognizerResult_1 = require("./recognizerResult");
|
|
|
10
10
|
/**
|
|
11
11
|
* Base class for implementing custom recognizers to identify intents and entities from user input.
|
|
12
12
|
*
|
|
13
|
+
* @remarks
|
|
13
14
|
* Recognizers process user input, such as text or speech, and return structured data representing
|
|
14
15
|
* the recognized intents, entities, and other relevant information. This class provides a foundation
|
|
15
16
|
* for creating custom recognizers by defining common methods and properties.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recognizer.js","sourceRoot":"","sources":["../../src/recognizer.ts"],"names":[],"mappings":";;;;;;AAKA,iDAA6C;AAE7C,uDAA8B;AAC9B,yDAA0E;
|
|
1
|
+
{"version":3,"file":"recognizer.js","sourceRoot":"","sources":["../../src/recognizer.ts"],"names":[],"mappings":";;;;;;AAKA,iDAA6C;AAE7C,uDAA8B;AAC9B,yDAA0E;AAsB1E;;;;;;;GAOG;AACH,MAAa,UAAW,SAAQ,2BAAY;IAK1C;;;;;;;SAOK;IACL,SAAS,CACP,cAA6B,EAC7B,SAA4B,EAC5B,oBAA6C,EAC7C,iBAA0C;QAE1C,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAA;IACzD,CAAC;IAED;;;;;SAKK;IACK,wBAAwB,CAAE,iBAAmD;QACrF,IAAI,IAAI,GAAW,EAAE,CAAA;QACrB,IAAI,SAAS,GAAwB,EAAE,CAAA;QAEnC,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC,UAA2B,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,EAAE;YACzG,IAAI,GAAG,MAAM,CAAC,IAAI,CAAA;YAClB,SAAS,GAAG,MAAM,CAAC,SAAS,CAAA;YAC5B,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,sCAAmB,EAAC,MAAM,CAAC,CAAA;YACrD,IAAI,M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ognizerResult {
|
|
|
28
28
|
*/
|
|
29
29
|
[propName: string]: any;
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Finds the intent with the highest confidence score from a recognizer result.
|
|
33
|
+
*
|
|
34
|
+
* This function iterates through all intents in the recognizer result and returns
|
|
35
|
+
* the intent name and score for the intent with the highest confidence score.
|
|
36
|
+
* If multiple intents have the same highest score, the last one encountered is returned.
|
|
37
|
+
*
|
|
38
|
+
* @param result - The recognizer result containing intents and their scores
|
|
39
|
+
* @returns An object containing the top-scoring intent name and its confidence score
|
|
40
|
+
* @throws {Error} Throws an error if the result is empty or doesn't contain intents
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const result: RecognizerResult = {
|
|
45
|
+
* text: "Book a flight to Seattle",
|
|
46
|
+
* intents: {
|
|
47
|
+
* "BookFlight": { score: 0.95 },
|
|
48
|
+
* "Cancel": { score: 0.02 },
|
|
49
|
+
* "Help": { score: 0.03 }
|
|
50
|
+
* }
|
|
51
|
+
* };
|
|
52
|
+
*
|
|
53
|
+
* const topIntent = getTopScoringIntent(result);
|
|
54
|
+
* // Returns: { intent: "BookFlight", score: 0.95 }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
31
57
|
export declare const getTopScoringIntent: (result: RecognizerResult) => {
|
|
32
58
|
intent: string;
|
|
33
59
|
score: number;
|
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getTopScoringIntent = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Finds the intent with the highest confidence score from a recognizer result.
|
|
6
|
+
*
|
|
7
|
+
* This function iterates through all intents in the recognizer result and returns
|
|
8
|
+
* the intent name and score for the intent with the highest confidence score.
|
|
9
|
+
* If multiple intents have the same highest score, the last one encountered is returned.
|
|
10
|
+
*
|
|
11
|
+
* @param result - The recognizer result containing intents and their scores
|
|
12
|
+
* @returns An object containing the top-scoring intent name and its confidence score
|
|
13
|
+
* @throws {Error} Throws an error if the result is empty or doesn't contain intents
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const result: RecognizerResult = {
|
|
18
|
+
* text: "Book a flight to Seattle",
|
|
19
|
+
* intents: {
|
|
20
|
+
* "BookFlight": { score: 0.95 },
|
|
21
|
+
* "Cancel": { score: 0.02 },
|
|
22
|
+
* "Help": { score: 0.03 }
|
|
23
|
+
* }
|
|
24
|
+
* };
|
|
25
|
+
*
|
|
26
|
+
* const topIntent = getTopScoringIntent(result);
|
|
27
|
+
* // Returns: { intent: "BookFlight", score: 0.95 }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
4
30
|
const getTopScoringIntent = (result) => {
|
|
5
31
|
var _a;
|
|
6
32
|
if (!result || !result.intents) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recognizerResult.js","sourceRoot":"","sources":["../../src/recognizerResult.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"recognizerResult.js","sourceRoot":"","sources":["../../src/recognizerResult.ts"],"names":[],"mappings":";;;AAoCA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACI,MAAM,mBAAmB,GAAG,CAAC,MAAwB,EAAqC,EAAE;;IACjG,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAA;IACpC,CAAC;IAED,IAAI,SAAS,GAAG,EAAE,CAAA;IAClB,IAAI,QAAQ,GAAG,CAAC,CAAC,CAAA;IACjB,KAAK,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;QAClE,MAAM,KAAK,GAAG,MAAA,MAAM,CAAC,KAAK,mCAAI,CAAC,CAAC,CAAA;QAChC,IAAI,CAAC,SAAS,IAAI,KAAK,GAAG,QAAQ,EAAE,CAAC;YACnC,SAAS,GAAG,UAAU,CAAA;YACtB,QAAQ,GAAG,KAAK,CAAA;QAClB,CAAC;IACH,CAAC;IAED,OAAO;QACL,MAAM,EAAE,SAAS;QACjB,KAAK,EAAE,QAAQ;KAChB,CAAA;AACH,CAAC,CAAA;AAnBY,QAAA,mBAAmB,uBAmB/B"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@microsoft/agents-hosting-dialogs",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.11",
|
|
5
5
|
"homepage": "https://github.com/microsoft/Agents-for-js",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"main": "dist/index.js",
|
|
17
17
|
"types": "dist/src/index.d.ts",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@microsoft/agents-hosting": "0.6.
|
|
19
|
+
"@microsoft/agents-hosting": "0.6.11",
|
|
20
20
|
"@types/lodash": "^4.17.16",
|
|
21
21
|
"dependency-graph": "^1.0.0",
|
|
22
22
|
"@microsoft/recognizers-text-suite": "^1.3.1",
|
|
@@ -29,10 +29,38 @@ export interface FindChoicesOptions extends FindValuesOptions {
|
|
|
29
29
|
recognizeOrdinals?: boolean;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Represents a choice that was found and matched within a user's utterance.
|
|
34
|
+
* This interface contains information about the matched choice, including its
|
|
35
|
+
* original value, position in the choices list, confidence score, and the
|
|
36
|
+
* specific text that triggered the match.
|
|
37
|
+
*/
|
|
32
38
|
export interface FoundChoice {
|
|
39
|
+
/**
|
|
40
|
+
* The original value of the choice that was matched. This is the canonical
|
|
41
|
+
* value from the choice list, not the text that was actually found in the utterance.
|
|
42
|
+
*/
|
|
33
43
|
value: string;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The zero-based index of this choice in the original choices array that was
|
|
47
|
+
* passed to the findChoices function. This allows you to map back to the
|
|
48
|
+
* original choice object if needed.
|
|
49
|
+
*/
|
|
34
50
|
index: number;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A confidence score between 0.0 and 1.0 indicating how well the found text
|
|
54
|
+
* matches the choice. Higher scores indicate better matches, with 1.0 being
|
|
55
|
+
* a perfect match.
|
|
56
|
+
*/
|
|
35
57
|
score: number;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The specific text or synonym that was actually matched in the user's utterance.
|
|
61
|
+
* This may be different from the choice's value if the match was made against
|
|
62
|
+
* a synonym, action title, or alternative representation of the choice.
|
|
63
|
+
*/
|
|
36
64
|
synonym?: string;
|
|
37
65
|
}
|
|
38
66
|
|
|
@@ -30,41 +30,96 @@ export interface FindValuesOptions {
|
|
|
30
30
|
tokenizer?: TokenizerFunction;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Represents a value that was successfully found and matched during a search operation.
|
|
35
|
+
* This interface contains the matched value along with metadata about the match quality
|
|
36
|
+
* and its position in the original search list.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* // Example of a FoundValue result from searching for "red" in ["red", "green", "blue"]
|
|
41
|
+
* const foundValue: FoundValue = {
|
|
42
|
+
* value: "red",
|
|
43
|
+
* index: 0,
|
|
44
|
+
* score: 1.0
|
|
45
|
+
* };
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
33
48
|
export interface FoundValue {
|
|
34
49
|
/**
|
|
35
|
-
* The value that was
|
|
50
|
+
* The exact value that was matched from the original search list.
|
|
51
|
+
* This is the original string value, not the user's input that matched it.
|
|
52
|
+
*
|
|
53
|
+
* @example "red" (when user typed "rd" and it matched "red")
|
|
36
54
|
*/
|
|
37
55
|
value: string;
|
|
38
56
|
|
|
39
57
|
/**
|
|
40
|
-
* The index of
|
|
58
|
+
* The zero-based index position of this value in the original list that was searched.
|
|
59
|
+
* This allows you to correlate the found value back to its position in the source array.
|
|
60
|
+
*
|
|
61
|
+
* @example 0 (if "red" was the first item in the original choices array)
|
|
41
62
|
*/
|
|
42
63
|
index: number;
|
|
43
64
|
|
|
44
65
|
/**
|
|
45
|
-
*
|
|
66
|
+
* A confidence score between 0 and 1 indicating the quality of the match.
|
|
67
|
+
* - 1.0 indicates a perfect exact match
|
|
68
|
+
* - Lower values indicate partial or fuzzy matches
|
|
69
|
+
* - Calculated based on completeness (how much of the value matched) and accuracy (token distance)
|
|
70
|
+
*
|
|
71
|
+
* @example 1.0 for exact matches, 0.8 for close partial matches, 0.3 for distant fuzzy matches
|
|
46
72
|
*/
|
|
47
73
|
score: number;
|
|
48
74
|
}
|
|
49
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Represents a value with its original position that can be used in search operations.
|
|
78
|
+
* This interface is used internally by the search algorithm to maintain the relationship
|
|
79
|
+
* between search values and their original positions in the source array.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* // Example of SortedValue objects created from a choices array
|
|
84
|
+
* const choices = ["red", "green", "blue"];
|
|
85
|
+
* const sortedValues: SortedValue[] = choices.map((value, index) => ({
|
|
86
|
+
* value,
|
|
87
|
+
* index
|
|
88
|
+
* }));
|
|
89
|
+
* // Results in:
|
|
90
|
+
* // [
|
|
91
|
+
* // { value: "red", index: 0 },
|
|
92
|
+
* // { value: "green", index: 1 },
|
|
93
|
+
* // { value: "blue", index: 2 }
|
|
94
|
+
* // ]
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
50
97
|
export interface SortedValue {
|
|
51
98
|
/**
|
|
52
|
-
* The value to be searched for.
|
|
99
|
+
* The string value to be searched for during matching operations.
|
|
100
|
+
* This is the actual text content that will be compared against user input.
|
|
101
|
+
*
|
|
102
|
+
* @example "red", "green", "blue" when searching color choices
|
|
53
103
|
*/
|
|
54
104
|
value: string;
|
|
55
105
|
|
|
56
106
|
/**
|
|
57
|
-
* The index of
|
|
107
|
+
* The zero-based index position of this value in the original source array.
|
|
108
|
+
* This allows the search algorithm to correlate found matches back to their
|
|
109
|
+
* original positions, which is essential for maintaining proper choice selection.
|
|
110
|
+
*
|
|
111
|
+
* @example 0 for the first item, 1 for the second item, etc.
|
|
58
112
|
*/
|
|
59
113
|
index: number;
|
|
60
114
|
}
|
|
61
115
|
|
|
62
116
|
/**
|
|
63
|
-
*
|
|
117
|
+
* Low-level function that searches for a set of values within an utterance. Higher level
|
|
64
118
|
* functions like `findChoices()` and `recognizeChoices()` are layered above this function. In most
|
|
65
119
|
* cases its easier to just call one of the higher level functions instead but this function contains
|
|
66
120
|
* the fuzzy search algorithm that drives choice recognition.
|
|
67
121
|
*
|
|
122
|
+
* @internal
|
|
68
123
|
* @param utterance The text or user utterance to search over.
|
|
69
124
|
* @param values List of values to search over.
|
|
70
125
|
* @param options (Optional) options used to tweak the search that's performed.
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { findChoices, FindChoicesOptions, FoundChoice } from './findChoices'
|
|
6
6
|
import { ModelResult } from './modelResult'
|
|
7
7
|
import { Choice } from './choice'
|
|
8
|
-
import { debug } from '@microsoft/agents-
|
|
8
|
+
import { debug } from '@microsoft/agents-activity/src/logger'
|
|
9
9
|
|
|
10
10
|
const logger = debug('dialogs:recognizeChoices')
|
|
11
11
|
|
package/src/dialogEvent.ts
CHANGED
|
@@ -3,24 +3,30 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export interface DialogEvent {
|
|
5
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
* Flag indicating whether the event will be bubbled to the parent `DialogContext`.
|
|
7
|
+
*/
|
|
8
8
|
bubble: boolean;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
* Name of the event being raised.
|
|
12
|
+
*/
|
|
13
13
|
name: string;
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
* Optional. Value associated with the event.
|
|
17
|
+
*/
|
|
18
18
|
value?: any;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Configuration options for dialog initialization and behavior.
|
|
23
|
+
* This interface defines the settings that can be applied when creating or configuring a dialog instance.
|
|
24
|
+
*/
|
|
21
25
|
export interface DialogConfiguration {
|
|
22
26
|
/**
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
* Optional static identifier for the dialog.
|
|
28
|
+
* When provided, this unique identifier can be used to reference and manage the dialog instance
|
|
29
|
+
* throughout its lifecycle. If not specified, the dialog will operate without a persistent identifier.
|
|
30
|
+
*/
|
|
25
31
|
id?: string;
|
|
26
32
|
}
|
package/src/dialogManager.ts
CHANGED
|
@@ -25,15 +25,53 @@ const LAST_ACCESS = '_lastAccess'
|
|
|
25
25
|
const CONVERSATION_STATE = 'ConversationState'
|
|
26
26
|
const USER_STATE = 'UserState'
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Result returned by the DialogManager after processing a conversation turn.
|
|
30
|
+
* Contains the outcome of dialog execution and any state changes that occurred during the turn.
|
|
31
|
+
*/
|
|
28
32
|
export interface DialogManagerResult {
|
|
33
|
+
/**
|
|
34
|
+
* The result of executing the dialog during this conversation turn.
|
|
35
|
+
* Contains information about the dialog's completion state, any returned values,
|
|
36
|
+
* and whether the dialog is waiting for additional input from the user.
|
|
37
|
+
*/
|
|
29
38
|
turnResult: DialogTurnResult;
|
|
30
39
|
}
|
|
31
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Configuration interface for DialogManager instances.
|
|
43
|
+
* Defines the required and optional settings needed to initialize and configure a dialog manager.
|
|
44
|
+
*/
|
|
32
45
|
export interface DialogManagerConfiguration {
|
|
46
|
+
/**
|
|
47
|
+
* The conversation state storage for maintaining dialog state across turns.
|
|
48
|
+
* This is required and manages the dialog stack and conversation-scoped data.
|
|
49
|
+
*/
|
|
33
50
|
conversationState: AgentState;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The root dialog that will be started when the dialog manager begins execution.
|
|
54
|
+
* This dialog serves as the entry point for the conversation flow.
|
|
55
|
+
*/
|
|
34
56
|
rootDialog: Dialog;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Optional user state storage for maintaining user-scoped data across conversations.
|
|
60
|
+
* When provided, enables persistence of user-specific information beyond individual conversations.
|
|
61
|
+
*/
|
|
35
62
|
userState?: UserState;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Optional timeout duration in milliseconds after which inactive conversations expire.
|
|
66
|
+
* When set, conversations that haven't been accessed within this timeframe will have their state cleared.
|
|
67
|
+
* If not specified, conversations will not automatically expire.
|
|
68
|
+
*/
|
|
36
69
|
expireAfter?: number;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Optional configuration for the dialog state manager.
|
|
73
|
+
* Provides advanced settings for how dialog state is managed and persisted.
|
|
74
|
+
*/
|
|
37
75
|
stateConfiguration?: DialogStateManagerConfiguration;
|
|
38
76
|
}
|
|
39
77
|
|
package/src/dialogSet.ts
CHANGED
|
@@ -11,10 +11,47 @@ import { Dialog } from './dialog'
|
|
|
11
11
|
import { DialogContext, DialogState } from './dialogContext'
|
|
12
12
|
import { StringUtils } from './stringUtils'
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Interface for dialogs that have child dialog dependencies.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* Implement this interface on dialog classes that need to register child dialogs
|
|
19
|
+
* with their parent dialog set. When a dialog implementing this interface is added
|
|
20
|
+
* to a DialogSet, the DialogSet will automatically call getDependencies() and add
|
|
21
|
+
* all returned child dialogs to itself, ensuring proper dialog registration and
|
|
22
|
+
* avoiding runtime errors when the dialog tries to call child dialogs.
|
|
23
|
+
*
|
|
24
|
+
* This is particularly useful for complex dialogs that compose multiple sub-dialogs
|
|
25
|
+
* or for dialog libraries that need to ensure their dependencies are available.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* class MyComplexDialog extends Dialog implements DialogDependencies {
|
|
30
|
+
* private textPrompt = new TextPrompt('textPrompt');
|
|
31
|
+
* private confirmPrompt = new ConfirmPrompt('confirmPrompt');
|
|
32
|
+
*
|
|
33
|
+
* getDependencies(): Dialog[] {
|
|
34
|
+
* return [this.textPrompt, this.confirmPrompt];
|
|
35
|
+
* }
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
14
39
|
export interface DialogDependencies {
|
|
15
40
|
/**
|
|
16
|
-
|
|
17
|
-
|
|
41
|
+
* Returns an array of child dialogs that this dialog depends on.
|
|
42
|
+
*
|
|
43
|
+
* @returns An array of Dialog instances that should be added to the parent DialogSet.
|
|
44
|
+
*
|
|
45
|
+
* @remarks
|
|
46
|
+
* This method is called automatically by DialogSet.add() when a dialog implementing
|
|
47
|
+
* this interface is added to the set. All returned dialogs will be recursively
|
|
48
|
+
* added to the same DialogSet, ensuring they are available when needed during
|
|
49
|
+
* dialog execution.
|
|
50
|
+
*
|
|
51
|
+
* The returned dialogs should be the actual Dialog instances that will be called
|
|
52
|
+
* by this dialog, not new instances. This ensures proper dialog lifecycle management
|
|
53
|
+
* and state consistency.
|
|
54
|
+
*/
|
|
18
55
|
getDependencies(): Dialog[];
|
|
19
56
|
}
|
|
20
57
|
|