@botonic/plugin-flow-builder
Version:
Botonic plugin for **Hubtype Flow Builder**: run and bridge flow-driven logic from bots on the **current** line.
31 lines • 1.47 kB
JavaScript
import { __awaiter } from "tslib";
import { splitAiAgentContents } from '../utils';
export function getContentsByAiAgentFromUserInput(_a) {
return __awaiter(this, arguments, void 0, function* ({ cmsApi, flowBuilderPlugin, botonicContext, }) {
const startNodeAiAgentFlow = cmsApi.getStartNodeAiAgentFlow();
const isAiAgentEnabled = cmsApi.isAiAgentEnabled();
if (!startNodeAiAgentFlow || !isAiAgentEnabled) {
return [];
}
const contents = yield flowBuilderPlugin.getContentsByNode(startNodeAiAgentFlow);
const splitContents = splitAiAgentContents(contents);
if (!splitContents) {
return [];
}
if ('aiAgentRouterContent' in splitContents) {
const { aiAgentRouterContent, contentsBeforeAiAgentRouter } = splitContents;
const aiAgentResponse = yield aiAgentRouterContent.resolveAIAgentResponse(botonicContext, contentsBeforeAiAgentRouter);
if (!aiAgentResponse || aiAgentResponse.exit) {
return [];
}
return contents;
}
const { aiAgentContent, contentsBeforeAiAgent } = splitContents;
const aiAgentResponse = yield aiAgentContent.resolveAIAgentResponse(botonicContext, contentsBeforeAiAgent);
if (!aiAgentResponse || aiAgentResponse.exit) {
return [];
}
return contents;
});
}
//# sourceMappingURL=ai-agent-from-user-input.js.map