Replace ambiguous AGENT_NAME usage across runtime, setup, and helper scripts with explicit TENANT_ID or platform runtime identity where appropriate. Keep AGENT_NAME as a compatibility boundary instead of the primary source for shared runtime naming. --- Build: pass | Tests: pass — 138 passed (10 files)
72 lines
2.6 KiB
TypeScript
72 lines
2.6 KiB
TypeScript
/**
|
|
* test-memory-pipeline.ts
|
|
* Quick end-to-end test: embed → store → search
|
|
* Run: tsx scripts/test-memory-pipeline.ts
|
|
*/
|
|
|
|
import { initMemoryPool, shutdownMemoryPool } from '../src/memory-lifecycle.js';
|
|
import { storeMemory, searchMemories, getMemoryStats } from '../src/memory-pg.js';
|
|
import { TENANT_ID } from '../src/config.js';
|
|
|
|
const AGENT_DISPLAY_NAME = TENANT_ID.charAt(0).toUpperCase() + TENANT_ID.slice(1);
|
|
|
|
const TEST_SUMMARY = `
|
|
${AGENT_DISPLAY_NAME} je pomagala uporabniku nastaviti lokalni embedding strežnik bge-m3 na FreeBSD gostitelju.
|
|
Namestili smo llama-cpp z bastille jail za PostgreSQL s pgvector razširitvijo.
|
|
Vektorska baza podatkov ${TENANT_ID}_brain je zdaj aktivna na 192.168.100.3.
|
|
Embedding model bge-m3 deluje na 127.0.0.1:8080 z 1024 dimenzijami.
|
|
`.trim();
|
|
|
|
async function run() {
|
|
console.log('==> Connecting to memory DB...');
|
|
await initMemoryPool();
|
|
console.log(' OK\n');
|
|
|
|
console.log('==> Storing test memory (Slovenian text)...');
|
|
await storeMemory(TEST_SUMMARY, {
|
|
topics: ['embeddings', 'postgresql', 'FreeBSD', 'bge-m3'],
|
|
importance: 8,
|
|
keyFacts: ['bge-m3 running at :8080', 'pgvector 1024-dim', 'db jail at 192.168.100.3'],
|
|
decisions: ['switched from nomic-embed to bge-m3', 'pg17 instead of pg16'],
|
|
sessionId: 'test-pipeline-001',
|
|
});
|
|
console.log(' OK\n');
|
|
|
|
console.log('==> Checking DB stats...');
|
|
const stats = await getMemoryStats();
|
|
console.log(` memories: ${stats.memories} chunks: ${stats.chunks} embeddings: ${stats.embeddings}`);
|
|
console.log();
|
|
|
|
console.log('==> Searching: "embedding strežnik" (Slovenian)...');
|
|
const results = await searchMemories('embedding strežnik', 3);
|
|
if (results.length > 0) {
|
|
console.log(` Found ${results.length} result(s):`);
|
|
results.forEach((r, i) => {
|
|
console.log(` [${i + 1}] score=${r.combined_score?.toFixed(4) ?? 'n/a'} "${r.chunk_text?.slice(0, 80)}..."`);
|
|
});
|
|
} else {
|
|
console.log(' No results (FTS-only fallback or empty DB)');
|
|
}
|
|
console.log();
|
|
|
|
console.log('==> Searching: "pgvector database" (English cross-lingual)...');
|
|
const results2 = await searchMemories('pgvector database FreeBSD', 3);
|
|
if (results2.length > 0) {
|
|
console.log(` Found ${results2.length} result(s):`);
|
|
results2.forEach((r, i) => {
|
|
console.log(` [${i + 1}] score=${r.combined_score?.toFixed(4) ?? 'n/a'} "${r.chunk_text?.slice(0, 80)}..."`);
|
|
});
|
|
} else {
|
|
console.log(' No results');
|
|
}
|
|
console.log();
|
|
|
|
console.log('==> Shutting down pool...');
|
|
await shutdownMemoryPool();
|
|
console.log(' Done.\n');
|
|
}
|
|
|
|
run().catch((err) => {
|
|
console.error('FAILED:', err.message);
|
|
process.exit(1);
|
|
});
|