Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19,601 changes: 19,601 additions & 0 deletions examples/flow-builder-typescript/package-lock.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion examples/flow-builder-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"@botonic/plugin-ai-agents": "^0.54.0",
"@botonic/plugin-flow-builder": "^0.54.0",
"@botonic/plugin-hubtype-analytics": "^0.54.0",
"@botonic/plugin-knowledge-bases": "^0.54.0",
"@botonic/react": "^0.54.0",
"@reduxjs/toolkit": "1.9.7",
"axios": "^1.18.1",
Expand Down
57 changes: 5 additions & 52 deletions examples/flow-builder-typescript/src/server/config.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import { PluginAiAgentOptions } from '@botonic/plugin-ai-agents'
import type { PluginAiAgentOptions } from '@botonic/plugin-ai-agents'
import {
type BotonicPluginFlowBuilderOptions,
FlowBuilderJSONVersion,
} from '@botonic/plugin-flow-builder'
import {
KnowledgeBasesResponse,
type PluginKnowledgeBaseOptions,
} from '@botonic/plugin-knowledge-bases/src/types'

import { UserData } from './domain/user-data'
import { BotPlugins } from './plugins'
import type { UserData } from './domain/user-data'
import type { BotPlugins } from './plugins'
import { customTools } from './tools'
import { trackEvent } from './tracking'
import { BotRequest } from './types'
import { ENVIRONMENT, isLocal, isProduction } from './utils/env-utils'
import type { BotRequest } from './types'
import { ENVIRONMENT, isLocal } from './utils/env-utils'

const AUTH_TOKEN = 'ADD_YOUR_FLOW_BUILDER_AUTH_TOKEN'

Expand All @@ -29,39 +25,6 @@ function getFlowBuilderConfig(
trackEvent: async (request: BotRequest, eventName, args) => {
await trackEvent(request, eventName, args)
},
getKnowledgeBaseResponse: async (
request: BotRequest,
sources: string[],
instructions: string,
messageId: string,
memoryLength: number
): Promise<KnowledgeBasesResponse> => {
try {
const knowledgeBasePlugin = request.plugins.knowledgeBases
const response = await knowledgeBasePlugin.getInference(
request,
sources,
instructions,
messageId,
memoryLength
)
if (!isProduction()) {
console.log('knowledgeBasePlugin.getInference', { response })
}
return response
} catch (error: any) {
console.error('knowledgeBasePlugin.getInference', {
e: error?.response?.data,
})
return {
inferenceId: '',
answer: '',
hasKnowledge: false,
isFaithful: false,
chunkIds: [],
}
}
},
// TODO: Uncomment this to use the AI Agents. You need to create a .env file as .env.template in root with your AZURE_OPENAI_API_KEY and AZURE_OPENAI_ENDPOINT
// getAiAgentResponse: async (
// request: BotRequest,
Expand All @@ -76,13 +39,6 @@ function getFlowBuilderConfig(
}
}

function getKnowledgeBasesConfig(): PluginKnowledgeBaseOptions {
return {
authToken: AUTH_TOKEN, // Used locally
host: process.env.HUBTYPE_API_URL || 'https://api.hubtype.com',
}
}

function getAiAgentsConfig(): PluginAiAgentOptions {
return {
authToken: AUTH_TOKEN, // Used locally
Expand All @@ -95,18 +51,15 @@ interface Config {
// to avoid type errors with circular dependencies
aiAgents: PluginAiAgentOptions
flowBuilder: BotonicPluginFlowBuilderOptions<any, any>
knowledgeBases: PluginKnowledgeBaseOptions
}

export const CONFIG: Record<ENVIRONMENT, Config> = {
[ENVIRONMENT.LOCAL]: {
aiAgents: getAiAgentsConfig(),
flowBuilder: getFlowBuilderConfig(ENVIRONMENT.LOCAL),
knowledgeBases: getKnowledgeBasesConfig(),
},
[ENVIRONMENT.PRODUCTION]: {
aiAgents: getAiAgentsConfig(),
flowBuilder: getFlowBuilderConfig(ENVIRONMENT.PRODUCTION),
knowledgeBases: getKnowledgeBasesConfig(),
},
}
6 changes: 2 additions & 4 deletions examples/flow-builder-typescript/src/server/plugins.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { ResolvedPlugins } from '@botonic/core'
import type { ResolvedPlugins } from '@botonic/core'
import BotonicPluginAiAgents from '@botonic/plugin-ai-agents'
import BotonicPluginFlowBuilder, {
BotonicPluginFlowBuilderOptions,
type BotonicPluginFlowBuilderOptions,
} from '@botonic/plugin-flow-builder'
import BotonicPluginHubtypeAnalytics from '@botonic/plugin-hubtype-analytics'
import BotonicPluginKnowledgeBases from '@botonic/plugin-knowledge-bases'

import { CONFIG } from './config'
import { getEnvironment } from './utils/env-utils'
Expand All @@ -18,6 +17,5 @@ export const plugins = {
config.flowBuilder as BotonicPluginFlowBuilderOptions<ResolvedPlugins>
),
aiAgents: new BotonicPluginAiAgents(config.aiAgents),
knowledgeBases: new BotonicPluginKnowledgeBases(config.knowledgeBases),
hubtypeAnalytics: new BotonicPluginHubtypeAnalytics(),
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/botonic-core/src/models/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from './ai-agents'
export * from './bot-config'
export * from './hubtype-analytics'
export * from './knowledge-bases'
export * from './legacy-types'
7 changes: 0 additions & 7 deletions packages/botonic-core/src/models/knowledge-bases.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type BotonicPluginFlowBuilder from '../index'
import { inputHasTextOrTranscript } from '../utils/input'
import { getContentsByAiAgentFromUserInput } from './ai-agent-from-user-input'
import type { FlowBuilderContext } from './context'
import { getContentsByKnowledgeBase } from './knowledge-bases'
import { getContentsByPayload } from './payload'

export async function getContentsByFirstInteraction(
Expand Down Expand Up @@ -38,7 +37,7 @@ export async function getContentsByFirstInteraction(
}

/* If the first interaction has a FlowBotAction, it should be the last content
* and avoid to render the match with keywords,intents or knowledge base
* and avoid to render the match with keywords or intents
*/
if (firstInteractionContents.at(-1) instanceof FlowBotAction) {
return firstInteractionContents
Expand Down Expand Up @@ -88,17 +87,6 @@ async function getContentsByUserInput(
}
}

const contentsByKnowledgeBase = await getContentsByKnowledgeBase({
cmsApi,
flowBuilderPlugin,
request,
resolvedLocale,
})

if (contentsByKnowledgeBase.length > 0) {
return contentsByKnowledgeBase
}

if (!flowBuilderPlugin.disableAIAgentInFirstInteraction) {
const contentsByAiAgent = await getContentsByAiAgentFromUserInput(context)
return contentsByAiAgent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { getContentsByAiAgentFromUserInput } from './ai-agent-from-user-input'
import { getFlowBuilderActionContext } from './context'
import { getContentsByFallback } from './fallback'
import { getContentsByFirstInteraction } from './first-interaction'
import { getContentsByKnowledgeBase } from './knowledge-bases'
import { getContentsByPayload } from './payload'

export async function getContents(
Expand Down Expand Up @@ -41,10 +40,6 @@ export async function getContents(
if (aiAgentContents.length > 0) {
return aiAgentContents
}
const knowledgeBaseContents = await getContentsByKnowledgeBase(context)
if (knowledgeBaseContents.length > 0) {
return knowledgeBaseContents
}
}

return await getContentsByFallback(context)
Expand Down
164 changes: 0 additions & 164 deletions packages/botonic-plugin-flow-builder/src/action/knowledge-bases.ts

This file was deleted.

Loading
Loading