feat: add baseSystemPrompt

This commit is contained in:
2026-05-19 23:24:34 +09:00
parent 882e12340c
commit f964d4de9b
5 changed files with 49 additions and 6 deletions

View File

@@ -124,4 +124,30 @@ describe('Conversation API', () => {
expect(mode).toBe('start-conversation');
expect(started.messages).toEqual(['오늘 좀 조용하네.']);
});
it('includes baseSystemPrompt at the start of the instruction when provided', async () => {
const memory = new InMemoryMemoryStore();
let captured: ReplyGenerationInput | undefined;
const persona = new Persona('Mina', 'Mina likes quiet cafes.', {
memory,
now: '2026-05-01T10:00:00.000Z',
baseSystemPrompt: 'You are a helpful assistant. Always be kind.',
models: {
conversation: {
async generateReply(input) {
captured = input;
return { messages: ['Hello!'] };
},
},
},
});
await persona.ready();
await persona.sendMessage({
datetime: '2026-05-01T12:00:00.000Z',
messageHistory: [{ sender: 'user', time: '2026-05-01T12:00:00.000Z', content: 'Hi' }],
});
expect(captured?.instruction.startsWith('You are a helpful assistant. Always be kind.')).toBe(true);
});
});

View File

@@ -29,6 +29,18 @@ describe('Persona initialization', () => {
expect(debug).toContain('persona.initialized');
});
it('exposes baseSystemPrompt on the persona instance when provided', async () => {
const memory = new InMemoryMemoryStore();
const persona = new Persona('Hana', 'Hana is a cheerful barista.', {
memory,
now: '2026-05-01T10:00:00.000Z',
baseSystemPrompt: 'You are a helpful assistant. Always be kind.',
});
await persona.ready();
expect(persona.baseSystemPrompt).toBe('You are a helpful assistant. Always be kind.');
});
it('loads an existing persona space by space id without creating another space', async () => {
const memory = new InMemoryMemoryStore();
const created = new Persona('Joon', 'Joon is a freelance designer.', { memory, now: '2026-05-01T10:00:00.000Z' });