UNPKG

cui-llama.rn

Version:
37 lines (36 loc) 969 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.formatChat = formatChat; function formatChat(messages) { const chat = []; messages.forEach(currMsg => { const role = currMsg.role || ''; let content = ''; if ('content' in currMsg) { if (typeof currMsg.content === 'string') { ; ({ content } = currMsg); } else if (Array.isArray(currMsg.content)) { currMsg.content.forEach(part => { if ('text' in part) { content += `${content ? '\n' : ''}${part.text}`; } }); } else { throw new TypeError("Invalid 'content' type (ref: https://github.com/ggerganov/llama.cpp/issues/8367)"); } } else { throw new Error("Missing 'content' (ref: https://github.com/ggerganov/llama.cpp/issues/8367)"); } chat.push({ role, content }); }); return chat; } //# sourceMappingURL=chat.js.map