-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.ts
More file actions
59 lines (50 loc) · 1.88 KB
/
test.ts
File metadata and controls
59 lines (50 loc) · 1.88 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
import { BaseGrid } from './src/index.js'
const bg = new BaseGrid({
apiKey: 'bg_test_815f8c401b03c13950d2cdfb50df0b09'
})
async function test() {
try {
console.log('🧪 Testing BaseGrid SDK...\n')
// Add memory
console.log('1️⃣ Adding memory...')
const memory = await bg.add({
agentId: 'sdk-test-bot',
content: 'User wants to schedule meetings on Tuesdays',
metadata: { preference: 'tuesday', type: 'scheduling' }
})
console.log('✅ Memory added:', memory.id)
console.log(' Content:', memory.content)
console.log()
// Add another memory
console.log('2️⃣ Adding another memory...')
const memory2 = await bg.add({
agentId: 'sdk-test-bot',
content: 'User prefers video calls over phone calls',
metadata: { preference: 'video', type: 'communication' }
})
console.log('✅ Memory added:', memory2.id)
console.log()
// Search
console.log('3️⃣ Searching memories...')
const results = await bg.search({
agentId: 'sdk-test-bot',
query: 'When does the user prefer meetings?'
})
console.log(`✅ Found ${results.length} results:`)
results.forEach((r, i) => {
console.log(` ${i + 1}. "${r.content}"`)
console.log(` Similarity: ${r.similarity?.toFixed(3)}`)
console.log(` Combined Score: ${r.combined_score?.toFixed(3)}`)
})
console.log()
// List all memories
console.log('4️⃣ Listing all memories for agent...')
const list = await bg.list('sdk-test-bot')
console.log(`✅ Total memories: ${list.total}`)
console.log()
console.log('🎉 All tests passed!')
} catch (error) {
console.error('❌ Error:', error)
}
}
test()