Skip to content

Commit

Permalink
fix: convert incoming config to camelCase
Browse files Browse the repository at this point in the history
  • Loading branch information
vanbasten17 committed May 17, 2024
1 parent e9d9d69 commit 30a477f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/botonic-plugin-flow-builder/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion packages/botonic-plugin-flow-builder/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface BotonicPluginFlowBuilderOptions {
getKnowledgeBaseResponse?: (
request: ActionRequest
) => Promise<KnowledgeBaseResponse>
smartIntentsConfig?: { num_smart_intents_to_use: number }
smartIntentsConfig?: { numSmartIntentsToUse: number }
}

export interface FlowBuilderApiOptions {
Expand Down
4 changes: 2 additions & 2 deletions packages/botonic-plugin-flow-builder/src/user-input/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<SmartIntentsInferenceParams>
smartIntentsConfig: SmartIntentsInferenceConfig
): Promise<HtSmartIntentNode | HtIntentNode | HtKeywordNode | undefined> {
if (request.input.data) {
const keywordNode = await getKeywordNodeByInput(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit 30a477f

Please sign in to comment.