1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const tslib_1 = require("tslib");
|
4 | const CLRunner_1 = require("./CLRunner");
|
5 | const CLMemory_1 = require("./CLMemory");
|
6 | const CLDebug_1 = require("./CLDebug");
|
7 | const CLClient_1 = require("./CLClient");
|
8 | const router_1 = require("./http/router");
|
9 | const Utils_1 = require("./Utils");
|
10 | class ConversationLearner {
|
11 | constructor(modelId, maxTimeout) {
|
12 | if (!ConversationLearner.options) {
|
13 | throw new Error("Init() must be called on ConversationLearner before instances are created");
|
14 | }
|
15 | if (typeof maxTimeout !== 'number') {
|
16 | maxTimeout = Utils_1.DEFAULT_MAX_SESSION_LENGTH;
|
17 | }
|
18 | this.clRunner = CLRunner_1.CLRunner.Create(modelId, maxTimeout, ConversationLearner.clClient);
|
19 | }
|
20 | static Init(options, storage = null) {
|
21 | ConversationLearner.options = options;
|
22 | try {
|
23 | this.clClient = new CLClient_1.CLClient(options);
|
24 | CLMemory_1.CLMemory.Init(storage);
|
25 | }
|
26 | catch (error) {
|
27 | CLDebug_1.CLDebug.Error(error, 'Conversation Learner Initialization');
|
28 | }
|
29 | return router_1.default(this.clClient, options);
|
30 | }
|
31 | recognize(turnContext, force) {
|
32 | return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
33 | return yield this.clRunner.recognize(turnContext, force);
|
34 | });
|
35 | }
|
36 | |
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 | StartSession(turnContext) {
|
43 | return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
44 | yield this.clRunner.BotStartSession(turnContext);
|
45 | });
|
46 | }
|
47 | |
48 |
|
49 |
|
50 |
|
51 | OnSessionStartCallback(target) {
|
52 | this.clRunner.onSessionStartCallback = target;
|
53 | }
|
54 | |
55 |
|
56 |
|
57 |
|
58 |
|
59 | OnSessionEndCallback(target) {
|
60 | this.clRunner.onSessionEndCallback = target;
|
61 | }
|
62 | SendResult(result) {
|
63 | return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
64 | yield this.clRunner.SendIntent(result);
|
65 | });
|
66 | }
|
67 | |
68 |
|
69 |
|
70 | InTrainingUI(turnContext) {
|
71 | return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
72 |
|
73 | return yield this.clRunner.InTrainingUI(turnContext);
|
74 | });
|
75 | }
|
76 | |
77 |
|
78 |
|
79 |
|
80 | AddCallback(callback) {
|
81 | this.clRunner.AddCallback(callback);
|
82 | }
|
83 | |
84 |
|
85 |
|
86 | EntityDetectionCallback(target) {
|
87 | this.clRunner.entityDetectionCallback = target;
|
88 | }
|
89 | }
|
90 | ConversationLearner.options = null;
|
91 | exports.ConversationLearner = ConversationLearner;
|
92 |
|
\ | No newline at end of file |