34 lines
2.4 KiB
TypeScript
34 lines
2.4 KiB
TypeScript
/**
|
||
* 벡터 기억 중복 판정(2026-10-25) — 실측 쌍으로 고정.
|
||
*/
|
||
import { describe, test } from 'node:test';
|
||
import assert from 'node:assert/strict';
|
||
import { isNearDuplicateFact, dedupeFacts } from '../src/gateway/memory/memory-vector';
|
||
|
||
describe('isNearDuplicateFact', () => {
|
||
test('같은 사실의 다른 문장 — 거리(실측)로', () => {
|
||
assert.equal(isNearDuplicateFact('클로서버(Claw-Server)의 대시보드 주소는 `http://192.168.0.5:18789`이다.', '클로서버 웹 대시보드 주소는 http://192.168.0.5:18789(LAN 내부) 또는 http://localhost:18789(로컬)이다.', 0.1536), true);
|
||
assert.equal(isNearDuplicateFact('클로서버는 Dell T5810(Xeon E5-2683 v4, 40GB RAM, RTX 3060 12GB ×2) 사양을 사용한다.', '클로서버(Claw-Server)는 Dell Precision T5810 모델이며, CPU는 Xeon E5-2683 v4, RAM 40GB, GPU는 RTX 3060 12GB 2개를 사용한다.', 0.1206), true);
|
||
});
|
||
test('가깝지만 숫자가 다르면 다른 사실', () => {
|
||
assert.equal(isNearDuplicateFact('로봇청소기 1호기의 IP는 192.168.0.76이다.', '로봇청소기 2호기의 IP는 192.168.0.87이다.', 0.142), false);
|
||
assert.equal(isNearDuplicateFact('NVIDIA RTX 5090의 메모리 대역폭은 1,790 GB/s이다.', 'NVIDIA RTX 3090의 메모리 대역폭은 936.2 GB/s이다.', 0.1886), false);
|
||
});
|
||
test('거리 없이 글자 유사도로(회상 결과끼리)', () => {
|
||
assert.equal(isNearDuplicateFact('클로서버의 웹 대시보드 주소는 http://192.168.0.5:18789이다.', '클로서버 대시보드 주소는 http://192.168.0.5:18789이다.'), true);
|
||
assert.equal(isNearDuplicateFact('클로서버(Claw-Server)의 RAM 용량은 40GB이다.', '클로서버(Claw-Server)의 GPU는 RTX 3060 12GB 2장(총 VRAM 24GB)이 장착되어 있다.'), false);
|
||
});
|
||
});
|
||
|
||
describe('dedupeFacts', () => {
|
||
test('앞쪽(더 관련 있는 것)을 남긴다', () => {
|
||
const out = dedupeFacts([
|
||
{ text: '클로서버 대시보드 주소는 http://192.168.0.5:18789이다.' },
|
||
{ text: '클로서버의 웹 대시보드 주소는 http://192.168.0.5:18789이다.' },
|
||
{ text: '클로서버 웹 대시보드 주소는 http://192.168.0.5:18789 이다.' },
|
||
{ text: '클로서버(Claw-Server)의 RAM 용량은 40GB이다.' },
|
||
]);
|
||
assert.deepEqual(out.map(o => o.text), ['클로서버 대시보드 주소는 http://192.168.0.5:18789이다.', '클로서버(Claw-Server)의 RAM 용량은 40GB이다.']);
|
||
});
|
||
});
|