export function constructMessages(history) {
    const msgs = [];
    for (let i = 0; i < history.length; i++) {
        const historyItem = history[i];
        let content = Array.isArray(historyItem.message.content)
            ? historyItem.message.content
            : [{ type: "text", text: historyItem.message.content }];
        const ctxItems = historyItem.contextItems.map((ctxItem) => {
            return { type: "text", text: `${ctxItem.content}\n` };
        });
        content = [...ctxItems, ...content];
        msgs.push({
            role: historyItem.message.role,
            content,
        });
    }
    return msgs;
}
