UNPKG

ludmi

Version:

LU (Layer Understanding) is a lightweight framework for controlled chatbot interactions with LLMs, action orchestration, and retrieval-augmented generation (RAG).

37 lines (36 loc) 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.orchestrator = void 0; const classifier_1 = require("./classifier"); const queueMemory_1 = require("./memory/queueMemory"); const orchestrator = async ({ history = [], input, revised, sizeHistory = 10, topics, userData = {}, actions = {}, metadata, temperature = 1 }) => { //Update the history with the new input (0, queueMemory_1.addMessageToHistory)({ history, message: { role: "user", content: input } }); //Get the last n messages from the history history = (0, queueMemory_1.getContextHistory)({ history, size: sizeHistory }); let { price, topic, revised_prompt } = await (0, classifier_1.getTopic)({ topics, conversation: history, revised, metadata, temperature }); //Base Data creation const data = { history, input, revised_prompt, topic, userData }; //Exist the actions for the topic const action = actions[topic]; if (action) { const resultAction = await action({ input, revised_prompt, userData, history }); price += resultAction.price; data.eval = resultAction.eval; } //Orchestrator END return { price: { unit: "USD", value: price }, data }; }; exports.orchestrator = orchestrator;