import { Chat, Memory } from 'nebula-sdk';
const chat = new Chat({ apiKey: 'your-key' });
const memory = new Memory({ storageKey: 'chat-session' });
async function chatWithMemory(message: string) {
// Retrieve conversation history
const history = await memory.retrieve('conversation') || [];
const response = await chat.send({
message,
context: history,
systemPrompt: 'Continue our conversation naturally.'
});
// Store updated history
history.push(
{ role: 'user', content: message },
{ role: 'assistant', content: response.content }
);
await memory.store({
key: 'conversation',
value: history
});
return response;
}