-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-memmachine.js
More file actions
64 lines (53 loc) · 1.93 KB
/
check-memmachine.js
File metadata and controls
64 lines (53 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const fetch = require('node-fetch');
async function checkMemMachine() {
const MEMMACHINE_URL = 'http://localhost:8099';
const userId = 'default';
try {
console.log('🔍 Checking MemMachine memories for user:', userId);
// Query all memories
const response = await fetch(`${MEMMACHINE_URL}/v2/memories/query`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
user_id: userId,
query: '',
top_k: 100
})
});
if (!response.ok) {
console.error('❌ MemMachine query failed:', response.status, response.statusText);
const text = await response.text();
console.error('Response:', text);
return;
}
const data = await response.json();
console.log('\n📊 Total memories found:', data.results?.length || 0);
if (data.results && data.results.length > 0) {
console.log('\n📋 Memory details:\n');
// Count by type
const byType = {};
data.results.forEach(mem => {
const metadata = mem.metadata || {};
const type = metadata.type || 'unknown';
byType[type] = (byType[type] || 0) + 1;
});
console.log('By type:');
Object.entries(byType).forEach(([type, count]) => {
console.log(` ${type}: ${count}`);
});
console.log('\n📝 Recent memories:');
data.results.slice(0, 10).forEach((mem, idx) => {
const metadata = mem.metadata || {};
console.log(`\n${idx + 1}. Type: ${metadata.type || 'unknown'}`);
console.log(` File: ${metadata.filename || 'N/A'}`);
console.log(` Content preview: ${mem.content.substring(0, 100)}...`);
console.log(` Score: ${mem.score}`);
});
} else {
console.log('⚠️ No memories found in MemMachine!');
}
} catch (error) {
console.error('❌ Error checking MemMachine:', error.message);
}
}
checkMemMachine().catch(console.error);