@botonic/plugin-flow-builder
Version:
Botonic plugin for **Hubtype Flow Builder**: run and bridge flow-driven logic from bots on the **current** line.
54 lines • 2.16 kB
JavaScript
import { __awaiter } from "tslib";
import { BotServerMessageFactory, } from '@botonic/core';
import { ContentFieldsBase } from './content-fields-base';
export const DISABLED_MEMORY_LENGTH = 1;
export class FlowKnowledgeBase extends ContentFieldsBase {
constructor() {
super(...arguments);
this.feedbackEnabled = false;
this.sources = [];
this.text = '';
this.sourcesData = [];
this.instructions = '';
this.hasMemory = false;
this.memoryLength = DISABLED_MEMORY_LENGTH;
}
static fromHubtypeCMS(component) {
const newKnowledgeBase = new FlowKnowledgeBase(component.id);
newKnowledgeBase.code = component.code;
newKnowledgeBase.feedbackEnabled = component.content.feedback_enabled;
newKnowledgeBase.sourcesData = component.content.sources_data;
newKnowledgeBase.instructions = component.content.instructions;
newKnowledgeBase.hasMemory = component.content.has_memory || false;
newKnowledgeBase.memoryLength =
component.content.memory_length || DISABLED_MEMORY_LENGTH;
newKnowledgeBase.followUp = component.follow_up;
return newKnowledgeBase;
}
trackFlow() {
return __awaiter(this, void 0, void 0, function* () {
return;
});
}
processContent(botonicContext) {
return __awaiter(this, void 0, void 0, function* () {
return this.filterContent(botonicContext, this);
});
}
toBotonic() {
return __awaiter(this, void 0, void 0, function* () {
// TODO: Tweak botonic model so it accepts feedbackEnabled, inferenceId, botInteractionId
return BotServerMessageFactory.createText({
text: this.text,
// TODO: Tweak botonic model
// metadata: {
// id,
// feedbackEnabled: this.feedbackEnabled,
// inferenceId: this.inferenceId,
// botInteractionId: request.input.botInteractionId,
// }
});
});
}
}
//# sourceMappingURL=flow-knowledge-base.js.map