@botonic/plugin-flow-builder 0.28.2 → 0.29.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/knowledge-bases.js +10 -8
- package/lib/cjs/action/knowledge-bases.js.map +1 -1
- package/lib/cjs/content-fields/flow-knowledge-base.d.ts +4 -0
- package/lib/cjs/content-fields/flow-knowledge-base.js +2 -1
- package/lib/cjs/content-fields/flow-knowledge-base.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/knowledge-base.d.ts +6 -1
- package/lib/cjs/types.d.ts +1 -5
- package/lib/esm/action/knowledge-bases.js +10 -8
- package/lib/esm/action/knowledge-bases.js.map +1 -1
- package/lib/esm/content-fields/flow-knowledge-base.d.ts +4 -0
- package/lib/esm/content-fields/flow-knowledge-base.js +2 -1
- package/lib/esm/content-fields/flow-knowledge-base.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/knowledge-base.d.ts +6 -1
- package/lib/esm/types.d.ts +1 -5
- package/package.json +2 -2
- package/src/action/knowledge-bases.ts +14 -14
- package/src/content-fields/flow-knowledge-base.tsx +2 -1
- package/src/content-fields/hubtype-fields/knowledge-base.ts +6 -1
- package/src/types.ts +1 -5
|
@@ -16,9 +16,11 @@ function getContentsByKnowledgeBase({ cmsApi, flowBuilderPlugin, request, resolv
|
|
|
16
16
|
if (!knowledgeBaseContent) {
|
|
17
17
|
return contents;
|
|
18
18
|
}
|
|
19
|
+
const sourceIds = knowledgeBaseContent.sourcesData.map(source => source.id);
|
|
19
20
|
if (flowBuilderPlugin.getKnowledgeBaseResponse &&
|
|
20
|
-
(0, utils_1.inputHasTextData)(request.input)
|
|
21
|
-
|
|
21
|
+
(0, utils_1.inputHasTextData)(request.input) &&
|
|
22
|
+
sourceIds.length > 0) {
|
|
23
|
+
const contentsWithKnowledgeResponse = yield getContentsWithKnowledgeResponse(flowBuilderPlugin.getKnowledgeBaseResponse, request, contents, sourceIds);
|
|
22
24
|
if (contentsWithKnowledgeResponse) {
|
|
23
25
|
return contentsWithKnowledgeResponse;
|
|
24
26
|
}
|
|
@@ -27,10 +29,10 @@ function getContentsByKnowledgeBase({ cmsApi, flowBuilderPlugin, request, resolv
|
|
|
27
29
|
});
|
|
28
30
|
}
|
|
29
31
|
exports.getContentsByKnowledgeBase = getContentsByKnowledgeBase;
|
|
30
|
-
function getContentsWithKnowledgeResponse(getKnowledgeBaseResponse, request,
|
|
32
|
+
function getContentsWithKnowledgeResponse(getKnowledgeBaseResponse, request, contents, sourceIds) {
|
|
31
33
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
const knowledgeBaseResponse = yield getKnowledgeBaseResponse(request, request.input.data,
|
|
33
|
-
yield trackKnowledgeBase(knowledgeBaseResponse, request);
|
|
34
|
+
const knowledgeBaseResponse = yield getKnowledgeBaseResponse(request, request.input.data, sourceIds);
|
|
35
|
+
yield trackKnowledgeBase(knowledgeBaseResponse, request, sourceIds);
|
|
34
36
|
if (!knowledgeBaseResponse.hasKnowledge ||
|
|
35
37
|
!knowledgeBaseResponse.isFaithuful) {
|
|
36
38
|
return undefined;
|
|
@@ -47,11 +49,11 @@ function updateContentsWithResponse(contents, response) {
|
|
|
47
49
|
return content;
|
|
48
50
|
});
|
|
49
51
|
}
|
|
50
|
-
function trackKnowledgeBase(response, request) {
|
|
52
|
+
function trackKnowledgeBase(response, request, sourceIds) {
|
|
51
53
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
52
54
|
const knowledgebaseInferenceId = response.inferenceId;
|
|
53
|
-
const knowledgebaseSourcesIds =
|
|
54
|
-
const knowledgebaseChunksIds = response.
|
|
55
|
+
const knowledgebaseSourcesIds = sourceIds;
|
|
56
|
+
const knowledgebaseChunksIds = response.chunkIds;
|
|
55
57
|
const knowledgebaseMessageId = request.input.message_id;
|
|
56
58
|
let knowledgebaseFailReason;
|
|
57
59
|
if (!response.isFaithuful) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knowledge-bases.js","sourceRoot":"","sources":["../../../src/action/knowledge-bases.ts"],"names":[],"mappings":";;;;AAEA,sDAAkE;AAClE,0CAA8E;AAE9E,oCAA2C;AAG3C,SAAsB,0BAA0B,CAAC,EAC/C,MAAM,EACN,iBAAiB,EACjB,OAAO,EACP,cAAc,GACK;;QACnB,MAAM,yBAAyB,GAAG,MAAM,CAAC,4BAA4B,EAAE,CAAA;QAEvE,IAAI,CAAC,yBAAyB,EAAE;YAC9B,OAAO,EAAE,CAAA;SACV;QAED,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,iBAAiB,CACxD,yBAAyB,EACzB,cAAc,CACf,CAAA;QAED,MAAM,oBAAoB,GAAG,QAAQ,CAAC,IAAI,CACxC,OAAO,CAAC,EAAE,CAAC,OAAO,YAAY,kCAAiB,CAC3B,CAAA;QAEtB,IAAI,CAAC,oBAAoB,EAAE;YACzB,OAAO,QAAQ,CAAA;SAChB;QAED,IACE,iBAAiB,CAAC,wBAAwB;YAC1C,IAAA,wBAAgB,EAAC,OAAO,CAAC,KAAK,CAAC
|
|
1
|
+
{"version":3,"file":"knowledge-bases.js","sourceRoot":"","sources":["../../../src/action/knowledge-bases.ts"],"names":[],"mappings":";;;;AAEA,sDAAkE;AAClE,0CAA8E;AAE9E,oCAA2C;AAG3C,SAAsB,0BAA0B,CAAC,EAC/C,MAAM,EACN,iBAAiB,EACjB,OAAO,EACP,cAAc,GACK;;QACnB,MAAM,yBAAyB,GAAG,MAAM,CAAC,4BAA4B,EAAE,CAAA;QAEvE,IAAI,CAAC,yBAAyB,EAAE;YAC9B,OAAO,EAAE,CAAA;SACV;QAED,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,iBAAiB,CACxD,yBAAyB,EACzB,cAAc,CACf,CAAA;QAED,MAAM,oBAAoB,GAAG,QAAQ,CAAC,IAAI,CACxC,OAAO,CAAC,EAAE,CAAC,OAAO,YAAY,kCAAiB,CAC3B,CAAA;QAEtB,I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A;SAC3C;QAED,OAAO,OAAO,CAAA;IAChB,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAe,kBAAkB,CAC/B,QAA+B,EAC/B,OAAsB,EACtB,SAAmB;;QAEnB,MAAM,wBAAwB,GAAG,QAAQ,CAAC,WAAW,CAAA;QACrD,MAAM,uBAAuB,GAAG,SAAS,CAAA;QACzC,MAAM,sBAAsB,GAAG,QAAQ,CAAC,QAAQ,CAAA;QAChD,MAAM,sBAAsB,GAAG,OAAO,CAAC,KAAK,CAAC,UAAU,CAAA;QAEvD,IAAI,uBAA4D,CAAA;QAEhE,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE;YACzB,uBAAuB,GAAG,kCAAuB,CAAC,aAAa,CAAA;SAChE;QAED,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE;YAC1B,uBAAuB,GAAG,kCAAuB,CAAC,WAAW,CAAA;SAC9D;QAED,MAAM,IAAA,qBAAU,EAAC,OAAO,EAAE,sBAAW,CAAC,aAAa,EAAE;YACnD,wBAAwB;YACxB,uBAAuB;YACvB,uBAAuB;YACvB,sBAAsB;YACtB,sBAAsB;YACtB,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI;SAC9B,CAAC,CAAA;IACJ,CAAC;CAAA"}
|
|
@@ -7,6 +7,10 @@ export declare class FlowKnowledgeBase extends ContentFieldsBase {
|
|
|
7
7
|
sources: string[];
|
|
8
8
|
text: string;
|
|
9
9
|
inferenceId?: string;
|
|
10
|
+
sourcesData: {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
}[];
|
|
10
14
|
static fromHubtypeCMS(component: HtKnowledgeBaseNode): FlowKnowledgeBase;
|
|
11
15
|
toBotonic(id: string, request: ActionRequest): JSX.Element;
|
|
12
16
|
}
|
|
@@ -11,12 +11,13 @@ class FlowKnowledgeBase extends content_fields_base_1.ContentFieldsBase {
|
|
|
11
11
|
this.feedbackEnabled = false;
|
|
12
12
|
this.sources = [];
|
|
13
13
|
this.text = '';
|
|
14
|
+
this.sourcesData = [];
|
|
14
15
|
}
|
|
15
16
|
static fromHubtypeCMS(component) {
|
|
16
17
|
const newKnowledgeBase = new FlowKnowledgeBase(component.id);
|
|
17
18
|
newKnowledgeBase.code = component.code;
|
|
18
19
|
newKnowledgeBase.feedbackEnabled = component.content.feedback_enabled;
|
|
19
|
-
newKnowledgeBase.
|
|
20
|
+
newKnowledgeBase.sourcesData = component.content.sources_data;
|
|
20
21
|
return newKnowledgeBase;
|
|
21
22
|
}
|
|
22
23
|
toBotonic(id, request) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-knowledge-base.js","sourceRoot":"","sources":["../../../src/content-fields/flow-knowledge-base.tsx"],"names":[],"mappings":";;;;AAAA,0CAAoD;AAGpD,+DAAyD;AAGzD,MAAa,iBAAkB,SAAQ,uCAAiB;IAAxD;;QACS,SAAI,GAAW,EAAE,CAAA;QACjB,oBAAe,GAAY,KAAK,CAAA;QAChC,YAAO,GAAa,EAAE,CAAA;QACtB,SAAI,GAAW,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"flow-knowledge-base.js","sourceRoot":"","sources":["../../../src/content-fields/flow-knowledge-base.tsx"],"names":[],"mappings":";;;;AAAA,0CAAoD;AAGpD,+DAAyD;AAGzD,MAAa,iBAAkB,SAAQ,uCAAiB;IAAxD;;QACS,SAAI,GAAW,EAAE,CAAA;QACjB,oBAAe,GAAY,KAAK,CAAA;QAChC,YAAO,GAAa,EAAE,CAAA;QACtB,SAAI,GAAW,EAAE,CAAA;QAEjB,gBAAW,GAAmC,EAAE,CAAA;IAuBzD,CAAC;IArBC,MAAM,CAAC,cAAc,CAAC,SAA8B;QAClD,MAAM,gBAAgB,GAAG,IAAI,iBAAiB,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QAC5D,gBAAgB,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAA;QACtC,gBAAgB,CAAC,eAAe,GAAG,SAAS,CAAC,OAAO,CAAC,gBAAgB,CAAA;QACrE,gBAAgB,CAAC,WAAW,GAAG,SAAS,CAAC,OAAO,CAAC,YAAY,CAAA;QAE7D,OAAO,gBAAgB,CAAA;IACzB,CAAC;IAED,SAAS,CAAC,EAAU,EAAE,OAAsB;QAC1C,OAAO,CACL,uBAAC,YAAI,kBAEH,eAAe,EAAE,IAAI,CAAC,eAAe,EACrC,WAAW,EAAE,IAAI,CAAC,WAAW,EAC7B,gBAAgB,EAAE,OAAO,CAAC,KAAK,CAAC,kBAAkB,gBAEjD,IAAI,CAAC,IAAI,KALL,EAAE,CAMF,CACR,CAAA;IACH,CAAC;CACF;AA7BD,8CA6BC"}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { HtBaseNode } from './common';
|
|
2
2
|
import { HtNodeWithContentType } from './node-types';
|
|
3
|
+
interface SourceData {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
3
7
|
export interface HtKnowledgeBaseNode extends HtBaseNode {
|
|
4
8
|
type: HtNodeWithContentType.KNOWLEDGE_BASE;
|
|
5
9
|
content: {
|
|
6
10
|
feedback_enabled: boolean;
|
|
7
|
-
|
|
11
|
+
sources_data: SourceData[];
|
|
8
12
|
};
|
|
9
13
|
}
|
|
14
|
+
export {};
|
package/lib/cjs/types.d.ts
CHANGED
|
@@ -36,11 +36,7 @@ export interface KnowledgeBaseResponse {
|
|
|
36
36
|
answer: string;
|
|
37
37
|
hasKnowledge: boolean;
|
|
38
38
|
isFaithuful: boolean;
|
|
39
|
-
|
|
40
|
-
knowledgeBaseId: string;
|
|
41
|
-
knowledgeSourceId: string;
|
|
42
|
-
knowledgeChunkId: string;
|
|
43
|
-
}[];
|
|
39
|
+
chunkIds: string[];
|
|
44
40
|
}
|
|
45
41
|
export interface SmartIntentResponse {
|
|
46
42
|
data: {
|
|
@@ -13,9 +13,11 @@ export function getContentsByKnowledgeBase({ cmsApi, flowBuilderPlugin, request,
|
|
|
13
13
|
if (!knowledgeBaseContent) {
|
|
14
14
|
return contents;
|
|
15
15
|
}
|
|
16
|
+
const sourceIds = knowledgeBaseContent.sourcesData.map(source => source.id);
|
|
16
17
|
if (flowBuilderPlugin.getKnowledgeBaseResponse &&
|
|
17
|
-
inputHasTextData(request.input)
|
|
18
|
-
|
|
18
|
+
inputHasTextData(request.input) &&
|
|
19
|
+
sourceIds.length > 0) {
|
|
20
|
+
const contentsWithKnowledgeResponse = yield getContentsWithKnowledgeResponse(flowBuilderPlugin.getKnowledgeBaseResponse, request, contents, sourceIds);
|
|
19
21
|
if (contentsWithKnowledgeResponse) {
|
|
20
22
|
return contentsWithKnowledgeResponse;
|
|
21
23
|
}
|
|
@@ -23,10 +25,10 @@ export function getContentsByKnowledgeBase({ cmsApi, flowBuilderPlugin, request,
|
|
|
23
25
|
return [];
|
|
24
26
|
});
|
|
25
27
|
}
|
|
26
|
-
function getContentsWithKnowledgeResponse(getKnowledgeBaseResponse, request,
|
|
28
|
+
function getContentsWithKnowledgeResponse(getKnowledgeBaseResponse, request, contents, sourceIds) {
|
|
27
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
const knowledgeBaseResponse = yield getKnowledgeBaseResponse(request, request.input.data,
|
|
29
|
-
yield trackKnowledgeBase(knowledgeBaseResponse, request);
|
|
30
|
+
const knowledgeBaseResponse = yield getKnowledgeBaseResponse(request, request.input.data, sourceIds);
|
|
31
|
+
yield trackKnowledgeBase(knowledgeBaseResponse, request, sourceIds);
|
|
30
32
|
if (!knowledgeBaseResponse.hasKnowledge ||
|
|
31
33
|
!knowledgeBaseResponse.isFaithuful) {
|
|
32
34
|
return undefined;
|
|
@@ -43,11 +45,11 @@ function updateContentsWithResponse(contents, response) {
|
|
|
43
45
|
return content;
|
|
44
46
|
});
|
|
45
47
|
}
|
|
46
|
-
function trackKnowledgeBase(response, request) {
|
|
48
|
+
function trackKnowledgeBase(response, request, sourceIds) {
|
|
47
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
50
|
const knowledgebaseInferenceId = response.inferenceId;
|
|
49
|
-
const knowledgebaseSourcesIds =
|
|
50
|
-
const knowledgebaseChunksIds = response.
|
|
51
|
+
const knowledgebaseSourcesIds = sourceIds;
|
|
52
|
+
const knowledgebaseChunksIds = response.chunkIds;
|
|
51
53
|
const knowledgebaseMessageId = request.input.message_id;
|
|
52
54
|
let knowledgebaseFailReason;
|
|
53
55
|
if (!response.isFaithuful) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knowledge-bases.js","sourceRoot":"","sources":["../../../src/action/knowledge-bases.ts"],"names":[],"mappings":";AAEA,OAAO,EAAe,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAG3C,MAAM,UAAgB,0BAA0B,CAAC,EAC/C,MAAM,EACN,iBAAiB,EACjB,OAAO,EACP,cAAc,GACK;;QACnB,MAAM,yBAAyB,GAAG,MAAM,CAAC,4BAA4B,EAAE,CAAA;QAEvE,IAAI,CAAC,yBAAyB,EAAE;YAC9B,OAAO,EAAE,CAAA;SACV;QAED,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,iBAAiB,CACxD,yBAAyB,EACzB,cAAc,CACf,CAAA;QAED,MAAM,oBAAoB,GAAG,QAAQ,CAAC,IAAI,CACxC,OAAO,CAAC,EAAE,CAAC,OAAO,YAAY,iBAAiB,CAC3B,CAAA;QAEtB,IAAI,CAAC,oBAAoB,EAAE;YACzB,OAAO,QAAQ,CAAA;SAChB;QAED,IACE,iBAAiB,CAAC,wBAAwB;YAC1C,gBAAgB,CAAC,OAAO,CAAC,KAAK,CAAC
|
|
1
|
+
{"version":3,"file":"knowledge-bases.js","sourceRoot":"","sources":["../../../src/action/knowledge-bases.ts"],"names":[],"mappings":";AAEA,OAAO,EAAe,iBAAiB,EAAE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AAsB;YACtB,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI;SAC9B,CAAC,CAAA;IACJ,CAAC;CAAA"}
|
|
@@ -7,6 +7,10 @@ export declare class FlowKnowledgeBase extends ContentFieldsBase {
|
|
|
7
7
|
sources: string[];
|
|
8
8
|
text: string;
|
|
9
9
|
inferenceId?: string;
|
|
10
|
+
sourcesData: {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
}[];
|
|
10
14
|
static fromHubtypeCMS(component: HtKnowledgeBaseNode): FlowKnowledgeBase;
|
|
11
15
|
toBotonic(id: string, request: ActionRequest): JSX.Element;
|
|
12
16
|
}
|
|
@@ -8,12 +8,13 @@ export class FlowKnowledgeBase extends ContentFieldsBase {
|
|
|
8
8
|
this.feedbackEnabled = false;
|
|
9
9
|
this.sources = [];
|
|
10
10
|
this.text = '';
|
|
11
|
+
this.sourcesData = [];
|
|
11
12
|
}
|
|
12
13
|
static fromHubtypeCMS(component) {
|
|
13
14
|
const newKnowledgeBase = new FlowKnowledgeBase(component.id);
|
|
14
15
|
newKnowledgeBase.code = component.code;
|
|
15
16
|
newKnowledgeBase.feedbackEnabled = component.content.feedback_enabled;
|
|
16
|
-
newKnowledgeBase.
|
|
17
|
+
newKnowledgeBase.sourcesData = component.content.sources_data;
|
|
17
18
|
return newKnowledgeBase;
|
|
18
19
|
}
|
|
19
20
|
toBotonic(id, request) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-knowledge-base.js","sourceRoot":"","sources":["../../../src/content-fields/flow-knowledge-base.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAiB,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAGpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAGzD,MAAM,OAAO,iBAAkB,SAAQ,iBAAiB;IAAxD;;QACS,SAAI,GAAW,EAAE,CAAA;QACjB,oBAAe,GAAY,KAAK,CAAA;QAChC,YAAO,GAAa,EAAE,CAAA;QACtB,SAAI,GAAW,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"flow-knowledge-base.js","sourceRoot":"","sources":["../../../src/content-fields/flow-knowledge-base.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAiB,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAGpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAGzD,MAAM,OAAO,iBAAkB,SAAQ,iBAAiB;IAAxD;;QACS,SAAI,GAAW,EAAE,CAAA;QACjB,oBAAe,GAAY,KAAK,CAAA;QAChC,YAAO,GAAa,EAAE,CAAA;QACtB,SAAI,GAAW,EAAE,CAAA;QAEjB,gBAAW,GAAmC,EAAE,CAAA;IAuBzD,CAAC;IArBC,MAAM,CAAC,cAAc,CAAC,SAA8B;QAClD,MAAM,gBAAgB,GAAG,IAAI,iBAAiB,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QAC5D,gBAAgB,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAA;QACtC,gBAAgB,CAAC,eAAe,GAAG,SAAS,CAAC,OAAO,CAAC,gBAAgB,CAAA;QACrE,gBAAgB,CAAC,WAAW,GAAG,SAAS,CAAC,OAAO,CAAC,YAAY,CAAA;QAE7D,OAAO,gBAAgB,CAAA;IACzB,CAAC;IAED,SAAS,CAAC,EAAU,EAAE,OAAsB;QAC1C,OAAO,CACL,KAAC,IAAI,kBAEH,eAAe,EAAE,IAAI,CAAC,eAAe,EACrC,WAAW,EAAE,IAAI,CAAC,WAAW,EAC7B,gBAAgB,EAAE,OAAO,CAAC,KAAK,CAAC,kBAAkB,gBAEjD,IAAI,CAAC,IAAI,KALL,EAAE,CAMF,CACR,CAAA;IACH,CAAC;CACF"}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { HtBaseNode } from './common';
|
|
2
2
|
import { HtNodeWithContentType } from './node-types';
|
|
3
|
+
interface SourceData {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
3
7
|
export interface HtKnowledgeBaseNode extends HtBaseNode {
|
|
4
8
|
type: HtNodeWithContentType.KNOWLEDGE_BASE;
|
|
5
9
|
content: {
|
|
6
10
|
feedback_enabled: boolean;
|
|
7
|
-
|
|
11
|
+
sources_data: SourceData[];
|
|
8
12
|
};
|
|
9
13
|
}
|
|
14
|
+
export {};
|
package/lib/esm/types.d.ts
CHANGED
|
@@ -36,11 +36,7 @@ export interface KnowledgeBaseResponse {
|
|
|
36
36
|
answer: string;
|
|
37
37
|
hasKnowledge: boolean;
|
|
38
38
|
isFaithuful: boolean;
|
|
39
|
-
|
|
40
|
-
knowledgeBaseId: string;
|
|
41
|
-
knowledgeSourceId: string;
|
|
42
|
-
knowledgeChunkId: string;
|
|
43
|
-
}[];
|
|
39
|
+
chunkIds: string[];
|
|
44
40
|
}
|
|
45
41
|
export interface SmartIntentResponse {
|
|
46
42
|
data: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botonic/plugin-flow-builder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.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": "^0.
|
|
17
|
+
"@botonic/react": "^0.29.0",
|
|
18
18
|
"axios": "^1.7.2",
|
|
19
19
|
"uuid": "^9.0.1"
|
|
20
20
|
},
|
|
@@ -31,16 +31,19 @@ export async function getContentsByKnowledgeBase({
|
|
|
31
31
|
return contents
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
const sourceIds = knowledgeBaseContent.sourcesData.map(source => source.id)
|
|
35
|
+
|
|
34
36
|
if (
|
|
35
37
|
flowBuilderPlugin.getKnowledgeBaseResponse &&
|
|
36
|
-
inputHasTextData(request.input)
|
|
38
|
+
inputHasTextData(request.input) &&
|
|
39
|
+
sourceIds.length > 0
|
|
37
40
|
) {
|
|
38
41
|
const contentsWithKnowledgeResponse =
|
|
39
42
|
await getContentsWithKnowledgeResponse(
|
|
40
43
|
flowBuilderPlugin.getKnowledgeBaseResponse,
|
|
41
44
|
request,
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
contents,
|
|
46
|
+
sourceIds
|
|
44
47
|
)
|
|
45
48
|
|
|
46
49
|
if (contentsWithKnowledgeResponse) {
|
|
@@ -54,15 +57,15 @@ export async function getContentsByKnowledgeBase({
|
|
|
54
57
|
async function getContentsWithKnowledgeResponse(
|
|
55
58
|
getKnowledgeBaseResponse: KnowledgeBaseFunction,
|
|
56
59
|
request: ActionRequest,
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
contents: FlowContent[],
|
|
61
|
+
sourceIds: string[]
|
|
59
62
|
): Promise<FlowContent[] | undefined> {
|
|
60
63
|
const knowledgeBaseResponse = await getKnowledgeBaseResponse(
|
|
61
64
|
request,
|
|
62
65
|
request.input.data!,
|
|
63
|
-
|
|
66
|
+
sourceIds
|
|
64
67
|
)
|
|
65
|
-
await trackKnowledgeBase(knowledgeBaseResponse, request)
|
|
68
|
+
await trackKnowledgeBase(knowledgeBaseResponse, request, sourceIds)
|
|
66
69
|
|
|
67
70
|
if (
|
|
68
71
|
!knowledgeBaseResponse.hasKnowledge ||
|
|
@@ -90,15 +93,12 @@ function updateContentsWithResponse(
|
|
|
90
93
|
|
|
91
94
|
async function trackKnowledgeBase(
|
|
92
95
|
response: KnowledgeBaseResponse,
|
|
93
|
-
request: ActionRequest
|
|
96
|
+
request: ActionRequest,
|
|
97
|
+
sourceIds: string[]
|
|
94
98
|
) {
|
|
95
99
|
const knowledgebaseInferenceId = response.inferenceId
|
|
96
|
-
const knowledgebaseSourcesIds =
|
|
97
|
-
|
|
98
|
-
)
|
|
99
|
-
const knowledgebaseChunksIds = response.sources.map(
|
|
100
|
-
source => source.knowledgeChunkId
|
|
101
|
-
)
|
|
100
|
+
const knowledgebaseSourcesIds = sourceIds
|
|
101
|
+
const knowledgebaseChunksIds = response.chunkIds
|
|
102
102
|
const knowledgebaseMessageId = request.input.message_id
|
|
103
103
|
|
|
104
104
|
let knowledgebaseFailReason: KnowledgebaseFailReason | undefined
|
|
@@ -10,12 +10,13 @@ export class FlowKnowledgeBase extends ContentFieldsBase {
|
|
|
10
10
|
public sources: string[] = []
|
|
11
11
|
public text: string = ''
|
|
12
12
|
public inferenceId?: string
|
|
13
|
+
public sourcesData: { id: string; name: string }[] = []
|
|
13
14
|
|
|
14
15
|
static fromHubtypeCMS(component: HtKnowledgeBaseNode): FlowKnowledgeBase {
|
|
15
16
|
const newKnowledgeBase = new FlowKnowledgeBase(component.id)
|
|
16
17
|
newKnowledgeBase.code = component.code
|
|
17
18
|
newKnowledgeBase.feedbackEnabled = component.content.feedback_enabled
|
|
18
|
-
newKnowledgeBase.
|
|
19
|
+
newKnowledgeBase.sourcesData = component.content.sources_data
|
|
19
20
|
|
|
20
21
|
return newKnowledgeBase
|
|
21
22
|
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { HtBaseNode } from './common'
|
|
2
2
|
import { HtNodeWithContentType } from './node-types'
|
|
3
3
|
|
|
4
|
+
interface SourceData {
|
|
5
|
+
id: string
|
|
6
|
+
name: string
|
|
7
|
+
}
|
|
8
|
+
|
|
4
9
|
export interface HtKnowledgeBaseNode extends HtBaseNode {
|
|
5
10
|
type: HtNodeWithContentType.KNOWLEDGE_BASE
|
|
6
11
|
content: {
|
|
7
12
|
feedback_enabled: boolean
|
|
8
|
-
|
|
13
|
+
sources_data: SourceData[]
|
|
9
14
|
}
|
|
10
15
|
}
|
package/src/types.ts
CHANGED
|
@@ -50,11 +50,7 @@ export interface KnowledgeBaseResponse {
|
|
|
50
50
|
answer: string
|
|
51
51
|
hasKnowledge: boolean
|
|
52
52
|
isFaithuful: boolean
|
|
53
|
-
|
|
54
|
-
knowledgeBaseId: string
|
|
55
|
-
knowledgeSourceId: string
|
|
56
|
-
knowledgeChunkId: string
|
|
57
|
-
}[]
|
|
53
|
+
chunkIds: string[]
|
|
58
54
|
}
|
|
59
55
|
|
|
60
56
|
export interface SmartIntentResponse {
|