@justinechang39/maki
Version:
AI-powered CLI agent for file operations, CSV manipulation, todo management, and web content fetching using OpenRouter
16 lines (15 loc) • 580 B
JavaScript
import { AIMessage, HumanMessage, SystemMessage } from '@langchain/core/messages';
export const createMemoryFromHistory = (conversationHistory) => {
return conversationHistory.map(msg => {
switch (msg.role) {
case 'user':
return new HumanMessage(msg.content || '');
case 'assistant':
return new AIMessage(msg.content || '');
case 'system':
return new SystemMessage(msg.content || '');
default:
return new AIMessage(msg.content || '');
}
});
};