feat: use FactExtractor
All checks were successful
CI / verify (push) Successful in 11s

This commit is contained in:
2026-05-17 23:41:02 +09:00
parent 4ef1b89a2d
commit 600f5ff0bc
7 changed files with 106 additions and 90 deletions

View File

@@ -55,7 +55,6 @@ describe('Conversation API', () => {
memory,
now: '2026-05-01T10:00:00.000Z',
models: {
initialization: { async extractInitialFacts() { return []; } },
conversation: {
async generateReply(input) {
memorySummary = input.context.memorySummary;
@@ -64,7 +63,8 @@ describe('Conversation API', () => {
},
},
});
await persona.ready();
const space = await persona.ready();
memory.facts.set(space.id, []);
await persona.sendMessage({
datetime: '2026-05-01T12:00:00.000Z',

View File

@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest';
import { InMemoryMemoryStore, Persona, type FactDraft } from '../src';
import { InMemoryMemoryStore, Persona } from '../src';
describe('Persona initialization', () => {
it('creates a new isolated persona space from displayName and seed message', async () => {
@@ -10,15 +10,13 @@ describe('Persona initialization', () => {
now: '2026-05-01T10:00:00.000Z',
debug: (event) => { debug.push(event.name); },
models: {
initialization: {
async extractInitialFacts(input): Promise<FactDraft[]> {
return [
{
statement: `${input.displayName} likes quiet cafes.`,
topics: ['persona', input.displayName],
source: 'test',
},
];
factExtractor: {
async extract(input) {
return {
statement: 'Mina likes quiet cafes.',
topics: [{ name: 'persona' }, { name: 'Mina' }],
source: 'test',
};
},
},
},

View File

@@ -8,17 +8,18 @@ describe('sleepMemory', () => {
memory,
now: '2026-05-01T10:00:00.000Z',
models: {
memoryExtraction: {
factExtractor: {
async extract(input) {
expect(input.formattedMessageHistory).toContain('user@2026-05-01T15:00:00.000Z: 나는 타입스크립트를 2025년부터 시작했어');
expect(input.instruction).toContain('Objectivize');
return [
{
statement: 'The user started TypeScript in 2025.',
topics: ['user', 'TypeScript', '2025'],
confidence: 0.9,
},
];
if (input.includes('Seed:')) {
return { statement: 'Mina remembers stable details.', topics: [{ name: 'persona' }, { name: 'Mina' }] };
}
expect(input).toContain('user@2026-05-01T15:00:00.000Z: 나는 타입스크립트를 2025년부터 시작했어');
expect(input).toContain('Objectivize');
return {
statement: 'The user started TypeScript in 2025.',
topics: [{ name: 'user' }, { name: 'TypeScript' }, { name: '2025' }],
confidence: 0.9,
};
},
},
},