@botonic/plugin-flow-builder 0.54.0-alpha.0 → 0.55.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.
Files changed (105) hide show
  1. package/lib/cjs/action/first-interaction.js +1 -11
  2. package/lib/cjs/action/first-interaction.js.map +1 -1
  3. package/lib/cjs/action/get-contents.js +0 -5
  4. package/lib/cjs/action/get-contents.js.map +1 -1
  5. package/lib/cjs/api.d.ts +0 -6
  6. package/lib/cjs/api.js +0 -19
  7. package/lib/cjs/api.js.map +1 -1
  8. package/lib/cjs/constants.d.ts +0 -1
  9. package/lib/cjs/constants.js +1 -2
  10. package/lib/cjs/constants.js.map +1 -1
  11. package/lib/cjs/content-fields/hubtype-fields/common.d.ts +0 -1
  12. package/lib/cjs/content-fields/hubtype-fields/fallback.d.ts +0 -2
  13. package/lib/cjs/content-fields/hubtype-fields/index.d.ts +0 -1
  14. package/lib/cjs/content-fields/hubtype-fields/index.js +0 -1
  15. package/lib/cjs/content-fields/hubtype-fields/index.js.map +1 -1
  16. package/lib/cjs/content-fields/hubtype-fields/node-types.d.ts +0 -1
  17. package/lib/cjs/content-fields/hubtype-fields/node-types.js +0 -1
  18. package/lib/cjs/content-fields/hubtype-fields/node-types.js.map +1 -1
  19. package/lib/cjs/content-fields/hubtype-fields/nodes.d.ts +1 -2
  20. package/lib/cjs/content-fields/index.d.ts +2 -4
  21. package/lib/cjs/content-fields/index.js +1 -4
  22. package/lib/cjs/content-fields/index.js.map +1 -1
  23. package/lib/cjs/flow-factory.js +0 -2
  24. package/lib/cjs/flow-factory.js.map +1 -1
  25. package/lib/cjs/index.d.ts +1 -2
  26. package/lib/cjs/index.js +0 -2
  27. package/lib/cjs/index.js.map +1 -1
  28. package/lib/cjs/tracking.js +1 -2
  29. package/lib/cjs/tracking.js.map +1 -1
  30. package/lib/cjs/types.d.ts +1 -4
  31. package/lib/cjs/types.js.map +1 -1
  32. package/lib/cjs/utils/input.d.ts +0 -1
  33. package/lib/cjs/utils/input.js +0 -4
  34. package/lib/cjs/utils/input.js.map +1 -1
  35. package/lib/esm/action/first-interaction.js +1 -11
  36. package/lib/esm/action/first-interaction.js.map +1 -1
  37. package/lib/esm/action/get-contents.js +0 -5
  38. package/lib/esm/action/get-contents.js.map +1 -1
  39. package/lib/esm/api.d.ts +0 -6
  40. package/lib/esm/api.js +0 -19
  41. package/lib/esm/api.js.map +1 -1
  42. package/lib/esm/constants.d.ts +0 -1
  43. package/lib/esm/constants.js +1 -2
  44. package/lib/esm/constants.js.map +1 -1
  45. package/lib/esm/content-fields/hubtype-fields/common.d.ts +0 -1
  46. package/lib/esm/content-fields/hubtype-fields/fallback.d.ts +0 -2
  47. package/lib/esm/content-fields/hubtype-fields/index.d.ts +0 -1
  48. package/lib/esm/content-fields/hubtype-fields/index.js +0 -1
  49. package/lib/esm/content-fields/hubtype-fields/index.js.map +1 -1
  50. package/lib/esm/content-fields/hubtype-fields/node-types.d.ts +0 -1
  51. package/lib/esm/content-fields/hubtype-fields/node-types.js +0 -1
  52. package/lib/esm/content-fields/hubtype-fields/node-types.js.map +1 -1
  53. package/lib/esm/content-fields/hubtype-fields/nodes.d.ts +1 -2
  54. package/lib/esm/content-fields/index.d.ts +2 -4
  55. package/lib/esm/content-fields/index.js +1 -4
  56. package/lib/esm/content-fields/index.js.map +1 -1
  57. package/lib/esm/flow-factory.js +0 -2
  58. package/lib/esm/flow-factory.js.map +1 -1
  59. package/lib/esm/index.d.ts +1 -2
  60. package/lib/esm/index.js +0 -2
  61. package/lib/esm/index.js.map +1 -1
  62. package/lib/esm/tracking.js +1 -2
  63. package/lib/esm/tracking.js.map +1 -1
  64. package/lib/esm/types.d.ts +1 -4
  65. package/lib/esm/types.js.map +1 -1
  66. package/lib/esm/utils/input.d.ts +0 -1
  67. package/lib/esm/utils/input.js +0 -4
  68. package/lib/esm/utils/input.js.map +1 -1
  69. package/package.json +2 -2
  70. package/src/action/first-interaction.ts +1 -13
  71. package/src/action/get-contents.ts +0 -5
  72. package/src/api.ts +1 -35
  73. package/src/constants.ts +0 -1
  74. package/src/content-fields/hubtype-fields/common.ts +0 -1
  75. package/src/content-fields/hubtype-fields/fallback.ts +0 -2
  76. package/src/content-fields/hubtype-fields/index.ts +0 -1
  77. package/src/content-fields/hubtype-fields/node-types.ts +0 -1
  78. package/src/content-fields/hubtype-fields/nodes.ts +0 -2
  79. package/src/content-fields/index.ts +0 -8
  80. package/src/flow-factory.ts +0 -4
  81. package/src/index.ts +0 -4
  82. package/src/tracking.ts +1 -4
  83. package/src/types.ts +0 -14
  84. package/src/utils/input.ts +0 -4
  85. package/lib/cjs/action/knowledge-bases.d.ts +0 -3
  86. package/lib/cjs/action/knowledge-bases.js +0 -85
  87. package/lib/cjs/action/knowledge-bases.js.map +0 -1
  88. package/lib/cjs/content-fields/flow-knowledge-base.d.ts +0 -21
  89. package/lib/cjs/content-fields/flow-knowledge-base.js +0 -44
  90. package/lib/cjs/content-fields/flow-knowledge-base.js.map +0 -1
  91. package/lib/cjs/content-fields/hubtype-fields/knowledge-base.d.ts +0 -17
  92. package/lib/cjs/content-fields/hubtype-fields/knowledge-base.js +0 -3
  93. package/lib/cjs/content-fields/hubtype-fields/knowledge-base.js.map +0 -1
  94. package/lib/esm/action/knowledge-bases.d.ts +0 -3
  95. package/lib/esm/action/knowledge-bases.js +0 -85
  96. package/lib/esm/action/knowledge-bases.js.map +0 -1
  97. package/lib/esm/content-fields/flow-knowledge-base.d.ts +0 -21
  98. package/lib/esm/content-fields/flow-knowledge-base.js +0 -44
  99. package/lib/esm/content-fields/flow-knowledge-base.js.map +0 -1
  100. package/lib/esm/content-fields/hubtype-fields/knowledge-base.d.ts +0 -17
  101. package/lib/esm/content-fields/hubtype-fields/knowledge-base.js +0 -3
  102. package/lib/esm/content-fields/hubtype-fields/knowledge-base.js.map +0 -1
  103. package/src/action/knowledge-bases.ts +0 -164
  104. package/src/content-fields/flow-knowledge-base.tsx +0 -58
  105. package/src/content-fields/hubtype-fields/knowledge-base.ts +0 -18
package/src/api.ts CHANGED
@@ -1,12 +1,7 @@
1
1
  import type { PluginPreRequest } from '@botonic/core'
2
2
  import axios from 'axios'
3
3
 
4
- import {
5
- AI_AGENTS_FLOW_NAME,
6
- KNOWLEDGE_BASE_FLOW_NAME,
7
- SEPARATOR,
8
- UUID_REGEXP,
9
- } from './constants'
4
+ import { AI_AGENTS_FLOW_NAME, SEPARATOR, UUID_REGEXP } from './constants'
10
5
  import {
11
6
  type HtBotActionNode,
12
7
  type HtCaptureUserInputNode,
@@ -162,21 +157,6 @@ export class FlowBuilderApi {
162
157
  : this.getNodeById(fallbackSecondMessage.id)
163
158
  }
164
159
 
165
- getKnowledgeBaseConfig():
166
- | { followup?: HtNodeLink; isActive: boolean }
167
- | undefined {
168
- const fallbackNode = this.flow.nodes.find(
169
- node => node.type === HtNodeWithContentType.FALLBACK
170
- ) as HtFallbackNode | undefined
171
-
172
- return fallbackNode
173
- ? {
174
- followup: fallbackNode.content.knowledge_base_followup,
175
- isActive: fallbackNode.content.is_knowledge_base_active || false,
176
- }
177
- : undefined
178
- }
179
-
180
160
  getSmartIntentNodes(): HtSmartIntentNode[] {
181
161
  return this.flow.nodes.filter(
182
162
  node => node.type === HtNodeWithContentType.SMART_INTENT
@@ -254,16 +234,6 @@ export class FlowBuilderApi {
254
234
  return campaign ? campaign.name : ''
255
235
  }
256
236
 
257
- getStartNodeKnowledgeBaseFlow(): HtNodeWithContent | undefined {
258
- const knowledgeBaseFlow = this.flow.flows.find(
259
- flow => flow.name === KNOWLEDGE_BASE_FLOW_NAME
260
- )
261
- if (!knowledgeBaseFlow) {
262
- return undefined
263
- }
264
- return this.getNodeById<HtNodeWithContent>(knowledgeBaseFlow.start_node_id)
265
- }
266
-
267
237
  getStartNodeAiAgentFlow(): HtNodeWithContent | undefined {
268
238
  const aiAgentFlow = this.flow.flows.find(
269
239
  flow => flow.name === AI_AGENTS_FLOW_NAME
@@ -276,10 +246,6 @@ export class FlowBuilderApi {
276
246
  return this.getNodeById<HtNodeWithContent>(aiAgentFlow.start_node_id)
277
247
  }
278
248
 
279
- isKnowledgeBaseEnabled(): boolean {
280
- return this.flow.is_knowledge_base_active || false
281
- }
282
-
283
249
  isAiAgentEnabled(): boolean {
284
250
  return this.flow.is_ai_agent_active || false
285
251
  }
package/src/constants.ts CHANGED
@@ -15,6 +15,5 @@ export const PUSH_FLOW_PAYLOAD = 'push-flow'
15
15
 
16
16
  /* ********** FLOW NAMES ********** */
17
17
  export const MAIN_FLOW_NAME = 'Main'
18
- export const KNOWLEDGE_BASE_FLOW_NAME = 'Knowledge base'
19
18
  export const AI_AGENTS_FLOW_NAME = 'AI Agents'
20
19
  export const FALLBACK_FLOW_NAME = 'Fallback'
@@ -11,7 +11,6 @@ export interface HtFlowBuilderData {
11
11
  default_locale_code: string
12
12
  start_node_id?: string
13
13
  ai_model_id?: string
14
- is_knowledge_base_active?: boolean
15
14
  is_ai_agent_active?: boolean
16
15
  nodes: HtNodeComponent[]
17
16
  flows: HtFlows[]
@@ -6,7 +6,5 @@ export interface HtFallbackNode extends HtBaseNode {
6
6
  content: {
7
7
  first_message?: HtNodeLink
8
8
  second_message?: HtNodeLink
9
- knowledge_base_followup?: HtNodeLink
10
- is_knowledge_base_active?: boolean
11
9
  }
12
10
  }
@@ -12,7 +12,6 @@ export * from './go-to-flow'
12
12
  export * from './handoff'
13
13
  export * from './image'
14
14
  export * from './keyword'
15
- export * from './knowledge-base'
16
15
  export * from './node-types'
17
16
  export * from './nodes'
18
17
  export * from './payload'
@@ -11,7 +11,6 @@ export enum HtNodeWithContentType {
11
11
  WHATSAPP_BUTTON_LIST = 'whatsapp-button-list',
12
12
  WHATSAPP_CTA_URL_BUTTON = 'whatsapp-cta-url-button',
13
13
  WHATSAPP_TEMPLATE = 'whatsapp-template',
14
- KNOWLEDGE_BASE = 'knowledge-base',
15
14
  BOT_ACTION = 'bot-action',
16
15
  AI_AGENT = 'ai-agent',
17
16
  AI_AGENT_ROUTER = 'ai-agent-router',
@@ -13,7 +13,6 @@ import type { HtGoToFlow } from './go-to-flow'
13
13
  import type { HtHandoffNode } from './handoff'
14
14
  import type { HtImageNode } from './image'
15
15
  import type { HtKeywordNode } from './keyword'
16
- import type { HtKnowledgeBaseNode } from './knowledge-base'
17
16
  import type { HtPayloadNode } from './payload'
18
17
  // import { HtQueueStatusConditionalNode } from './queue-status-conditional'
19
18
  import type { HtRatingNode } from './rating'
@@ -38,7 +37,6 @@ export type HtNodeWithContent =
38
37
  | HtWhatsappButtonListNode
39
38
  | HtWhatsappCTAUrlButtonNode
40
39
  | HtSmartIntentNode
41
- | HtKnowledgeBaseNode
42
40
  | HtBotActionNode
43
41
  | HtAiAgentNode
44
42
  | HtAiAgentRouterNode
@@ -10,10 +10,6 @@ import { FlowCustomConditional } from './flow-custom-conditional'
10
10
  import { FlowGoToFlow } from './flow-go-to-flow'
11
11
  import { FlowHandoff } from './flow-handoff'
12
12
  import { FlowImage } from './flow-image'
13
- import {
14
- DISABLED_MEMORY_LENGTH,
15
- FlowKnowledgeBase,
16
- } from './flow-knowledge-base'
17
13
  import { FlowQueueStatusConditional } from './flow-queue-status-conditional'
18
14
  import { FlowRating } from './flow-rating'
19
15
  import { FlowText } from './flow-text'
@@ -41,7 +37,6 @@ export {
41
37
  FlowGoToFlow,
42
38
  FlowHandoff,
43
39
  FlowImage,
44
- FlowKnowledgeBase,
45
40
  FlowQueueStatusConditional,
46
41
  FlowRating,
47
42
  FlowText,
@@ -63,7 +58,6 @@ export type FlowContent =
63
58
  | FlowWhatsappCtaUrlButtonNode
64
59
  | FlowWhatsappTemplate
65
60
  | FlowHandoff
66
- | FlowKnowledgeBase
67
61
  | FlowBotAction
68
62
  | FlowAiAgent
69
63
  | FlowRating
@@ -75,5 +69,3 @@ export type FlowContent =
75
69
  | FlowCaptureUserInput
76
70
  | FlowAiAgentRouter
77
71
  | FlowCustomConditionalV2
78
-
79
- export { DISABLED_MEMORY_LENGTH }
@@ -14,7 +14,6 @@ import {
14
14
  FlowGoToFlow,
15
15
  FlowHandoff,
16
16
  FlowImage,
17
- FlowKnowledgeBase,
18
17
  FlowQueueStatusConditional,
19
18
  FlowRating,
20
19
  FlowText,
@@ -83,9 +82,6 @@ export class FlowFactory {
83
82
  this.cmsApi
84
83
  )
85
84
 
86
- case HtNodeWithContentType.KNOWLEDGE_BASE:
87
- return FlowKnowledgeBase.fromHubtypeCMS(hubtypeContent)
88
-
89
85
  case HtNodeWithContentType.AI_AGENT_ROUTER:
90
86
  return FlowAiAgentRouter.fromHubtypeCMS(hubtypeContent, this.botContext)
91
87
 
package/src/index.ts CHANGED
@@ -31,7 +31,6 @@ import {
31
31
  type ContentFilter,
32
32
  FlowBuilderJSONVersion,
33
33
  type InShadowingConfig,
34
- type KnowledgeBaseFunction,
35
34
  type PayloadParamsBase,
36
35
  type RatingSubmittedInfo,
37
36
  type TrackEventFunction,
@@ -50,7 +49,6 @@ export default class BotonicPluginFlowBuilder implements Plugin {
50
49
  private currentRequest: PluginPreRequest
51
50
  public getAccessToken: (session: Session) => string
52
51
  public trackEvent?: TrackEventFunction
53
- public getKnowledgeBaseResponse?: KnowledgeBaseFunction
54
52
  public getAiAgentResponse?: AiAgentFunction
55
53
  public smartIntentsConfig: SmartIntentsInferenceConfig
56
54
  public inShadowing: InShadowingConfig
@@ -68,7 +66,6 @@ export default class BotonicPluginFlowBuilder implements Plugin {
68
66
  this.flow = options.flow
69
67
  this.getAccessToken = resolveGetAccessToken(options.getAccessToken)
70
68
  this.trackEvent = options.trackEvent
71
- this.getKnowledgeBaseResponse = options.getKnowledgeBaseResponse
72
69
  this.getAiAgentResponse = options.getAiAgentResponse
73
70
  this.smartIntentsConfig = {
74
71
  ...options?.smartIntentsConfig,
@@ -79,7 +76,6 @@ export default class BotonicPluginFlowBuilder implements Plugin {
79
76
  this.inShadowing = {
80
77
  allowKeywords: options.inShadowing?.allowKeywords || false,
81
78
  allowSmartIntents: options.inShadowing?.allowSmartIntents || false,
82
- allowKnowledgeBases: options.inShadowing?.allowKnowledgeBases || false,
83
79
  allowAiAgents: options.inShadowing?.allowAiAgents || false,
84
80
  }
85
81
  this.contentFilters = options.contentFilters || []
package/src/tracking.ts CHANGED
@@ -44,10 +44,7 @@ export async function trackOneContent(
44
44
  }
45
45
 
46
46
  const nodeContent = cmsApi.getNodeById<HtNodeWithContent>(content.id)
47
- if (
48
- nodeContent.type !== HtNodeWithContentType.KNOWLEDGE_BASE &&
49
- nodeContent.type !== HtNodeWithContentType.AI_AGENT
50
- ) {
47
+ if (nodeContent.type !== HtNodeWithContentType.AI_AGENT) {
51
48
  const event = getContentEventArgs(request, nodeContent)
52
49
  const { action, ...eventArgs } = event
53
50
  await trackEvent(request, action, eventArgs)
package/src/types.ts CHANGED
@@ -3,7 +3,6 @@ import {
3
3
  type BotContext,
4
4
  GuardrailRule,
5
5
  type InferenceResponse,
6
- type KnowledgeBasesResponse,
7
6
  type PluginPreRequest,
8
7
  type ResolvedPlugins,
9
8
  } from '@botonic/core'
@@ -17,7 +16,6 @@ import type { FlowBuilderContentMessage } from './structured-output/flow-builder
17
16
  export interface InShadowingConfig {
18
17
  allowKeywords: boolean
19
18
  allowSmartIntents: boolean
20
- allowKnowledgeBases: boolean
21
19
  allowAiAgents: boolean
22
20
  }
23
21
 
@@ -31,7 +29,6 @@ export interface BotonicPluginFlowBuilderOptions<
31
29
  customFunctions?: Record<any, any>
32
30
  getAccessToken: () => string
33
31
  trackEvent?: TrackEventFunction<TPlugins, TExtraData>
34
- getKnowledgeBaseResponse?: KnowledgeBaseFunction<TPlugins, TExtraData>
35
32
  getAiAgentResponse?: AiAgentFunction<TPlugins, TExtraData>
36
33
  smartIntentsConfig?: { numSmartIntentsToUse: number }
37
34
  inShadowing?: Partial<InShadowingConfig>
@@ -49,17 +46,6 @@ export type TrackEventFunction<
49
46
  args?: Record<string, any>
50
47
  ) => Promise<void>
51
48
 
52
- export type KnowledgeBaseFunction<
53
- TPlugins extends ResolvedPlugins = ResolvedPlugins,
54
- TExtraData = any,
55
- > = (
56
- request: BotContext<TPlugins, TExtraData>,
57
- sources: string[],
58
- instructions: string,
59
- messageId: string,
60
- memoryLength: number
61
- ) => Promise<KnowledgeBasesResponse>
62
-
63
49
  export type AiAgentFunction<
64
50
  TPlugins extends ResolvedPlugins = ResolvedPlugins,
65
51
  TExtraData = any,
@@ -40,7 +40,3 @@ export function isKeywordsAllowed(request: ActionRequest): boolean {
40
40
  export function isSmartIntentsAllowed(request: ActionRequest): boolean {
41
41
  return isNluAllowed(request, 'allowSmartIntents')
42
42
  }
43
-
44
- export function isKnowledgeBasesAllowed(request: ActionRequest): boolean {
45
- return isNluAllowed(request, 'allowKnowledgeBases')
46
- }
@@ -1,3 +0,0 @@
1
- import { type FlowContent } from '../content-fields';
2
- import type { FlowBuilderContext } from './context';
3
- export declare function getContentsByKnowledgeBase({ cmsApi, flowBuilderPlugin, request, }: FlowBuilderContext): Promise<FlowContent[]>;
@@ -1,85 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getContentsByKnowledgeBase = getContentsByKnowledgeBase;
4
- const core_1 = require("@botonic/core");
5
- const content_fields_1 = require("../content-fields");
6
- const tracking_1 = require("../tracking");
7
- const input_1 = require("../utils/input");
8
- async function getContentsByKnowledgeBase({ cmsApi, flowBuilderPlugin, request, }) {
9
- if ((0, input_1.isKnowledgeBasesAllowed)(request)) {
10
- const startNodeKnowledgeBaseFlow = cmsApi.getStartNodeKnowledgeBaseFlow();
11
- const isKnowledgeBaseEnabled = cmsApi.isKnowledgeBaseEnabled();
12
- if (!startNodeKnowledgeBaseFlow || !isKnowledgeBaseEnabled) {
13
- return [];
14
- }
15
- const contents = await flowBuilderPlugin.getContentsByNode(startNodeKnowledgeBaseFlow);
16
- const knowledgeBaseContent = contents.find(content => content instanceof content_fields_1.FlowKnowledgeBase);
17
- if (!knowledgeBaseContent) {
18
- return contents;
19
- }
20
- const sourceIds = knowledgeBaseContent.sourcesData.map(source => source.id);
21
- if (flowBuilderPlugin.getKnowledgeBaseResponse &&
22
- (0, input_1.inputHasTextOrTranscript)(request.input) &&
23
- sourceIds.length > 0) {
24
- const contentsWithKnowledgeResponse = await getContentsWithKnowledgeResponse(flowBuilderPlugin.getKnowledgeBaseResponse, request, contents, knowledgeBaseContent);
25
- if (contentsWithKnowledgeResponse) {
26
- return contentsWithKnowledgeResponse;
27
- }
28
- }
29
- }
30
- return [];
31
- }
32
- async function getContentsWithKnowledgeResponse(getKnowledgeBaseResponse, request, contents, knowledgeBaseContent) {
33
- const sourceIds = knowledgeBaseContent.sourcesData.map(source => source.id);
34
- const instructions = knowledgeBaseContent.instructions;
35
- const messageId = request.input.message_id;
36
- const memoryLength = knowledgeBaseContent.hasMemory
37
- ? knowledgeBaseContent.memoryLength
38
- : content_fields_1.DISABLED_MEMORY_LENGTH;
39
- const knowledgeBaseResponse = await getKnowledgeBaseResponse(request, sourceIds, instructions, messageId, memoryLength);
40
- await trackKnowledgeBase(knowledgeBaseResponse, request, knowledgeBaseContent);
41
- if (!knowledgeBaseResponse.hasKnowledge ||
42
- !knowledgeBaseResponse.isFaithful) {
43
- return undefined;
44
- }
45
- return updateContentsWithResponse(contents, knowledgeBaseResponse);
46
- }
47
- function updateContentsWithResponse(contents, response) {
48
- return contents.map(content => {
49
- if (content instanceof content_fields_1.FlowKnowledgeBase) {
50
- content.text = response.answer;
51
- content.inferenceId = response.inferenceId;
52
- }
53
- return content;
54
- });
55
- }
56
- async function trackKnowledgeBase(response, request, knowledgeBaseContent) {
57
- const getKnowledgeFailReason = () => {
58
- let knowledgebaseFailReason;
59
- if (!response.isFaithful) {
60
- knowledgebaseFailReason = core_1.KnowledgebaseFailReason.Hallucination;
61
- }
62
- if (!response.hasKnowledge) {
63
- knowledgebaseFailReason = core_1.KnowledgebaseFailReason.NoKnowledge;
64
- }
65
- return knowledgebaseFailReason;
66
- };
67
- const { flowId, flowName, flowNodeId, flowNodeContentId } = (0, tracking_1.getCommonFlowContentEventArgsForContentId)(request, knowledgeBaseContent.id);
68
- const event = {
69
- action: core_1.EventAction.Knowledgebase,
70
- knowledgebaseInferenceId: response.inferenceId,
71
- knowledgebaseFailReason: getKnowledgeFailReason(),
72
- knowledgebaseSourcesIds: knowledgeBaseContent.sourcesData.map(source => source.id),
73
- knowledgebaseChunksIds: response.chunkIds,
74
- knowledgebaseMessageId: request.input.message_id,
75
- userInput: request.input.data,
76
- flowThreadId: request.session.flow_thread_id,
77
- flowId,
78
- flowName,
79
- flowNodeId,
80
- flowNodeContentId,
81
- };
82
- const { action, ...eventArgs } = event;
83
- await (0, tracking_1.trackEvent)(request, action, eventArgs);
84
- }
85
- //# sourceMappingURL=knowledge-bases.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"knowledge-bases.js","sourceRoot":"","sources":["../../../src/action/knowledge-bases.ts"],"names":[],"mappings":";;AAyBA,gEA+CC;AAxED,wCAOsB;AAEtB,sDAI0B;AAC1B,0CAGoB;AAEpB,0CAGuB;AAGhB,KAAK,UAAU,0BAA0B,CAAC,EAC/C,MAAM,EACN,iBAAiB,EACjB,OAAO,GACY;IACnB,IAAI,IAAA,+BAAuB,EAAC,OAAO,CAAC,EAAE,CAAC;QACrC,MAAM,0BAA0B,GAAG,MAAM,CAAC,6BAA6B,EAAE,CAAA;QACzE,MAAM,sBAAsB,GAAG,MAAM,CAAC,sBAAsB,EAAE,CAAA;QAE9D,IAAI,CAAC,0BAA0B,IAAI,CAAC,sBAAsB,EAAE,CAAC;YAC3D,OAAO,EAAE,CAAA;QACX,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,iBAAiB,CACxD,0BAA0B,CAC3B,CAAA;QAED,MAAM,oBAAoB,GAAG,QAAQ,CAAC,IAAI,CACxC,OAAO,CAAC,EAAE,CAAC,OAAO,YAAY,kCAAiB,CAC3B,CAAA;QAEtB,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC1B,OAAO,QAAQ,CAAA;QACjB,CAAC;QAED,MAAM,SA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O,CAAC,KAAK,CAAC,UAAU;QAChD,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,IAAc;QACvC,YAAY,EAAE,OAAO,CAAC,OAAO,CAAC,cAAwB;QACtD,MAAM;QACN,QAAQ;QACR,UAAU;QACV,iBAAiB;KAClB,CAAA;IAED,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAA;IAEtC,MAAM,IAAA,qBAAU,EAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAAA;AAC9C,CAAC"}
@@ -1,21 +0,0 @@
1
- import type { BotContext } from '@botonic/core';
2
- import { ContentFieldsBase } from './content-fields-base';
3
- import type { HtKnowledgeBaseNode } from './hubtype-fields';
4
- export declare const DISABLED_MEMORY_LENGTH = 1;
5
- export declare class FlowKnowledgeBase extends ContentFieldsBase {
6
- feedbackEnabled: boolean;
7
- sources: string[];
8
- text: string;
9
- inferenceId?: string;
10
- sourcesData: {
11
- id: string;
12
- name: string;
13
- }[];
14
- instructions: string;
15
- hasMemory: boolean;
16
- memoryLength: number;
17
- static fromHubtypeCMS(component: HtKnowledgeBaseNode): FlowKnowledgeBase;
18
- trackFlow(_botContext: BotContext): Promise<void>;
19
- processContent(botContext: BotContext): Promise<void>;
20
- toBotonic(botContext: BotContext): JSX.Element;
21
- }
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FlowKnowledgeBase = exports.DISABLED_MEMORY_LENGTH = void 0;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("@botonic/react");
6
- const content_fields_base_1 = require("./content-fields-base");
7
- exports.DISABLED_MEMORY_LENGTH = 1;
8
- class FlowKnowledgeBase extends content_fields_base_1.ContentFieldsBase {
9
- constructor() {
10
- super(...arguments);
11
- this.feedbackEnabled = false;
12
- this.sources = [];
13
- this.text = '';
14
- this.sourcesData = [];
15
- }
16
- static fromHubtypeCMS(component) {
17
- const newKnowledgeBase = new FlowKnowledgeBase(component.id);
18
- newKnowledgeBase.code = component.code;
19
- newKnowledgeBase.feedbackEnabled = component.content.feedback_enabled;
20
- newKnowledgeBase.sourcesData = component.content.sources_data;
21
- newKnowledgeBase.instructions = component.content.instructions;
22
- newKnowledgeBase.hasMemory = component.content.has_memory || false;
23
- newKnowledgeBase.memoryLength =
24
- component.content.memory_length || exports.DISABLED_MEMORY_LENGTH;
25
- newKnowledgeBase.followUp = component.follow_up;
26
- return newKnowledgeBase;
27
- }
28
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
29
- async trackFlow(_botContext) {
30
- // TODO: Review how we can track here the knowledge base event here.
31
- // We should store event args in an attribute of FlowKnowledgeBase
32
- // when knowledge base is resolved inside the flow builder action
33
- }
34
- async processContent(botContext) {
35
- await this.filterContent(botContext, this);
36
- await this.trackFlow(botContext);
37
- return;
38
- }
39
- toBotonic(botContext) {
40
- return ((0, jsx_runtime_1.jsx)(react_1.Text, { feedbackEnabled: this.feedbackEnabled, inferenceId: this.inferenceId, botInteractionId: botContext.input.bot_interaction_id, children: this.text }, this.id));
41
- }
42
- }
43
- exports.FlowKnowledgeBase = FlowKnowledgeBase;
44
- //# sourceMappingURL=flow-knowledge-base.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"flow-knowledge-base.js","sourceRoot":"","sources":["../../../src/content-fields/flow-knowledge-base.tsx"],"names":[],"mappings":";;;;AACA,0CAAqC;AAErC,+DAAyD;AAG5C,QAAA,sBAAsB,GAAG,CAAC,CAAA;AAEvC,MAAa,iBAAkB,SAAQ,uCAAiB;IAAxD;;QACS,oBAAe,GAAY,KAAK,CAAA;QAChC,YAAO,GAAa,EAAE,CAAA;QACtB,SAAI,GAAW,EAAE,CAAA;QAEjB,gBAAW,GAAmC,EAAE,CAAA;IA4CzD,CAAC;IAvCC,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;QAC7D,gBAAgB,CAAC,YAAY,GAAG,SAAS,CAAC,OAAO,CAAC,YAAY,CAAA;QAC9D,gBAAgB,CAAC,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,UAAU,IAAI,KAAK,CAAA;QAClE,gBAAgB,CAAC,YAAY;YAC3B,SAAS,CAAC,OAAO,CAAC,aAAa,IAAI,8BAAsB,CAAA;QAC3D,gBAAgB,CAAC,QAAQ,GAAG,SAAS,CAAC,SAAS,CAAA;QAE/C,OAAO,gBAAgB,CAAA;IACzB,CAAC;IAED,6DAA6D;IAC7D,KAAK,CAAC,SAAS,CAAC,WAAuB;QACrC,oEAAoE;QACpE,kEAAkE;QAClE,iEAAiE;IACnE,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,UAAsB;QACzC,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;QAC1C,MAAM,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;QAChC,OAAM;IACR,CAAC;IAED,SAAS,CAAC,UAAsB;QAC9B,OAAO,CACL,uBAAC,YAAI,IAEH,eAAe,EAAE,IAAI,CAAC,eAAe,EACrC,WAAW,EAAE,IAAI,CAAC,WAAW,EAC7B,gBAAgB,EAAE,UAAU,CAAC,KAAK,CAAC,kBAAkB,YAEpD,IAAI,CAAC,IAAI,IALL,IAAI,CAAC,EAAE,CAMP,CACR,CAAA;IACH,CAAC;CACF;AAjDD,8CAiDC"}
@@ -1,17 +0,0 @@
1
- import type { HtBaseNode } from './common';
2
- import type { HtNodeWithContentType } from './node-types';
3
- interface SourceData {
4
- id: string;
5
- name: string;
6
- }
7
- export interface HtKnowledgeBaseNode extends HtBaseNode {
8
- type: HtNodeWithContentType.KNOWLEDGE_BASE;
9
- content: {
10
- feedback_enabled: boolean;
11
- sources_data: SourceData[];
12
- instructions: string;
13
- has_memory: boolean;
14
- memory_length?: number;
15
- };
16
- }
17
- export {};
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=knowledge-base.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"knowledge-base.js","sourceRoot":"","sources":["../../../../src/content-fields/hubtype-fields/knowledge-base.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- import { type FlowContent } from '../content-fields';
2
- import type { FlowBuilderContext } from './context';
3
- export declare function getContentsByKnowledgeBase({ cmsApi, flowBuilderPlugin, request, }: FlowBuilderContext): Promise<FlowContent[]>;
@@ -1,85 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getContentsByKnowledgeBase = getContentsByKnowledgeBase;
4
- const core_1 = require("@botonic/core");
5
- const content_fields_1 = require("../content-fields");
6
- const tracking_1 = require("../tracking");
7
- const input_1 = require("../utils/input");
8
- async function getContentsByKnowledgeBase({ cmsApi, flowBuilderPlugin, request, }) {
9
- if ((0, input_1.isKnowledgeBasesAllowed)(request)) {
10
- const startNodeKnowledgeBaseFlow = cmsApi.getStartNodeKnowledgeBaseFlow();
11
- const isKnowledgeBaseEnabled = cmsApi.isKnowledgeBaseEnabled();
12
- if (!startNodeKnowledgeBaseFlow || !isKnowledgeBaseEnabled) {
13
- return [];
14
- }
15
- const contents = await flowBuilderPlugin.getContentsByNode(startNodeKnowledgeBaseFlow);
16
- const knowledgeBaseContent = contents.find(content => content instanceof content_fields_1.FlowKnowledgeBase);
17
- if (!knowledgeBaseContent) {
18
- return contents;
19
- }
20
- const sourceIds = knowledgeBaseContent.sourcesData.map(source => source.id);
21
- if (flowBuilderPlugin.getKnowledgeBaseResponse &&
22
- (0, input_1.inputHasTextOrTranscript)(request.input) &&
23
- sourceIds.length > 0) {
24
- const contentsWithKnowledgeResponse = await getContentsWithKnowledgeResponse(flowBuilderPlugin.getKnowledgeBaseResponse, request, contents, knowledgeBaseContent);
25
- if (contentsWithKnowledgeResponse) {
26
- return contentsWithKnowledgeResponse;
27
- }
28
- }
29
- }
30
- return [];
31
- }
32
- async function getContentsWithKnowledgeResponse(getKnowledgeBaseResponse, request, contents, knowledgeBaseContent) {
33
- const sourceIds = knowledgeBaseContent.sourcesData.map(source => source.id);
34
- const instructions = knowledgeBaseContent.instructions;
35
- const messageId = request.input.message_id;
36
- const memoryLength = knowledgeBaseContent.hasMemory
37
- ? knowledgeBaseContent.memoryLength
38
- : content_fields_1.DISABLED_MEMORY_LENGTH;
39
- const knowledgeBaseResponse = await getKnowledgeBaseResponse(request, sourceIds, instructions, messageId, memoryLength);
40
- await trackKnowledgeBase(knowledgeBaseResponse, request, knowledgeBaseContent);
41
- if (!knowledgeBaseResponse.hasKnowledge ||
42
- !knowledgeBaseResponse.isFaithful) {
43
- return undefined;
44
- }
45
- return updateContentsWithResponse(contents, knowledgeBaseResponse);
46
- }
47
- function updateContentsWithResponse(contents, response) {
48
- return contents.map(content => {
49
- if (content instanceof content_fields_1.FlowKnowledgeBase) {
50
- content.text = response.answer;
51
- content.inferenceId = response.inferenceId;
52
- }
53
- return content;
54
- });
55
- }
56
- async function trackKnowledgeBase(response, request, knowledgeBaseContent) {
57
- const getKnowledgeFailReason = () => {
58
- let knowledgebaseFailReason;
59
- if (!response.isFaithful) {
60
- knowledgebaseFailReason = core_1.KnowledgebaseFailReason.Hallucination;
61
- }
62
- if (!response.hasKnowledge) {
63
- knowledgebaseFailReason = core_1.KnowledgebaseFailReason.NoKnowledge;
64
- }
65
- return knowledgebaseFailReason;
66
- };
67
- const { flowId, flowName, flowNodeId, flowNodeContentId } = (0, tracking_1.getCommonFlowContentEventArgsForContentId)(request, knowledgeBaseContent.id);
68
- const event = {
69
- action: core_1.EventAction.Knowledgebase,
70
- knowledgebaseInferenceId: response.inferenceId,
71
- knowledgebaseFailReason: getKnowledgeFailReason(),
72
- knowledgebaseSourcesIds: knowledgeBaseContent.sourcesData.map(source => source.id),
73
- knowledgebaseChunksIds: response.chunkIds,
74
- knowledgebaseMessageId: request.input.message_id,
75
- userInput: request.input.data,
76
- flowThreadId: request.session.flow_thread_id,
77
- flowId,
78
- flowName,
79
- flowNodeId,
80
- flowNodeContentId,
81
- };
82
- const { action, ...eventArgs } = event;
83
- await (0, tracking_1.trackEvent)(request, action, eventArgs);
84
- }
85
- //# sourceMappingURL=knowledge-bases.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"knowledge-bases.js","sourceRoot":"","sources":["../../../src/action/knowledge-bases.ts"],"names":[],"mappings":";;AAyBA,gEA+CC;AAxED,wCAOsB;AAEtB,sDAI0B;AAC1B,0CAGoB;AAEpB,0CAGuB;AAGhB,KAAK,UAAU,0BAA0B,CAAC,EAC/C,MAAM,EACN,iBAAiB,EACjB,OAAO,GACY;IACnB,IAAI,IAAA,+BAAuB,EAAC,OAAO,CAAC,EAAE,CAAC;QACrC,MAAM,0BAA0B,GAAG,MAAM,CAAC,6BAA6B,EAAE,CAAA;QACzE,MAAM,sBAAsB,GAAG,MAAM,CAAC,sBAAsB,EAAE,CAAA;QAE9D,IAAI,CAAC,0BAA0B,IAAI,CAAC,sBAAsB,EAAE,CAAC;YAC3D,OAAO,EAAE,CAAA;QACX,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,iBAAiB,CACxD,0BAA0B,CAC3B,CAAA;QAED,MAAM,oBAAoB,GAAG,QAAQ,CAAC,IAAI,CACxC,OAAO,CAAC,EAAE,CAAC,OAAO,YAAY,kCAAiB,CAC3B,CAAA;QAEtB,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC1B,OAAO,QAAQ,CAAA;QACjB,CAAC;QAED,MAAM,SAAS,GAAG,oBAAoB,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,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C,IAAc;QACvC,YAAY,EAAE,OAAO,CAAC,OAAO,CAAC,cAAwB;QACtD,MAAM;QACN,QAAQ;QACR,UAAU;QACV,iBAAiB;KAClB,CAAA;IAED,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAA;IAEtC,MAAM,IAAA,qBAAU,EAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAAA;AAC9C,CAAC"}
@@ -1,21 +0,0 @@
1
- import type { BotContext } from '@botonic/core';
2
- import { ContentFieldsBase } from './content-fields-base';
3
- import type { HtKnowledgeBaseNode } from './hubtype-fields';
4
- export declare const DISABLED_MEMORY_LENGTH = 1;
5
- export declare class FlowKnowledgeBase extends ContentFieldsBase {
6
- feedbackEnabled: boolean;
7
- sources: string[];
8
- text: string;
9
- inferenceId?: string;
10
- sourcesData: {
11
- id: string;
12
- name: string;
13
- }[];
14
- instructions: string;
15
- hasMemory: boolean;
16
- memoryLength: number;
17
- static fromHubtypeCMS(component: HtKnowledgeBaseNode): FlowKnowledgeBase;
18
- trackFlow(_botContext: BotContext): Promise<void>;
19
- processContent(botContext: BotContext): Promise<void>;
20
- toBotonic(botContext: BotContext): JSX.Element;
21
- }
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FlowKnowledgeBase = exports.DISABLED_MEMORY_LENGTH = void 0;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("@botonic/react");
6
- const content_fields_base_1 = require("./content-fields-base");
7
- exports.DISABLED_MEMORY_LENGTH = 1;
8
- class FlowKnowledgeBase extends content_fields_base_1.ContentFieldsBase {
9
- constructor() {
10
- super(...arguments);
11
- this.feedbackEnabled = false;
12
- this.sources = [];
13
- this.text = '';
14
- this.sourcesData = [];
15
- }
16
- static fromHubtypeCMS(component) {
17
- const newKnowledgeBase = new FlowKnowledgeBase(component.id);
18
- newKnowledgeBase.code = component.code;
19
- newKnowledgeBase.feedbackEnabled = component.content.feedback_enabled;
20
- newKnowledgeBase.sourcesData = component.content.sources_data;
21
- newKnowledgeBase.instructions = component.content.instructions;
22
- newKnowledgeBase.hasMemory = component.content.has_memory || false;
23
- newKnowledgeBase.memoryLength =
24
- component.content.memory_length || exports.DISABLED_MEMORY_LENGTH;
25
- newKnowledgeBase.followUp = component.follow_up;
26
- return newKnowledgeBase;
27
- }
28
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
29
- async trackFlow(_botContext) {
30
- // TODO: Review how we can track here the knowledge base event here.
31
- // We should store event args in an attribute of FlowKnowledgeBase
32
- // when knowledge base is resolved inside the flow builder action
33
- }
34
- async processContent(botContext) {
35
- await this.filterContent(botContext, this);
36
- await this.trackFlow(botContext);
37
- return;
38
- }
39
- toBotonic(botContext) {
40
- return ((0, jsx_runtime_1.jsx)(react_1.Text, { feedbackEnabled: this.feedbackEnabled, inferenceId: this.inferenceId, botInteractionId: botContext.input.bot_interaction_id, children: this.text }, this.id));
41
- }
42
- }
43
- exports.FlowKnowledgeBase = FlowKnowledgeBase;
44
- //# sourceMappingURL=flow-knowledge-base.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"flow-knowledge-base.js","sourceRoot":"","sources":["../../../src/content-fields/flow-knowledge-base.tsx"],"names":[],"mappings":";;;;AACA,0CAAqC;AAErC,+DAAyD;AAG5C,QAAA,sBAAsB,GAAG,CAAC,CAAA;AAEvC,MAAa,iBAAkB,SAAQ,uCAAiB;IAAxD;;QACS,oBAAe,GAAY,KAAK,CAAA;QAChC,YAAO,GAAa,EAAE,CAAA;QACtB,SAAI,GAAW,EAAE,CAAA;QAEjB,gBAAW,GAAmC,EAAE,CAAA;IA4CzD,CAAC;IAvCC,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,gBA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