From 30a477fcc39aae33a76a0a1f0d3eeca78c88e956 Mon Sep 17 00:00:00 2001 From: vanbasten17 Date: Fri, 17 May 2024 16:54:53 +0200 Subject: [PATCH] fix: convert incoming config to camelCase --- packages/botonic-plugin-flow-builder/src/index.ts | 2 +- packages/botonic-plugin-flow-builder/src/types.ts | 2 +- .../src/user-input/index.ts | 4 ++-- .../src/user-input/smart-intent.ts | 12 +++++++----- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/botonic-plugin-flow-builder/src/index.ts b/packages/botonic-plugin-flow-builder/src/index.ts index 4be0262432..c46f9f7b57 100644 --- a/packages/botonic-plugin-flow-builder/src/index.ts +++ b/packages/botonic-plugin-flow-builder/src/index.ts @@ -67,7 +67,7 @@ export default class BotonicPluginFlowBuilder implements Plugin { this.getKnowledgeBaseResponse = options.getKnowledgeBaseResponse this.smartIntentsConfig = { ...options?.smartIntentsConfig, - use_latest: jsonVersion === FlowBuilderJSONVersion.LATEST, + useLatest: jsonVersion === FlowBuilderJSONVersion.LATEST, } const customFunctions = options.customFunctions || {} this.functions = { ...DEFAULT_FUNCTIONS, ...customFunctions } diff --git a/packages/botonic-plugin-flow-builder/src/types.ts b/packages/botonic-plugin-flow-builder/src/types.ts index 47685b8704..65d7160234 100644 --- a/packages/botonic-plugin-flow-builder/src/types.ts +++ b/packages/botonic-plugin-flow-builder/src/types.ts @@ -18,7 +18,7 @@ export interface BotonicPluginFlowBuilderOptions { getKnowledgeBaseResponse?: ( request: ActionRequest ) => Promise - smartIntentsConfig?: { num_smart_intents_to_use: number } + smartIntentsConfig?: { numSmartIntentsToUse: number } } export interface FlowBuilderApiOptions { diff --git a/packages/botonic-plugin-flow-builder/src/user-input/index.ts b/packages/botonic-plugin-flow-builder/src/user-input/index.ts index 98f2394273..1068602e4b 100644 --- a/packages/botonic-plugin-flow-builder/src/user-input/index.ts +++ b/packages/botonic-plugin-flow-builder/src/user-input/index.ts @@ -8,13 +8,13 @@ import { } from '../content-fields/hubtype-fields' import { getIntentNodeByInput } from './intent' import { getKeywordNodeByInput } from './keyword' -import { SmartIntentsApi, SmartIntentsInferenceParams } from './smart-intent' +import { SmartIntentsApi, SmartIntentsInferenceConfig } from './smart-intent' export async function getNodeByUserInput( cmsApi: FlowBuilderApi, locale: string, request: ActionRequest, - smartIntentsConfig: Partial + smartIntentsConfig: SmartIntentsInferenceConfig ): Promise { if (request.input.data) { const keywordNode = await getKeywordNodeByInput( diff --git a/packages/botonic-plugin-flow-builder/src/user-input/smart-intent.ts b/packages/botonic-plugin-flow-builder/src/user-input/smart-intent.ts index 59cd6a9972..a235f85291 100644 --- a/packages/botonic-plugin-flow-builder/src/user-input/smart-intent.ts +++ b/packages/botonic-plugin-flow-builder/src/user-input/smart-intent.ts @@ -4,15 +4,16 @@ import axios from 'axios' import { FlowBuilderApi } from '../api' import { HtSmartIntentNode } from '../content-fields/hubtype-fields/smart-intent' -export interface SmartIntentsInferenceParams - extends SmartIntentsInferenceConfig { +export interface SmartIntentsInferenceParams { bot_id: string text: string + num_smart_intents_to_use?: number + use_latest: boolean } export interface SmartIntentsInferenceConfig { - use_latest: boolean - num_smart_intents_to_use?: number + useLatest: boolean + numSmartIntentsToUse?: number } export class SmartIntentsApi { @@ -30,7 +31,8 @@ export class SmartIntentsApi { const params = { bot_id: this.currentRequest.session.bot.id, text: this.currentRequest.input.data, - ...this.smartIntentsConfig, + num_smart_intents_to_use: this.smartIntentsConfig.numSmartIntentsToUse, + use_latest: this.smartIntentsConfig.useLatest, } try {