universal-llm-client 4.0.0 โ 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-model.d.ts +20 -22
- package/dist/ai-model.d.ts.map +1 -1
- package/dist/ai-model.js +26 -23
- package/dist/ai-model.js.map +1 -1
- package/dist/client.d.ts +5 -5
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +17 -9
- package/dist/client.js.map +1 -1
- package/dist/http.d.ts +2 -0
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +1 -0
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +49 -11
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js +14 -0
- package/dist/interfaces.js.map +1 -1
- package/dist/providers/anthropic.d.ts +56 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +524 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/google.d.ts +5 -0
- package/dist/providers/google.d.ts.map +1 -1
- package/dist/providers/google.js +64 -8
- package/dist/providers/google.js.map +1 -1
- package/dist/providers/index.d.ts +1 -0
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +1 -0
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/ollama.d.ts.map +1 -1
- package/dist/providers/ollama.js +38 -11
- package/dist/providers/ollama.js.map +1 -1
- package/dist/providers/openai.d.ts.map +1 -1
- package/dist/providers/openai.js +9 -7
- package/dist/providers/openai.js.map +1 -1
- package/dist/router.d.ts +13 -33
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +33 -57
- package/dist/router.js.map +1 -1
- package/dist/stream-decoder.d.ts +29 -2
- package/dist/stream-decoder.d.ts.map +1 -1
- package/dist/stream-decoder.js +39 -11
- package/dist/stream-decoder.js.map +1 -1
- package/dist/structured-output.d.ts +107 -181
- package/dist/structured-output.d.ts.map +1 -1
- package/dist/structured-output.js +137 -192
- package/dist/structured-output.js.map +1 -1
- package/dist/zod-adapter.d.ts +44 -0
- package/dist/zod-adapter.d.ts.map +1 -0
- package/dist/zod-adapter.js +61 -0
- package/dist/zod-adapter.js.map +1 -0
- package/package.json +9 -1
- package/src/ai-model.ts +350 -0
- package/src/auditor.ts +213 -0
- package/src/client.ts +402 -0
- package/src/debug/debug-google-streaming.ts +97 -0
- package/src/debug/debug-tool-execution.ts +86 -0
- package/src/debug/test-lmstudio-tools.ts +155 -0
- package/src/demos/README.md +47 -0
- package/src/demos/basic/universal-llm-examples.ts +161 -0
- package/src/demos/mcp/astrid-memory-demo.ts +295 -0
- package/src/demos/mcp/astrid-persona-memory.ts +357 -0
- package/src/demos/mcp/mcp-mongodb-demo.ts +275 -0
- package/src/demos/mcp/simple-astrid-memory.ts +148 -0
- package/src/demos/mcp/simple-mcp-demo.ts +68 -0
- package/src/demos/mcp/working-mcp-demo.ts +62 -0
- package/src/demos/model-alias-demo.ts +0 -0
- package/src/demos/tools/RAG_MEMORY_INTEGRATION.md +267 -0
- package/src/demos/tools/astrid-memory-demo.ts +270 -0
- package/src/demos/tools/astrid-production-memory-clean.ts +785 -0
- package/src/demos/tools/astrid-production-memory.ts +558 -0
- package/src/demos/tools/basic-translation-test.ts +66 -0
- package/src/demos/tools/chromadb-similarity-tuning.ts +390 -0
- package/src/demos/tools/clean-multilingual-conversation.ts +209 -0
- package/src/demos/tools/clean-translation-test.ts +119 -0
- package/src/demos/tools/clean-universal-multilingual-test.ts +131 -0
- package/src/demos/tools/complete-rag-demo.ts +369 -0
- package/src/demos/tools/complete-tool-demo.ts +132 -0
- package/src/demos/tools/demo-tool-calling.ts +124 -0
- package/src/demos/tools/dynamic-language-switching-test.ts +251 -0
- package/src/demos/tools/hybrid-thinking-test.ts +154 -0
- package/src/demos/tools/memory-integration-test.ts +420 -0
- package/src/demos/tools/multilingual-memory-system.ts +802 -0
- package/src/demos/tools/ondemand-translation-demo.ts +655 -0
- package/src/demos/tools/production-tool-demo.ts +245 -0
- package/src/demos/tools/revolutionary-multilingual-test.ts +151 -0
- package/src/demos/tools/rigorous-language-analysis.ts +218 -0
- package/src/demos/tools/test-universal-memory-system.ts +126 -0
- package/src/demos/tools/translation-integration-guide.ts +346 -0
- package/src/demos/tools/universal-memory-system.ts +560 -0
- package/src/http.ts +247 -0
- package/src/index.ts +161 -0
- package/src/interfaces.ts +657 -0
- package/src/mcp.ts +345 -0
- package/src/providers/anthropic.ts +762 -0
- package/src/providers/google.ts +620 -0
- package/src/providers/index.ts +8 -0
- package/src/providers/ollama.ts +469 -0
- package/src/providers/openai.ts +392 -0
- package/src/router.ts +780 -0
- package/src/stream-decoder.ts +361 -0
- package/src/structured-output.ts +759 -0
- package/src/test-scripts/test-advanced-tools.ts +310 -0
- package/src/test-scripts/test-google-streaming-enhanced.ts +147 -0
- package/src/test-scripts/test-google-streaming.ts +63 -0
- package/src/test-scripts/test-google-system-prompt-comprehensive.ts +189 -0
- package/src/test-scripts/test-mcp-config.ts +28 -0
- package/src/test-scripts/test-mcp-connection.ts +29 -0
- package/src/test-scripts/test-system-message-positions.ts +163 -0
- package/src/test-scripts/test-system-prompt-improvement-demo.ts +83 -0
- package/src/test-scripts/test-tool-calling.ts +231 -0
- package/src/tests/ai-model.test.ts +1614 -0
- package/src/tests/auditor.test.ts +224 -0
- package/src/tests/http.test.ts +200 -0
- package/src/tests/interfaces.test.ts +117 -0
- package/src/tests/providers/google.test.ts +660 -0
- package/src/tests/providers/ollama.test.ts +954 -0
- package/src/tests/providers/openai.test.ts +1122 -0
- package/src/tests/router.test.ts +254 -0
- package/src/tests/stream-decoder.test.ts +179 -0
- package/src/tests/structured-output.test.ts +1450 -0
- package/src/tests/tools.test.ts +175 -0
- package/src/tools.ts +246 -0
- package/src/zod-adapter.ts +72 -0
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RAG Memory System Integration Test
|
|
3
|
+
*
|
|
4
|
+
* Objective validation of memory storage, recall, and filtering capabilities
|
|
5
|
+
* using production ChromaDB and MongoDB services.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import '@dotenvx/dotenvx/config';
|
|
9
|
+
|
|
10
|
+
import { AIModelFactory, ToolBuilder, LLMChatMessage } from '../../index';
|
|
11
|
+
import { ChromaDBService } from '../../../../../src/services/ChromaDBService.js';
|
|
12
|
+
import { DatabaseConnection } from '../../../../../src/database/connection.js';
|
|
13
|
+
import { UserModel, UserGender, UserSexualOrientation } from '../../../../../src/models/User.js';
|
|
14
|
+
|
|
15
|
+
// Core test validation metrics
|
|
16
|
+
interface TestResults {
|
|
17
|
+
storageTests: {
|
|
18
|
+
meaningfulDataStored: number;
|
|
19
|
+
trivialDataFiltered: number;
|
|
20
|
+
emotionalContextCaptured: number;
|
|
21
|
+
};
|
|
22
|
+
recallTests: {
|
|
23
|
+
freshSessionRecalls: number;
|
|
24
|
+
searchQueriesSuccessful: number;
|
|
25
|
+
categoryFiltersWorking: number;
|
|
26
|
+
};
|
|
27
|
+
integrationTests: {
|
|
28
|
+
mongoDbConnected: boolean;
|
|
29
|
+
chromaDbConnected: boolean;
|
|
30
|
+
userCreationWorking: boolean;
|
|
31
|
+
memoryPersistence: boolean;
|
|
32
|
+
};
|
|
33
|
+
overallScore: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function createTestMemoryTools(chromaService: ChromaDBService, userMongoId: string, testResults: TestResults) {
|
|
37
|
+
const storeMemoryTool = ToolBuilder.createTool<{
|
|
38
|
+
category: string;
|
|
39
|
+
information: string;
|
|
40
|
+
importance: 'low' | 'medium' | 'high';
|
|
41
|
+
emotional_context?: string;
|
|
42
|
+
relationship_stage?: string;
|
|
43
|
+
}>(
|
|
44
|
+
'store_memory',
|
|
45
|
+
'Store important personal information for testing',
|
|
46
|
+
{
|
|
47
|
+
properties: {
|
|
48
|
+
category: {
|
|
49
|
+
type: 'string',
|
|
50
|
+
description: 'Category of information',
|
|
51
|
+
enum: ['interests', 'work', 'family', 'dreams', 'preferences', 'experiences', 'personality', 'relationships', 'fears', 'goals', 'values']
|
|
52
|
+
},
|
|
53
|
+
information: {
|
|
54
|
+
type: 'string',
|
|
55
|
+
description: 'The information to remember'
|
|
56
|
+
},
|
|
57
|
+
importance: {
|
|
58
|
+
type: 'string',
|
|
59
|
+
enum: ['low', 'medium', 'high'],
|
|
60
|
+
description: 'Importance level'
|
|
61
|
+
},
|
|
62
|
+
emotional_context: {
|
|
63
|
+
type: 'string',
|
|
64
|
+
description: 'Emotional context when shared'
|
|
65
|
+
},
|
|
66
|
+
relationship_stage: {
|
|
67
|
+
type: 'string',
|
|
68
|
+
description: 'Relationship stage when shared'
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
required: ['category', 'information', 'importance']
|
|
72
|
+
},
|
|
73
|
+
async (args) => {
|
|
74
|
+
try {
|
|
75
|
+
const conversationId = `test_chat_${Date.now()}`;
|
|
76
|
+
const confidence = args.importance === 'high' ? 0.9 : args.importance === 'medium' ? 0.7 : 0.5;
|
|
77
|
+
|
|
78
|
+
const insightId = await chromaService.addInsight(
|
|
79
|
+
userMongoId,
|
|
80
|
+
args.information,
|
|
81
|
+
args.category,
|
|
82
|
+
conversationId,
|
|
83
|
+
confidence,
|
|
84
|
+
'', // userPersonaId - empty for test
|
|
85
|
+
'', // basePersonaId - empty for test
|
|
86
|
+
'user_insight',
|
|
87
|
+
undefined,
|
|
88
|
+
args.emotional_context,
|
|
89
|
+
args.relationship_stage
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
console.log(`โ
STORAGE TEST: Stored ${args.category} data successfully`);
|
|
93
|
+
testResults.storageTests.meaningfulDataStored++;
|
|
94
|
+
|
|
95
|
+
if (args.emotional_context) {
|
|
96
|
+
testResults.storageTests.emotionalContextCaptured++;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
success: true,
|
|
101
|
+
insight_id: insightId,
|
|
102
|
+
message: `Stored ${args.importance} importance ${args.category}`
|
|
103
|
+
};
|
|
104
|
+
} catch (error) {
|
|
105
|
+
console.log(`โ STORAGE TEST: Failed - ${(error as Error).message}`);
|
|
106
|
+
return {
|
|
107
|
+
success: false,
|
|
108
|
+
error: `Storage failed: ${(error as Error).message}`
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
const recallMemoryTool = ToolBuilder.createTool<{
|
|
115
|
+
search_query?: string;
|
|
116
|
+
category?: string;
|
|
117
|
+
limit?: number;
|
|
118
|
+
}>(
|
|
119
|
+
'recall_memories',
|
|
120
|
+
'Retrieve stored memories for testing',
|
|
121
|
+
{
|
|
122
|
+
properties: {
|
|
123
|
+
search_query: {
|
|
124
|
+
type: 'string',
|
|
125
|
+
description: 'Search for specific memories'
|
|
126
|
+
},
|
|
127
|
+
category: {
|
|
128
|
+
type: 'string',
|
|
129
|
+
description: 'Filter by category',
|
|
130
|
+
enum: ['interests', 'work', 'family', 'dreams', 'preferences', 'experiences', 'personality', 'relationships', 'fears', 'goals', 'values']
|
|
131
|
+
},
|
|
132
|
+
limit: {
|
|
133
|
+
type: 'number',
|
|
134
|
+
description: 'Maximum memories to retrieve',
|
|
135
|
+
default: 5
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
async (args) => {
|
|
140
|
+
try {
|
|
141
|
+
console.log(`๐ RECALL TEST: "${args.search_query || args.category || 'all'}"`);
|
|
142
|
+
|
|
143
|
+
let insights;
|
|
144
|
+
|
|
145
|
+
if (args.search_query) {
|
|
146
|
+
const result = await chromaService.searchSimilarInsights(
|
|
147
|
+
userMongoId,
|
|
148
|
+
args.search_query,
|
|
149
|
+
args.limit || 5
|
|
150
|
+
);
|
|
151
|
+
insights = result.insights;
|
|
152
|
+
testResults.recallTests.searchQueriesSuccessful++;
|
|
153
|
+
} else {
|
|
154
|
+
insights = await chromaService.getUserInsightsByCategory(
|
|
155
|
+
userMongoId,
|
|
156
|
+
args.category,
|
|
157
|
+
'', // userPersonaId - empty for test
|
|
158
|
+
args.limit || 5
|
|
159
|
+
);
|
|
160
|
+
testResults.recallTests.categoryFiltersWorking++;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
console.log(` ๐ Found ${insights.length} memories`);
|
|
164
|
+
|
|
165
|
+
return {
|
|
166
|
+
memories: insights.map(insight => ({
|
|
167
|
+
category: insight.category,
|
|
168
|
+
information: insight.content,
|
|
169
|
+
emotional_context: insight.emotionalContext,
|
|
170
|
+
confidence: insight.confidence
|
|
171
|
+
})),
|
|
172
|
+
total_found: insights.length
|
|
173
|
+
};
|
|
174
|
+
} catch (error) {
|
|
175
|
+
console.log(` โ RECALL TEST: Failed - ${(error as Error).message}`);
|
|
176
|
+
return {
|
|
177
|
+
memories: [],
|
|
178
|
+
total_found: 0,
|
|
179
|
+
error: `Recall failed: ${(error as Error).message}`
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
return [storeMemoryTool, recallMemoryTool];
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
async function createTestUser(userId: string): Promise<boolean> {
|
|
189
|
+
try {
|
|
190
|
+
const existingUser = await UserModel.findOne({ userId });
|
|
191
|
+
if (existingUser) {
|
|
192
|
+
console.log(`โ
Test user already exists`);
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const testUser = new UserModel({
|
|
197
|
+
userId,
|
|
198
|
+
preferences: {
|
|
199
|
+
userName: 'Test User',
|
|
200
|
+
userGender: UserGender.PREFER_NOT_TO_SAY,
|
|
201
|
+
userSexualOrientation: UserSexualOrientation.OTHER,
|
|
202
|
+
preferredLanguage: 'en'
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
await testUser.save();
|
|
207
|
+
console.log(`โ
Created test user`);
|
|
208
|
+
return true;
|
|
209
|
+
} catch (error) {
|
|
210
|
+
console.error(`โ Failed to create test user: ${(error as Error).message}`);
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
async function runMemoryIntegrationTest() {
|
|
216
|
+
console.log('๐งช RAG Memory System Integration Test\n');
|
|
217
|
+
|
|
218
|
+
const testResults: TestResults = {
|
|
219
|
+
storageTests: {
|
|
220
|
+
meaningfulDataStored: 0,
|
|
221
|
+
trivialDataFiltered: 0,
|
|
222
|
+
emotionalContextCaptured: 0
|
|
223
|
+
},
|
|
224
|
+
recallTests: {
|
|
225
|
+
freshSessionRecalls: 0,
|
|
226
|
+
searchQueriesSuccessful: 0,
|
|
227
|
+
categoryFiltersWorking: 0
|
|
228
|
+
},
|
|
229
|
+
integrationTests: {
|
|
230
|
+
mongoDbConnected: false,
|
|
231
|
+
chromaDbConnected: false,
|
|
232
|
+
userCreationWorking: false,
|
|
233
|
+
memoryPersistence: false
|
|
234
|
+
},
|
|
235
|
+
overallScore: 0
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
let userId: string = '';
|
|
239
|
+
let userMongoId: string = '';
|
|
240
|
+
let astrid: any = null;
|
|
241
|
+
|
|
242
|
+
try {
|
|
243
|
+
// Test 1: MongoDB Connection
|
|
244
|
+
console.log('๐ง Test 1: MongoDB Connection');
|
|
245
|
+
const dbConnection = DatabaseConnection.getInstance();
|
|
246
|
+
await dbConnection.connect();
|
|
247
|
+
testResults.integrationTests.mongoDbConnected = true;
|
|
248
|
+
console.log('โ
MongoDB: PASS\n');
|
|
249
|
+
|
|
250
|
+
// Test 2: ChromaDB Connection
|
|
251
|
+
console.log('๐ง Test 2: ChromaDB Connection');
|
|
252
|
+
const chromaService = new ChromaDBService();
|
|
253
|
+
await chromaService.initialize();
|
|
254
|
+
testResults.integrationTests.chromaDbConnected = true;
|
|
255
|
+
console.log('โ
ChromaDB: PASS\n');
|
|
256
|
+
|
|
257
|
+
// Test 3: User Management
|
|
258
|
+
console.log('๐ง Test 3: User Management');
|
|
259
|
+
userId = `test_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
260
|
+
const userCreated = await createTestUser(userId);
|
|
261
|
+
if (!userCreated) throw new Error('User creation failed');
|
|
262
|
+
|
|
263
|
+
const user = await UserModel.findOne({ userId });
|
|
264
|
+
if (!user || !user._id) throw new Error('User not found');
|
|
265
|
+
|
|
266
|
+
userMongoId = user._id.toString();
|
|
267
|
+
testResults.integrationTests.userCreationWorking = true;
|
|
268
|
+
console.log('โ
User Management: PASS\n');
|
|
269
|
+
|
|
270
|
+
// Test 4: Memory Tools Setup
|
|
271
|
+
console.log('๐ง Test 4: Memory Tools Setup');
|
|
272
|
+
astrid = AIModelFactory.createOllamaChatModel('qwen3:8b');
|
|
273
|
+
const memoryTools = createTestMemoryTools(chromaService, userMongoId, testResults);
|
|
274
|
+
astrid.registerTools(memoryTools);
|
|
275
|
+
await astrid.ensureReady();
|
|
276
|
+
console.log('โ
Memory Tools: PASS\n');
|
|
277
|
+
|
|
278
|
+
// Test 5: Storage Functionality
|
|
279
|
+
console.log('๐ง Test 5: Storage Tests');
|
|
280
|
+
|
|
281
|
+
const storageTests = [
|
|
282
|
+
{
|
|
283
|
+
input: "I'm a software engineer specializing in healthcare AI",
|
|
284
|
+
category: "work",
|
|
285
|
+
importance: "high" as const,
|
|
286
|
+
expected: "meaningful"
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
input: "My sister has a rare genetic condition",
|
|
290
|
+
category: "family",
|
|
291
|
+
importance: "high" as const,
|
|
292
|
+
emotional_context: "concerned",
|
|
293
|
+
expected: "meaningful"
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
input: "I love hiking in mountains",
|
|
297
|
+
category: "interests",
|
|
298
|
+
importance: "medium" as const,
|
|
299
|
+
expected: "meaningful"
|
|
300
|
+
}
|
|
301
|
+
];
|
|
302
|
+
|
|
303
|
+
for (const test of storageTests) {
|
|
304
|
+
const response = await astrid.chatWithTools([
|
|
305
|
+
{
|
|
306
|
+
role: 'system',
|
|
307
|
+
content: `You are a test assistant. When given personal information, store it using the store_memory tool. Store meaningful information only.`
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
role: 'user',
|
|
311
|
+
content: test.input
|
|
312
|
+
}
|
|
313
|
+
]);
|
|
314
|
+
console.log(` ๐ Storage test: "${test.input.substring(0, 40)}..."`);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// Test 6: Recall Functionality
|
|
318
|
+
console.log('\n๐ง Test 6: Recall Tests');
|
|
319
|
+
|
|
320
|
+
const recallTests = [
|
|
321
|
+
{ query: "work healthcare", type: "search" },
|
|
322
|
+
{ category: "family", type: "category" },
|
|
323
|
+
{ category: "interests", type: "category" }
|
|
324
|
+
];
|
|
325
|
+
|
|
326
|
+
for (const test of recallTests) {
|
|
327
|
+
const response = await astrid.chatWithTools([
|
|
328
|
+
{
|
|
329
|
+
role: 'system',
|
|
330
|
+
content: `You are a test assistant. Use recall_memories to find information about the user.`
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
role: 'user',
|
|
334
|
+
content: test.type === 'search'
|
|
335
|
+
? `Find memories related to: ${test.query}`
|
|
336
|
+
: `Find memories in category: ${test.category}`
|
|
337
|
+
}
|
|
338
|
+
]);
|
|
339
|
+
console.log(` ๐ Recall test: ${test.type} - ${test.query || test.category}`);
|
|
340
|
+
testResults.recallTests.freshSessionRecalls++;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// Test 7: Memory Persistence
|
|
344
|
+
console.log('\n๐ง Test 7: Memory Persistence');
|
|
345
|
+
const allMemories = await chromaService.getUserInsightsByCategory(
|
|
346
|
+
userMongoId,
|
|
347
|
+
undefined,
|
|
348
|
+
'' // userPersonaId - empty for test
|
|
349
|
+
);
|
|
350
|
+
|
|
351
|
+
if (allMemories.length > 0) {
|
|
352
|
+
testResults.integrationTests.memoryPersistence = true;
|
|
353
|
+
console.log(`โ
Memory Persistence: PASS (${allMemories.length} memories stored)`);
|
|
354
|
+
} else {
|
|
355
|
+
console.log('โ Memory Persistence: FAIL (no memories found)');
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// Calculate overall score
|
|
359
|
+
const totalChecks = Object.values(testResults.integrationTests).length +
|
|
360
|
+
testResults.storageTests.meaningfulDataStored +
|
|
361
|
+
testResults.recallTests.freshSessionRecalls;
|
|
362
|
+
|
|
363
|
+
const passedChecks = Object.values(testResults.integrationTests).filter(Boolean).length +
|
|
364
|
+
testResults.storageTests.meaningfulDataStored +
|
|
365
|
+
testResults.recallTests.freshSessionRecalls;
|
|
366
|
+
|
|
367
|
+
testResults.overallScore = Math.round((passedChecks / totalChecks) * 100);
|
|
368
|
+
|
|
369
|
+
// Final Results
|
|
370
|
+
console.log('\n๐ === TEST RESULTS ===');
|
|
371
|
+
console.log(`Overall Score: ${testResults.overallScore}%`);
|
|
372
|
+
console.log('\n๐ง Integration Tests:');
|
|
373
|
+
console.log(` MongoDB Connected: ${testResults.integrationTests.mongoDbConnected ? 'โ
' : 'โ'}`);
|
|
374
|
+
console.log(` ChromaDB Connected: ${testResults.integrationTests.chromaDbConnected ? 'โ
' : 'โ'}`);
|
|
375
|
+
console.log(` User Creation: ${testResults.integrationTests.userCreationWorking ? 'โ
' : 'โ'}`);
|
|
376
|
+
console.log(` Memory Persistence: ${testResults.integrationTests.memoryPersistence ? 'โ
' : 'โ'}`);
|
|
377
|
+
|
|
378
|
+
console.log('\n๐พ Storage Tests:');
|
|
379
|
+
console.log(` Meaningful Data Stored: ${testResults.storageTests.meaningfulDataStored}`);
|
|
380
|
+
console.log(` Emotional Context Captured: ${testResults.storageTests.emotionalContextCaptured}`);
|
|
381
|
+
|
|
382
|
+
console.log('\n๐ Recall Tests:');
|
|
383
|
+
console.log(` Fresh Session Recalls: ${testResults.recallTests.freshSessionRecalls}`);
|
|
384
|
+
console.log(` Search Queries Successful: ${testResults.recallTests.searchQueriesSuccessful}`);
|
|
385
|
+
console.log(` Category Filters Working: ${testResults.recallTests.categoryFiltersWorking}`);
|
|
386
|
+
|
|
387
|
+
console.log('\n๐พ Stored Memories:');
|
|
388
|
+
allMemories.forEach((memory, index) => {
|
|
389
|
+
console.log(` ${index + 1}. [${memory.category?.toUpperCase()}] ${memory.content.substring(0, 80)}...`);
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
} catch (error) {
|
|
393
|
+
console.error(`โ Test failed: ${(error as Error).message}`);
|
|
394
|
+
testResults.overallScore = 0;
|
|
395
|
+
} finally {
|
|
396
|
+
// Cleanup
|
|
397
|
+
if (astrid) astrid.dispose();
|
|
398
|
+
|
|
399
|
+
if (userId) {
|
|
400
|
+
try {
|
|
401
|
+
await UserModel.deleteOne({ userId });
|
|
402
|
+
console.log('\n๐๏ธ Test user cleaned up');
|
|
403
|
+
} catch (cleanupError) {
|
|
404
|
+
console.warn(`โ ๏ธ Cleanup warning: ${(cleanupError as Error).message}`);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
console.log('\n๐งช Memory integration test completed!\n');
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
return testResults;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// Export the test function
|
|
415
|
+
export { runMemoryIntegrationTest };
|
|
416
|
+
|
|
417
|
+
// Run if called directly
|
|
418
|
+
if (require.main === module) {
|
|
419
|
+
runMemoryIntegrationTest().catch(console.error);
|
|
420
|
+
}
|