-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-memmachine-direct.js
More file actions
60 lines (50 loc) · 2.05 KB
/
test-memmachine-direct.js
File metadata and controls
60 lines (50 loc) · 2.05 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
const fetch = require('node-fetch')
const MEMMACHINE_URL = 'http://123.57.28.44:8081'
const ORG_ID = 'personal-assistant'
const USER_UUID = '8fe2b191-c205-489a-8763-174d60520ebd' // daqiao
const PROJECT_ID = `todd-assistant-${USER_UUID}`
async function testMemMachineSearch() {
console.log(`\n🔍 Testing MemMachine search for Daqiao...`)
console.log(` URL: ${MEMMACHINE_URL}/api/v2/memories/search`)
console.log(` Org: ${ORG_ID}`)
console.log(` Project: ${PROJECT_ID}`)
try {
// Test 1: Search for food preferences
console.log(`\n📤 Test 1: 搜索 "我爱吃什么"...`)
const searchResponse1 = await fetch(`${MEMMACHINE_URL}/api/v2/memories/search`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
org_id: ORG_ID,
project_id: PROJECT_ID,
query: '我爱吃什么',
top_k: 15
})
})
if (!searchResponse1.ok) {
console.error('❌ Search error:', searchResponse1.status)
const text = await searchResponse1.text()
console.error(text)
return
}
const searchResult1 = await searchResponse1.json()
const ltm1 = searchResult1.content?.episodic_memory?.long_term_memory?.episodes || []
const stm1 = searchResult1.content?.episodic_memory?.short_term_memory?.episodes || []
const all1 = [...ltm1, ...stm1]
console.log(`\n✅ 返回了 ${all1.length} 条记忆`)
all1.slice(0, 5).forEach((ep, i) => {
console.log(`\n[${i+1}] 相似度: ${ep.similarity_score !== undefined ? ep.similarity_score.toFixed(3) : '无'}`)
console.log(` UID: ${ep.uid || '无'}`)
console.log(` 内容: ${ep.content?.substring(0, 100)}...`)
})
// Show first episode structure
if (all1.length > 0) {
console.log(`\n\n=== 第一条记忆的完整结构 ===`)
console.log(JSON.stringify(all1[0], null, 2).substring(0, 800))
}
} catch (error) {
console.error('❌ Error:', error.message)
console.error(' Stack:', error.stack)
}
}
testMemMachineSearch().catch(console.error)