@botonic/plugin-flow-builder 0.37.1 → 0.37.2-alpha.0
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/lib/cjs/action/ai-agent.js +9 -4
- package/lib/cjs/action/ai-agent.js.map +1 -1
- package/lib/cjs/action/fallback.js +6 -2
- package/lib/cjs/action/fallback.js.map +1 -1
- package/lib/cjs/action/knowledge-bases.js +31 -29
- package/lib/cjs/action/knowledge-bases.js.map +1 -1
- package/lib/cjs/action/payload.js +2 -2
- package/lib/cjs/action/payload.js.map +1 -1
- package/lib/cjs/content-fields/flow-ai-agent.d.ts +3 -2
- package/lib/cjs/content-fields/flow-ai-agent.js +3 -1
- package/lib/cjs/content-fields/flow-ai-agent.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/ai-agent.d.ts +6 -0
- package/lib/cjs/tracking.d.ts +1 -12
- package/lib/cjs/tracking.js +15 -31
- package/lib/cjs/tracking.js.map +1 -1
- package/lib/cjs/types.d.ts +8 -44
- package/lib/cjs/types.js.map +1 -1
- package/lib/cjs/user-input/keyword.js +7 -5
- package/lib/cjs/user-input/keyword.js.map +1 -1
- package/lib/cjs/user-input/smart-intent.js +5 -2
- package/lib/cjs/user-input/smart-intent.js.map +1 -1
- package/lib/esm/action/ai-agent.js +9 -4
- package/lib/esm/action/ai-agent.js.map +1 -1
- package/lib/esm/action/fallback.js +8 -4
- package/lib/esm/action/fallback.js.map +1 -1
- package/lib/esm/action/knowledge-bases.js +33 -31
- package/lib/esm/action/knowledge-bases.js.map +1 -1
- package/lib/esm/action/payload.js +2 -2
- package/lib/esm/action/payload.js.map +1 -1
- package/lib/esm/content-fields/flow-ai-agent.d.ts +3 -2
- package/lib/esm/content-fields/flow-ai-agent.js +3 -1
- package/lib/esm/content-fields/flow-ai-agent.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/ai-agent.d.ts +6 -0
- package/lib/esm/tracking.d.ts +1 -12
- package/lib/esm/tracking.js +15 -31
- package/lib/esm/tracking.js.map +1 -1
- package/lib/esm/types.d.ts +8 -44
- package/lib/esm/types.js.map +1 -1
- package/lib/esm/user-input/keyword.js +10 -8
- package/lib/esm/user-input/keyword.js.map +1 -1
- package/lib/esm/user-input/smart-intent.js +8 -5
- package/lib/esm/user-input/smart-intent.js.map +1 -1
- package/package.json +2 -2
- package/src/action/ai-agent.ts +12 -2
- package/src/action/fallback.ts +9 -4
- package/src/action/knowledge-bases.ts +47 -43
- package/src/action/payload.ts +3 -3
- package/src/content-fields/flow-ai-agent.tsx +6 -4
- package/src/content-fields/hubtype-fields/ai-agent.ts +7 -0
- package/src/tracking.ts +14 -35
- package/src/types.ts +19 -52
- package/src/user-input/keyword.ts +11 -9
- package/src/user-input/smart-intent.ts +9 -5
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
|
-
import { EventAction
|
|
1
|
+
import { __awaiter, __rest } from "tslib";
|
|
2
|
+
import { EventAction } from '@botonic/core';
|
|
3
|
+
import { trackEvent } from '../tracking';
|
|
3
4
|
export function getContentsByFallback({ cmsApi, flowBuilderPlugin, request, }) {
|
|
4
5
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5
6
|
const fallbackNode = yield getFallbackNode(cmsApi, request);
|
|
@@ -16,11 +17,14 @@ function getFallbackNode(cmsApi, request) {
|
|
|
16
17
|
const isFirstFallbackOption = !!request.session.user.extra_data.isFirstFallbackOption;
|
|
17
18
|
const fallbackNode = cmsApi.getFallbackNode(isFirstFallbackOption);
|
|
18
19
|
request.session.user.extra_data.isFirstFallbackOption = !isFirstFallbackOption;
|
|
19
|
-
|
|
20
|
+
const event = {
|
|
21
|
+
action: EventAction.Fallback,
|
|
20
22
|
userInput: request.input.data,
|
|
21
23
|
fallbackOut: isFirstFallbackOption ? 1 : 2,
|
|
22
24
|
fallbackMessageId: request.input.message_id,
|
|
23
|
-
}
|
|
25
|
+
};
|
|
26
|
+
const { action } = event, eventArgs = __rest(event, ["action"]);
|
|
27
|
+
yield trackEvent(request, action, eventArgs);
|
|
24
28
|
return fallbackNode;
|
|
25
29
|
});
|
|
26
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fallback.js","sourceRoot":"","sources":["../../../src/action/fallback.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"fallback.js","sourceRoot":"","sources":["../../../src/action/fallback.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAiB,MAAM,eAAe,CAAA;AAK1D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGxC,MAAM,UAAgB,qBAAqB,CAAC,EAC1C,MAAM,EACN,iBAAiB,EACjB,OAAO,GACY;;QACnB,MAAM,YAAY,GAAG,MAAM,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QAC3D,MAAM,gBAAgB,GACpB,MAAM,iBAAiB,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAA;QAEzD,OAAO,gBAAgB,CAAA;IACzB,CAAC;CAAA;AAED,SAAe,eAAe,CAAC,MAAsB,EAAE,OAAsB;;;QAC3E,IAAI,CAAA,MAAA,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,0CAAE,qBAAqB,MAAK,SAAS,EAAE;YACxE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,mCAC1B,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,KAClC,qBAAqB,EAAE,IAAI,GAC5B,CAAA;SACF;QAED,MAAM,qBAAqB,GACzB,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,qBAAqB,CAAA;QACzD,MAAM,YAAY,GAAG,MAAM,CAAC,eAAe,CAAC,qBAAqB,CAAC,CAAA;QAClE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,qBAAqB,GAAG,CAAC,qBAAqB,CAAA;QAE9E,MAAM,KAAK,GAAkB;YAC3B,MAAM,EAAE,WAAW,CAAC,QAAQ;YAC5B,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,IAAc;YACvC,WAAW,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1C,iBAAiB,EAAE,OAAO,CAAC,KAAK,CAAC,UAAU;SAC5C,CAAA;QACD,MAAM,EAAE,MAAM,KAAmB,KAAK,EAAnB,SAAS,UAAK,KAAK,EAAhC,UAAwB,CAAQ,CAAA;QAEtC,MAAM,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAAA;QAE5C,OAAO,YAAY,CAAA;;CACpB"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
1
|
+
import { __awaiter, __rest } from "tslib";
|
|
2
|
+
import { EventAction, KnowledgebaseFailReason, } from '@botonic/core';
|
|
2
3
|
import { DISABLED_MEMORY_LENGTH, FlowKnowledgeBase, } from '../content-fields';
|
|
3
|
-
import {
|
|
4
|
+
import { getFlowBuilderPlugin } from '../helpers';
|
|
5
|
+
import { trackEvent } from '../tracking';
|
|
4
6
|
import { inputHasTextData, isKnowledgeBasesAllowed } from '../utils';
|
|
5
7
|
export function getContentsByKnowledgeBase({ cmsApi, flowBuilderPlugin, request, }) {
|
|
6
8
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -16,11 +18,10 @@ export function getContentsByKnowledgeBase({ cmsApi, flowBuilderPlugin, request,
|
|
|
16
18
|
return contents;
|
|
17
19
|
}
|
|
18
20
|
const sourceIds = knowledgeBaseContent.sourcesData.map(source => source.id);
|
|
19
|
-
const flowId = cmsApi.getNodeById(knowledgeBaseContent.id).flow_id;
|
|
20
21
|
if (flowBuilderPlugin.getKnowledgeBaseResponse &&
|
|
21
22
|
inputHasTextData(request.input) &&
|
|
22
23
|
sourceIds.length > 0) {
|
|
23
|
-
const contentsWithKnowledgeResponse = yield getContentsWithKnowledgeResponse(flowBuilderPlugin.getKnowledgeBaseResponse, request, contents, knowledgeBaseContent
|
|
24
|
+
const contentsWithKnowledgeResponse = yield getContentsWithKnowledgeResponse(flowBuilderPlugin.getKnowledgeBaseResponse, request, contents, knowledgeBaseContent);
|
|
24
25
|
if (contentsWithKnowledgeResponse) {
|
|
25
26
|
return contentsWithKnowledgeResponse;
|
|
26
27
|
}
|
|
@@ -29,7 +30,7 @@ export function getContentsByKnowledgeBase({ cmsApi, flowBuilderPlugin, request,
|
|
|
29
30
|
return [];
|
|
30
31
|
});
|
|
31
32
|
}
|
|
32
|
-
function getContentsWithKnowledgeResponse(getKnowledgeBaseResponse, request, contents, knowledgeBaseContent
|
|
33
|
+
function getContentsWithKnowledgeResponse(getKnowledgeBaseResponse, request, contents, knowledgeBaseContent) {
|
|
33
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
35
|
const sourceIds = knowledgeBaseContent.sourcesData.map(source => source.id);
|
|
35
36
|
const instructions = knowledgeBaseContent.instructions;
|
|
@@ -38,7 +39,7 @@ function getContentsWithKnowledgeResponse(getKnowledgeBaseResponse, request, con
|
|
|
38
39
|
? knowledgeBaseContent.memoryLength
|
|
39
40
|
: DISABLED_MEMORY_LENGTH;
|
|
40
41
|
const knowledgeBaseResponse = yield getKnowledgeBaseResponse(request, sourceIds, instructions, messageId, memoryLength);
|
|
41
|
-
yield trackKnowledgeBase(knowledgeBaseResponse, request, knowledgeBaseContent
|
|
42
|
+
yield trackKnowledgeBase(knowledgeBaseResponse, request, knowledgeBaseContent);
|
|
42
43
|
if (!knowledgeBaseResponse.hasKnowledge ||
|
|
43
44
|
!knowledgeBaseResponse.isFaithful) {
|
|
44
45
|
return undefined;
|
|
@@ -55,33 +56,34 @@ function updateContentsWithResponse(contents, response) {
|
|
|
55
56
|
return content;
|
|
56
57
|
});
|
|
57
58
|
}
|
|
58
|
-
function trackKnowledgeBase(response, request, knowledgeBaseContent
|
|
59
|
+
function trackKnowledgeBase(response, request, knowledgeBaseContent) {
|
|
59
60
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
knowledgebaseMessageId,
|
|
61
|
+
const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins);
|
|
62
|
+
const flowId = flowBuilderPlugin.cmsApi.getNodeById(knowledgeBaseContent.id).flow_id;
|
|
63
|
+
const getKnowledgeFailReason = () => {
|
|
64
|
+
let knowledgebaseFailReason;
|
|
65
|
+
if (!response.isFaithful) {
|
|
66
|
+
knowledgebaseFailReason = KnowledgebaseFailReason.Hallucination;
|
|
67
|
+
}
|
|
68
|
+
if (!response.hasKnowledge) {
|
|
69
|
+
knowledgebaseFailReason = KnowledgebaseFailReason.NoKnowledge;
|
|
70
|
+
}
|
|
71
|
+
return knowledgebaseFailReason;
|
|
72
|
+
};
|
|
73
|
+
const event = {
|
|
74
|
+
action: EventAction.Knowledgebase,
|
|
75
|
+
knowledgebaseInferenceId: response.inferenceId,
|
|
76
|
+
knowledgebaseFailReason: getKnowledgeFailReason(),
|
|
77
|
+
knowledgebaseSourcesIds: knowledgeBaseContent.sourcesData.map(source => source.id),
|
|
78
|
+
knowledgebaseChunksIds: response.chunkIds,
|
|
79
|
+
knowledgebaseMessageId: request.input.message_id,
|
|
80
80
|
userInput: request.input.data,
|
|
81
|
-
flowThreadId,
|
|
82
|
-
flowId,
|
|
83
|
-
flowNodeId,
|
|
84
|
-
}
|
|
81
|
+
flowThreadId: request.session.flow_thread_id,
|
|
82
|
+
flowId: flowId,
|
|
83
|
+
flowNodeId: knowledgeBaseContent.id,
|
|
84
|
+
};
|
|
85
|
+
const { action } = event, eventArgs = __rest(event, ["action"]);
|
|
86
|
+
yield trackEvent(request, action, eventArgs);
|
|
85
87
|
});
|
|
86
88
|
}
|
|
87
89
|
//# sourceMappingURL=knowledge-bases.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knowledge-bases.js","sourceRoot":"","sources":["../../../src/action/knowledge-bases.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"knowledge-bases.js","sourceRoot":"","sources":["../../../src/action/knowledge-bases.ts"],"names":[],"mappings":";AAAA,OAAO,EAEL,WAAW,EAEX,uBAAuB,GAGxB,MAAM,eAAe,CAAA;AAEtB,OAAO,EACL,sBAAsB,EAEtB,iBAAiB,GAClB,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAGpE,MAAM,UAAgB,0BAA0B,CAAC,EAC/C,MAAM,EACN,iBAAiB,EACjB,OAAO,GACY;;QACnB,IAAI,uBAAuB,CAAC,OAAO,CAAC,EAAE;YACpC,MAAM,0BAA0B,GAAG,MAAM,CAAC,6BAA6B,EAAE,CAAA;YACzE,MAAM,sBAAsB,GAAG,MAAM,CAAC,sBAAsB,EAAE,CAAA;YAE9D,IAAI,CAAC,0BAA0B,IAAI,CAAC,sBAAsB,EAAE;gBAC1D,OAAO,EAAE,CAAA;aACV;YAED,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,iBAAiB,CACxD,0BAA0B,CAC3B,CAAA;YAED,MAAM,oBAAoB,GAAG,QAAQ,CAAC,IAAI,CACxC,OAAO,CAAC,EAAE,CAAC,OAAO,YAAY,iBAAiB,CAC3B,CAAA;YAEtB,IAAI,CAAC,oBAAoB,EAAE;gBACzB,OAAO,QAAQ,CAAA;aAChB;YAED,MAAM,SAAS,GAAG,oBAAoB,CAAC,WAAW,CAAC,GAAG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C,YAAY,EAAE,OAAO,CAAC,OAAO,CAAC,cAAwB;YACtD,MAAM,EAAE,MAAM;YACd,UAAU,EAAE,oBAAoB,CAAC,EAAE;SACpC,CAAA;QAED,MAAM,EAAE,MAAM,KAAmB,KAAK,EAAnB,SAAS,UAAK,KAAK,EAAhC,UAAwB,CAAQ,CAAA;QAEtC,MAAM,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAAA;IAC9C,CAAC;CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
-
import { storeCaseRating } from '@botonic/core';
|
|
2
|
+
import { EventAction, storeCaseRating } from '@botonic/core';
|
|
3
3
|
import { v7 as uuid } from 'uuid';
|
|
4
4
|
import { AGENT_RATING_PAYLOAD, SEPARATOR } from '../constants';
|
|
5
|
-
import {
|
|
5
|
+
import { trackEvent } from '../tracking';
|
|
6
6
|
export function getContentsByPayload(context) {
|
|
7
7
|
var _a, _b;
|
|
8
8
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payload.js","sourceRoot":"","sources":["../../../src/action/payload.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"payload.js","sourceRoot":"","sources":["../../../src/action/payload.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAiB,eAAe,EAAE,MAAM,eAAe,CAAA;AAC3E,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAA;AAEjC,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAG9D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGxC,MAAM,UAAgB,oBAAoB,CACxC,OAA2B;;;QAE3B,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,GAA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AAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAC7E,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAE7E,IAAI,OAAO,CAAC,OAAO,CAAC,gBAAgB,EAAE;YACpC,MAAM,KAAK,GAAkB;gBAC3B,MAAM,EAAE,WAAW,CAAC,YAAY;gBAChC,gBAAgB,EAAE,OAAO,CAAC,OAAO,CAAC,gBAAgB;gBAClD,eAAe,EAAE,IAAI,EAAE,CAAC,QAAQ,EAAE;gBAClC,eAAe;gBACf,cAAc;gBACd,MAAM,EAAE,IAAI;gBACZ,KAAK;aACN,CAAA;YAED,MAAM,eAAe,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;YAC7C,MAAM,UAAU,CAAC,OAAO,EAAE,WAAW,CAAC,YAAY,EAAE,KAAK,CAAC,CAAA;SAC3D;QAED,MAAM,UAAU,GAAG,MAAM;YACvB,CAAC,CAAC,MAAM,CAAC,WAAW,CAAoB,MAAM,CAAC,EAAE,CAAC;YAClD,CAAC,CAAC,SAAS,CAAA;QAEb,IAAI,UAAU,EAAE;YACd,OAAO,MAAM,iBAAiB,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAA;SAC7D;QAED,OAAO,EAAE,CAAA;IACX,CAAC;CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { AgenticOutputMessage } from '
|
|
2
|
+
import { AgenticOutputMessage } from '@botonic/core';
|
|
3
3
|
import { ContentFieldsBase } from './content-fields-base';
|
|
4
|
-
import { HtAiAgentNode } from './hubtype-fields/ai-agent';
|
|
4
|
+
import { HtAiAgentNode, HtInputGuardrailRule } from './hubtype-fields/ai-agent';
|
|
5
5
|
export declare class FlowAiAgent extends ContentFieldsBase {
|
|
6
6
|
code: string;
|
|
7
7
|
name: string;
|
|
@@ -9,6 +9,7 @@ export declare class FlowAiAgent extends ContentFieldsBase {
|
|
|
9
9
|
activeTools?: {
|
|
10
10
|
name: string;
|
|
11
11
|
}[];
|
|
12
|
+
inputGuardrailRules: HtInputGuardrailRule[];
|
|
12
13
|
responses: AgenticOutputMessage[];
|
|
13
14
|
static fromHubtypeCMS(component: HtAiAgentNode): FlowAiAgent;
|
|
14
15
|
toBotonic(id: string): JSX.Element;
|
|
@@ -16,10 +16,12 @@ export class FlowAiAgent extends ContentFieldsBase {
|
|
|
16
16
|
newAiAgent.name = component.content.name;
|
|
17
17
|
newAiAgent.instructions = component.content.instructions;
|
|
18
18
|
newAiAgent.activeTools = component.content.active_tools;
|
|
19
|
+
newAiAgent.inputGuardrailRules =
|
|
20
|
+
component.content.input_guardrail_rules || [];
|
|
19
21
|
return newAiAgent;
|
|
20
22
|
}
|
|
21
23
|
toBotonic(id) {
|
|
22
|
-
return (_jsx(_Fragment, { children: this.responses.map(response => {
|
|
24
|
+
return (_jsx(_Fragment, { children: this.responses.map((response) => {
|
|
23
25
|
if (response.type === 'text') {
|
|
24
26
|
return _jsx(Text, { children: response.content.text }, id);
|
|
25
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-ai-agent.js","sourceRoot":"","sources":["../../../src/content-fields/flow-ai-agent.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"flow-ai-agent.js","sourceRoot":"","sources":["../../../src/content-fields/flow-ai-agent.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAEvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAG5C,MAAM,OAAO,WAAY,SAAQ,iBAAiB;IAAlD;;QACS,SAAI,GAAW,E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ACL,KAAC,QAAQ,cACN,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CACvC,WAAW,CAAC,WAAW,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CACnD,IAHY,EAAE,CAIN,CACZ,CAAA;iBACF;gBAED,OAAO,mBAAK,CAAA;YACd,CAAC,CAAC,GACD,CACJ,CAAA;IACH,CAAC;CACF"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { HtBaseNode } from './common';
|
|
2
2
|
import { HtNodeWithContentType } from './node-types';
|
|
3
|
+
export interface HtInputGuardrailRule {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
is_active: boolean;
|
|
7
|
+
}
|
|
3
8
|
export interface HtAiAgentNode extends HtBaseNode {
|
|
4
9
|
type: HtNodeWithContentType.AI_AGENT;
|
|
5
10
|
content: {
|
|
@@ -8,5 +13,6 @@ export interface HtAiAgentNode extends HtBaseNode {
|
|
|
8
13
|
active_tools?: {
|
|
9
14
|
name: string;
|
|
10
15
|
}[];
|
|
16
|
+
input_guardrail_rules?: HtInputGuardrailRule[];
|
|
11
17
|
};
|
|
12
18
|
}
|
package/lib/esm/tracking.d.ts
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
|
+
import { EventAction } from '@botonic/core';
|
|
1
2
|
import { ActionRequest } from '@botonic/react';
|
|
2
3
|
import { FlowContent } from './content-fields';
|
|
3
|
-
export declare enum EventAction {
|
|
4
|
-
FlowNode = "flow_node",
|
|
5
|
-
Keyword = "nlu_keyword",
|
|
6
|
-
IntentSmart = "nlu_intent_smart",
|
|
7
|
-
Knowledgebase = "knowledgebase",
|
|
8
|
-
Fallback = "fallback",
|
|
9
|
-
FeedbackCase = "feedback_case"
|
|
10
|
-
}
|
|
11
|
-
export declare enum KnowledgebaseFailReason {
|
|
12
|
-
NoKnowledge = "no_knowledge",
|
|
13
|
-
Hallucination = "hallucination"
|
|
14
|
-
}
|
|
15
4
|
export declare function trackEvent(request: ActionRequest, eventAction: EventAction, args?: Record<string, any>): Promise<void>;
|
|
16
5
|
export declare function trackFlowContent(request: ActionRequest, contents: FlowContent[]): Promise<void>;
|
package/lib/esm/tracking.js
CHANGED
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
1
|
+
import { __awaiter, __rest } from "tslib";
|
|
2
|
+
import { EventAction } from '@botonic/core';
|
|
2
3
|
import { v7 as uuidv7 } from 'uuid';
|
|
3
4
|
import { HtNodeWithContentType, } from './content-fields/hubtype-fields';
|
|
4
5
|
import { getFlowBuilderPlugin } from './helpers';
|
|
5
|
-
export var EventAction;
|
|
6
|
-
(function (EventAction) {
|
|
7
|
-
EventAction["FlowNode"] = "flow_node";
|
|
8
|
-
EventAction["Keyword"] = "nlu_keyword";
|
|
9
|
-
EventAction["IntentSmart"] = "nlu_intent_smart";
|
|
10
|
-
EventAction["Knowledgebase"] = "knowledgebase";
|
|
11
|
-
EventAction["Fallback"] = "fallback";
|
|
12
|
-
EventAction["FeedbackCase"] = "feedback_case";
|
|
13
|
-
})(EventAction || (EventAction = {}));
|
|
14
|
-
export var KnowledgebaseFailReason;
|
|
15
|
-
(function (KnowledgebaseFailReason) {
|
|
16
|
-
KnowledgebaseFailReason["NoKnowledge"] = "no_knowledge";
|
|
17
|
-
KnowledgebaseFailReason["Hallucination"] = "hallucination";
|
|
18
|
-
})(KnowledgebaseFailReason || (KnowledgebaseFailReason = {}));
|
|
19
6
|
export function trackEvent(request, eventAction, args) {
|
|
20
7
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
8
|
const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins);
|
|
@@ -26,36 +13,33 @@ export function trackEvent(request, eventAction, args) {
|
|
|
26
13
|
});
|
|
27
14
|
}
|
|
28
15
|
export function trackFlowContent(request, contents) {
|
|
29
|
-
var _a;
|
|
30
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
17
|
const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins);
|
|
32
18
|
const cmsApi = flowBuilderPlugin.cmsApi;
|
|
33
19
|
for (const content of contents) {
|
|
34
20
|
const nodeContent = cmsApi.getNodeById(content.id);
|
|
35
21
|
if (nodeContent.type !== HtNodeWithContentType.KNOWLEDGE_BASE) {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
flowName: flowBuilderPlugin.getFlowName(nodeContent.flow_id),
|
|
40
|
-
id: nodeContent.id,
|
|
41
|
-
isMeaningful: (_a = nodeContent.is_meaningful) !== null && _a !== void 0 ? _a : false,
|
|
42
|
-
});
|
|
43
|
-
yield trackEvent(request, EventAction.FlowNode, eventArgs);
|
|
22
|
+
const event = getContentEventArgs(request, nodeContent);
|
|
23
|
+
const { action } = event, eventArgs = __rest(event, ["action"]);
|
|
24
|
+
yield trackEvent(request, action, eventArgs);
|
|
44
25
|
}
|
|
45
26
|
}
|
|
46
27
|
});
|
|
47
28
|
}
|
|
48
|
-
function getContentEventArgs(request,
|
|
49
|
-
var _a;
|
|
29
|
+
function getContentEventArgs(request, nodeContent) {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins);
|
|
32
|
+
const flowName = flowBuilderPlugin.getFlowName(nodeContent.flow_id);
|
|
50
33
|
const flowThreadId = (_a = request.session.flow_thread_id) !== null && _a !== void 0 ? _a : uuidv7();
|
|
51
34
|
request.session.flow_thread_id = flowThreadId;
|
|
52
35
|
return {
|
|
36
|
+
action: EventAction.FlowNode,
|
|
53
37
|
flowThreadId,
|
|
54
|
-
flowId:
|
|
55
|
-
flowName:
|
|
56
|
-
flowNodeId:
|
|
57
|
-
flowNodeContentId:
|
|
58
|
-
flowNodeIsMeaningful:
|
|
38
|
+
flowId: nodeContent.flow_id,
|
|
39
|
+
flowName: flowName,
|
|
40
|
+
flowNodeId: nodeContent.id,
|
|
41
|
+
flowNodeContentId: nodeContent.code,
|
|
42
|
+
flowNodeIsMeaningful: (_b = nodeContent.is_meaningful) !== null && _b !== void 0 ? _b : false,
|
|
59
43
|
};
|
|
60
44
|
}
|
|
61
45
|
//# sourceMappingURL=tracking.js.map
|
package/lib/esm/tracking.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracking.js","sourceRoot":"","sources":["../../src/tracking.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"tracking.js","sourceRoot":"","sources":["../../src/tracking.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAa,MAAM,eAAe,CAAA;AAEtD,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAA;AAGnC,OAAO,EAEL,qBAAqB,GACtB,MAAM,iCAAiC,CAAA;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAEhD,MAAM,UAAgB,UAAU,CAC9B,OAAsB,EACtB,WAAwB,EACxB,IAA0B;;QAE1B,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAC/D,IAAI,iBAAiB,CAAC,UAAU,EAAE;YAChC,MAAM,iBAAiB,CAAC,UAAU,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,CAAA;SAC/D;QACD,OAAM;IACR,CAAC;CAAA;AAED,MAAM,UAAgB,gBAAgB,CACpC,OAAsB,EACtB,QAAuB;;QAEvB,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAC/D,MAAM,MAAM,GAAG,iBAAiB,CAAC,MAAM,CAAA;QACvC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;YAC9B,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAoB,OAAO,CAAC,EAAE,CAAC,CAAA;YACrE,IAAI,WAAW,CAAC,IAAI,KAAK,qBAAqB,CAAC,cAAc,EAAE;gBAC7D,MAAM,KAAK,GAAG,mBAAmB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;gBACvD,MAAM,EAAE,MAAM,KAAmB,KAAK,EAAnB,SAAS,UAAK,KAAK,EAAhC,UAAwB,CAAQ,CAAA;gBACtC,MAAM,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAAA;aAC7C;SACF;IACH,CAAC;CAAA;AAED,SAAS,mBAAmB,CAC1B,OAAsB,EACtB,WAA8B;;IAE9B,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAC/D,MAAM,QAAQ,GAAG,iBAAiB,CAAC,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;IACnE,MAAM,YAAY,GAAG,MAAA,OAAO,CAAC,OAAO,CAAC,cAAc,mCAAI,MAAM,EAAE,CAAA;IAC/D,OAAO,CAAC,OAAO,CAAC,cAAc,GAAG,YAAY,CAAA;IAE7C,OAAO;QACL,MAAM,EAAE,WAAW,CAAC,QAAQ;QAC5B,YAAY;QACZ,MAAM,EAAE,WAAW,CAAC,OAAO;QAC3B,QAAQ,EAAE,QAAQ;QAClB,UAAU,EAAE,WAAW,CAAC,EAAE;QAC1B,iBAAiB,EAAE,WAAW,CAAC,IAAI;QACnC,oBAAoB,EAAE,MAAA,WAAW,CAAC,aAAa,mCAAI,KAAK;KACzD,CAAA;AACH,CAAC"}
|
package/lib/esm/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BotContext, PluginPreRequest, ResolvedPlugins } from '@botonic/core';
|
|
1
|
+
import { BotContext, InferenceResponse, KnowledgeBasesResponse, PluginPreRequest, ResolvedPlugins } from '@botonic/core';
|
|
2
2
|
import { FlowContent } from './content-fields';
|
|
3
3
|
import { HtFlowBuilderData } from './content-fields/hubtype-fields';
|
|
4
4
|
export interface InShadowingConfig {
|
|
@@ -23,14 +23,19 @@ export interface BotonicPluginFlowBuilderOptions<TPlugins extends ResolvedPlugin
|
|
|
23
23
|
customRatingMessageEnabled?: boolean;
|
|
24
24
|
}
|
|
25
25
|
export type TrackEventFunction<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = (request: BotContext<TPlugins, TExtraData>, eventAction: string, args?: Record<string, any>) => Promise<void>;
|
|
26
|
-
export type KnowledgeBaseFunction<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = (request: BotContext<TPlugins, TExtraData>, sources: string[], instructions: string, messageId: string, memoryLength: number) => Promise<
|
|
27
|
-
export type AiAgentFunction<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = (request: BotContext<TPlugins, TExtraData>, aiAgentArgs: AiAgentArgs) => Promise<
|
|
26
|
+
export type KnowledgeBaseFunction<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = (request: BotContext<TPlugins, TExtraData>, sources: string[], instructions: string, messageId: string, memoryLength: number) => Promise<KnowledgeBasesResponse>;
|
|
27
|
+
export type AiAgentFunction<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = (request: BotContext<TPlugins, TExtraData>, aiAgentArgs: AiAgentArgs) => Promise<InferenceResponse>;
|
|
28
|
+
export interface GuardrailRule {
|
|
29
|
+
name: string;
|
|
30
|
+
description: string;
|
|
31
|
+
}
|
|
28
32
|
export interface AiAgentArgs {
|
|
29
33
|
name: string;
|
|
30
34
|
instructions: string;
|
|
31
35
|
activeTools?: {
|
|
32
36
|
name: string;
|
|
33
37
|
}[];
|
|
38
|
+
inputGuardrailRules?: GuardrailRule[];
|
|
34
39
|
}
|
|
35
40
|
export type ContentFilter<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData = any> = (request: BotContext<TPlugins, TExtraData>, content: FlowContent) => Promise<FlowContent> | FlowContent;
|
|
36
41
|
export interface FlowBuilderApiOptions {
|
|
@@ -48,13 +53,6 @@ export declare enum FlowBuilderJSONVersion {
|
|
|
48
53
|
DRAFT = "draft",
|
|
49
54
|
LATEST = "latest"
|
|
50
55
|
}
|
|
51
|
-
export interface KnowledgeBaseResponse {
|
|
52
|
-
inferenceId: string;
|
|
53
|
-
hasKnowledge: boolean;
|
|
54
|
-
isFaithful: boolean;
|
|
55
|
-
chunkIds: string[];
|
|
56
|
-
answer: string;
|
|
57
|
-
}
|
|
58
56
|
export interface SmartIntentResponse {
|
|
59
57
|
data: {
|
|
60
58
|
smart_intent_title: string;
|
|
@@ -68,37 +66,3 @@ export interface SmartIntentResponse {
|
|
|
68
66
|
export interface PayloadParamsBase {
|
|
69
67
|
followUpContentID?: string;
|
|
70
68
|
}
|
|
71
|
-
export interface OutputBaseMessage {
|
|
72
|
-
type: 'text' | 'textWithButtons' | 'carousel' | 'exit';
|
|
73
|
-
}
|
|
74
|
-
export interface TextMessage extends OutputBaseMessage {
|
|
75
|
-
type: 'text';
|
|
76
|
-
content: {
|
|
77
|
-
text: string;
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
export interface TextWithButtonsMessage extends OutputBaseMessage {
|
|
81
|
-
type: 'textWithButtons';
|
|
82
|
-
content: {
|
|
83
|
-
text: string;
|
|
84
|
-
buttons: string[];
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
export interface CarouselMessage extends OutputBaseMessage {
|
|
88
|
-
type: 'carousel';
|
|
89
|
-
content: {
|
|
90
|
-
elements: {
|
|
91
|
-
title: string;
|
|
92
|
-
subtitle: string;
|
|
93
|
-
image: string;
|
|
94
|
-
button: {
|
|
95
|
-
text: string;
|
|
96
|
-
url: string;
|
|
97
|
-
};
|
|
98
|
-
}[];
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
export interface ExitMessage extends OutputBaseMessage {
|
|
102
|
-
type: 'exit';
|
|
103
|
-
}
|
|
104
|
-
export type AgenticOutputMessage = TextMessage | TextWithButtonsMessage | CarouselMessage | ExitMessage;
|
package/lib/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AA8FA,MAAM,CAAN,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,+CAAyB,CAAA;IACzB,iDAA2B,CAAA;AAC7B,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,QAG7B;AAED,MAAM,CAAN,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAChC,yCAAe,CAAA;IACf,2CAAiB,CAAA;AACnB,CAAC,EAHW,sBAAsB,KAAtB,sBAAsB,QAGjC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
|
-
import { NluType } from '@botonic/core';
|
|
1
|
+
import { __awaiter, __rest } from "tslib";
|
|
2
|
+
import { EventAction, NluType } from '@botonic/core';
|
|
3
3
|
import { REG_EXP_PATTERN } from '../constants';
|
|
4
|
-
import {
|
|
4
|
+
import { trackEvent } from '../tracking';
|
|
5
5
|
export class KeywordMatcher {
|
|
6
6
|
constructor({ cmsApi, locale, request }) {
|
|
7
7
|
this.cmsApi = cmsApi;
|
|
@@ -63,16 +63,18 @@ export class KeywordMatcher {
|
|
|
63
63
|
}
|
|
64
64
|
trackKeywordEvent() {
|
|
65
65
|
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
const
|
|
66
|
+
const event = {
|
|
67
|
+
action: EventAction.Keyword,
|
|
68
|
+
flowThreadId: this.request.session.flow_thread_id,
|
|
69
|
+
flowNodeId: this.keywordNodeId,
|
|
70
|
+
flowId: this.flowId,
|
|
67
71
|
nluKeywordName: this.matchedKeyword,
|
|
68
72
|
nluKeywordIsRegex: this.isRegExp,
|
|
69
73
|
nluKeywordMessageId: this.request.input.message_id,
|
|
70
74
|
userInput: this.request.input.data,
|
|
71
|
-
flowThreadId: this.request.session.flow_thread_id,
|
|
72
|
-
flowId: this.flowId,
|
|
73
|
-
flowNodeId: this.keywordNodeId,
|
|
74
75
|
};
|
|
75
|
-
|
|
76
|
+
const { action } = event, eventArgs = __rest(event, ["action"]);
|
|
77
|
+
yield trackEvent(this.request, action, eventArgs);
|
|
76
78
|
});
|
|
77
79
|
}
|
|
78
80
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyword.js","sourceRoot":"","sources":["../../../src/user-input/keyword.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"keyword.js","sourceRoot":"","sources":["../../../src/user-input/keyword.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAgB,OAAO,EAAE,MAAM,eAAe,CAAA;AAIlE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAK9C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAOxC,MAAM,OAAO,cAAc;IASzB,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAgB;QACnD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAA;IACvB,CAAC;IAEK,cAAc,CAAC,SAAiB;;YACpC,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,CAAA;YAClD,MAAM,WAAW,GAAG,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAA;YAClE,IAAI,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;gBACxC,OAAO,SAAS,CAAA;aACjB;YACD,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;YAEhE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,aAAa,GAAG;gBACjC,I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AAnB,SAAS,UAAK,KAAK,EAAhC,UAAwB,CAAQ,CAAA;YACtC,MAAM,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAAA;QACnD,CAAC;KAAA;CACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
|
-
import { NluType } from '@botonic/core';
|
|
1
|
+
import { __awaiter, __rest } from "tslib";
|
|
2
|
+
import { EventAction, NluType } from '@botonic/core';
|
|
3
3
|
import axios from 'axios';
|
|
4
4
|
import { getFlowBuilderPlugin } from '../helpers';
|
|
5
|
-
import {
|
|
5
|
+
import { trackEvent } from '../tracking';
|
|
6
6
|
export class SmartIntentsApi {
|
|
7
7
|
constructor(cmsApi, currentRequest, smartIntentsConfig, flowId) {
|
|
8
8
|
this.cmsApi = cmsApi;
|
|
@@ -33,7 +33,8 @@ export class SmartIntentsApi {
|
|
|
33
33
|
matchedValue: smartIntentNode.content.title,
|
|
34
34
|
payload: targetPayload,
|
|
35
35
|
};
|
|
36
|
-
|
|
36
|
+
const event = {
|
|
37
|
+
action: EventAction.IntentSmart,
|
|
37
38
|
nluIntentSmartTitle: response.data.smart_intent_title,
|
|
38
39
|
nluIntentSmartNumUsed: response.data.smart_intents_used.length,
|
|
39
40
|
nluIntentSmartMessageId: this.currentRequest.input.message_id,
|
|
@@ -41,7 +42,9 @@ export class SmartIntentsApi {
|
|
|
41
42
|
flowThreadId: this.currentRequest.session.flow_thread_id,
|
|
42
43
|
flowId: smartIntentNode.flow_id,
|
|
43
44
|
flowNodeId: smartIntentNode.id,
|
|
44
|
-
}
|
|
45
|
+
};
|
|
46
|
+
const { action } = event, eventArgs = __rest(event, ["action"]);
|
|
47
|
+
yield trackEvent(this.currentRequest, action, eventArgs);
|
|
45
48
|
return smartIntentNode;
|
|
46
49
|
}
|
|
47
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smart-intent.js","sourceRoot":"","sources":["../../../src/user-input/smart-intent.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"smart-intent.js","sourceRoot":"","sources":["../../../src/user-input/smart-intent.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAoB,OAAO,EAAE,MAAM,eAAe,CAAA;AAEtE,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAexC,MAAM,OAAO,eAAe;IAC1B,YACS,MAAsB,EACtB,cAA6B,EAC7B,kBAA+C,EAC/C,MAAe;QAHf,WAAM,GAAN,MAAM,CAAgB;QACtB,mBAAc,GAAd,cAAc,CAAe;QAC7B,uBAAkB,GAAlB,kBAAkB,CAA6B;QAC/C,WAAM,GAAN,MAAM,CAAS;IACrB,CAAC;IAEE,cAAc;;YAClB,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI;gBAAE,OAAO,SAAS,CAAA;YACrD,MAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAA;YAC1D,IAAI,CAAC,gBAAgB,CAAC,MAAM;gBAAE,OAAO,SAAS,CAAA;YAE9C,MAAM,MAAM,GAAG;gBACb,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;gBAC1C,IAAI,EAAE,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI;gBACpC,wBAAwB,EAAE,IAAI,CAAC,kBAAkB,CAAC,oBAAoB;gBACtE,UAAU,EAAE,IAAI,CAAC,gBAAgB,EAAE;aACpC,CAAA;YAED,IAAI;gBACF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAA;gBAChD,MAAM,eAAe,GAAG,gBAAgB,CA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tB,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,mBAAmB;YAAE,OAAO,KAAK,CAAA;QACjE,OAAO,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAA;IAC1C,CAAC;IAEa,YAAY,CACxB,eAA4C;;YAE5C,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;YAC3E,MAAM,KAAK,GAAG,iBAAiB,CAAC,cAAc,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;YAE3E,OAAO,MAAM,KAAK,CAAC;gBACjB,MAAM,EAAE,MAAM;gBACd,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,0CAA0C;gBAC7E,OAAO,EAAE;oBACP,aAAa,EAAE,UAAU,KAAK,EAAE;oBAChC,cAAc,EAAE,kBAAkB;iBACnC;gBACD,IAAI,EAAE,eAAe;gBACrB,OAAO,EAAE,KAAK;aACf,CAAC,CAAA;QACJ,CAAC;KAAA;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botonic/plugin-flow-builder",
|
|
3
|
-
"version": "0.37.
|
|
3
|
+
"version": "0.37.2-alpha.0",
|
|
4
4
|
"main": "./lib/cjs/index.js",
|
|
5
5
|
"module": "./lib/esm/index.js",
|
|
6
6
|
"description": "Use Flow Builder to show your contents",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"lint_core": "../../node_modules/.bin/eslint_d --cache --quiet 'src/**/*.ts*'"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@botonic/react": "
|
|
17
|
+
"@botonic/react": "0.37.2-alpha.0",
|
|
18
18
|
"axios": "^1.10.0",
|
|
19
19
|
"uuid": "^10.0.0"
|
|
20
20
|
},
|
package/src/action/ai-agent.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FlowContent } from '../content-fields'
|
|
2
2
|
import { FlowAiAgent } from '../content-fields/flow-ai-agent'
|
|
3
|
+
import { GuardrailRule } from '../types'
|
|
3
4
|
import { FlowBuilderContext } from './index'
|
|
4
5
|
|
|
5
6
|
export async function getContentsByAiAgent({
|
|
@@ -24,12 +25,21 @@ export async function getContentsByAiAgent({
|
|
|
24
25
|
return []
|
|
25
26
|
}
|
|
26
27
|
|
|
28
|
+
const activeInputGuardrailRules: GuardrailRule[] =
|
|
29
|
+
aiAgentContent.inputGuardrailRules
|
|
30
|
+
?.filter(rule => rule.is_active)
|
|
31
|
+
?.map(rule => ({
|
|
32
|
+
name: rule.name,
|
|
33
|
+
description: rule.description,
|
|
34
|
+
})) || []
|
|
35
|
+
|
|
27
36
|
const aiAgentResponse = await flowBuilderPlugin.getAiAgentResponse?.(
|
|
28
37
|
request,
|
|
29
38
|
{
|
|
30
39
|
name: aiAgentContent.name,
|
|
31
40
|
instructions: aiAgentContent.instructions,
|
|
32
41
|
activeTools: aiAgentContent.activeTools,
|
|
42
|
+
inputGuardrailRules: activeInputGuardrailRules,
|
|
33
43
|
}
|
|
34
44
|
)
|
|
35
45
|
|
|
@@ -37,11 +47,11 @@ export async function getContentsByAiAgent({
|
|
|
37
47
|
return []
|
|
38
48
|
}
|
|
39
49
|
|
|
40
|
-
if (aiAgentResponse.
|
|
50
|
+
if (aiAgentResponse.exit) {
|
|
41
51
|
return []
|
|
42
52
|
}
|
|
43
53
|
|
|
44
|
-
aiAgentContent.responses = aiAgentResponse
|
|
54
|
+
aiAgentContent.responses = aiAgentResponse.messages
|
|
45
55
|
|
|
46
56
|
return contents
|
|
47
57
|
}
|
package/src/action/fallback.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { EventAction, EventFallback } from '@botonic/core'
|
|
1
2
|
import { ActionRequest } from '@botonic/react'
|
|
2
3
|
|
|
3
4
|
import { FlowBuilderApi } from '../api'
|
|
4
5
|
import { FlowContent } from '../content-fields'
|
|
5
|
-
import {
|
|
6
|
+
import { trackEvent } from '../tracking'
|
|
6
7
|
import { FlowBuilderContext } from './index'
|
|
7
8
|
|
|
8
9
|
export async function getContentsByFallback({
|
|
@@ -30,11 +31,15 @@ async function getFallbackNode(cmsApi: FlowBuilderApi, request: ActionRequest) {
|
|
|
30
31
|
const fallbackNode = cmsApi.getFallbackNode(isFirstFallbackOption)
|
|
31
32
|
request.session.user.extra_data.isFirstFallbackOption = !isFirstFallbackOption
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
const event: EventFallback = {
|
|
35
|
+
action: EventAction.Fallback,
|
|
36
|
+
userInput: request.input.data as string,
|
|
35
37
|
fallbackOut: isFirstFallbackOption ? 1 : 2,
|
|
36
38
|
fallbackMessageId: request.input.message_id,
|
|
37
|
-
}
|
|
39
|
+
}
|
|
40
|
+
const { action, ...eventArgs } = event
|
|
41
|
+
|
|
42
|
+
await trackEvent(request, action, eventArgs)
|
|
38
43
|
|
|
39
44
|
return fallbackNode
|
|
40
45
|
}
|