UNPKG

ludmi

Version:

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

26 lines (25 loc) 1.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getContextHistory = exports.addMessageToHistory = void 0; /** * Adds a message to the history array. * * @param {MessageToHistoryProps} props - The properties containing history and message. * @param {History} props.history - The array where the message will be added. * @param {Message} props.message - The message to be added to history. * @returns {void} */ const addMessageToHistory = ({ history, message }) => { history.push({ role: message.role, content: message.content }); }; exports.addMessageToHistory = addMessageToHistory; /** * Returns the last n messages from the history. * * @param {ContextHistory} props - The properties containing history and size. * @param {Messages} props.history - The array where the messages are stored. * @param {number} props.size - The number of messages to be returned. * @returns {Messages} - The last n messages from the history. */ const getContextHistory = ({ history, size }) => history.slice(-size); exports.getContextHistory = getContextHistory;