Copy
# Add and retrieve memory
npx ts-node -e "
import { Memory } from 'praisonai';
const mem = new Memory();
mem.add('Hello', 'user').then(() => {
mem.add('Hi there', 'assistant').then(() => {
console.log('Size:', mem.size);
});
});
"
# Search memory
npx ts-node -e "
import { Memory } from 'praisonai';
const mem = new Memory();
mem.add('TypeScript is great', 'user').then(() => {
mem.add('Python is good', 'user').then(() => {
mem.search('TypeScript').then(r => console.log(r));
});
});
"
# Get recent entries
npx ts-node -e "
import { Memory } from 'praisonai';
const mem = new Memory();
mem.add('Msg 1', 'user').then(() => {
mem.add('Msg 2', 'assistant').then(() => {
console.log(mem.getRecent(1));
});
});
"
# Build context
npx ts-node -e "
import { Memory } from 'praisonai';
const mem = new Memory();
mem.add('Question', 'user').then(() => {
mem.add('Answer', 'assistant').then(() => {
console.log(mem.buildContext());
});
});
"
# Export memory
npx ts-node -e "
import { Memory } from 'praisonai';
const mem = new Memory();
mem.add('Test', 'user').then(() => {
console.log(JSON.stringify(mem.toJSON()));
});
"

