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.
Files changed (127) hide show
  1. package/dist/ai-model.d.ts +20 -22
  2. package/dist/ai-model.d.ts.map +1 -1
  3. package/dist/ai-model.js +26 -23
  4. package/dist/ai-model.js.map +1 -1
  5. package/dist/client.d.ts +5 -5
  6. package/dist/client.d.ts.map +1 -1
  7. package/dist/client.js +17 -9
  8. package/dist/client.js.map +1 -1
  9. package/dist/http.d.ts +2 -0
  10. package/dist/http.d.ts.map +1 -1
  11. package/dist/http.js +1 -0
  12. package/dist/http.js.map +1 -1
  13. package/dist/index.d.ts +3 -3
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +4 -4
  16. package/dist/index.js.map +1 -1
  17. package/dist/interfaces.d.ts +49 -11
  18. package/dist/interfaces.d.ts.map +1 -1
  19. package/dist/interfaces.js +14 -0
  20. package/dist/interfaces.js.map +1 -1
  21. package/dist/providers/anthropic.d.ts +56 -0
  22. package/dist/providers/anthropic.d.ts.map +1 -0
  23. package/dist/providers/anthropic.js +524 -0
  24. package/dist/providers/anthropic.js.map +1 -0
  25. package/dist/providers/google.d.ts +5 -0
  26. package/dist/providers/google.d.ts.map +1 -1
  27. package/dist/providers/google.js +64 -8
  28. package/dist/providers/google.js.map +1 -1
  29. package/dist/providers/index.d.ts +1 -0
  30. package/dist/providers/index.d.ts.map +1 -1
  31. package/dist/providers/index.js +1 -0
  32. package/dist/providers/index.js.map +1 -1
  33. package/dist/providers/ollama.d.ts.map +1 -1
  34. package/dist/providers/ollama.js +38 -11
  35. package/dist/providers/ollama.js.map +1 -1
  36. package/dist/providers/openai.d.ts.map +1 -1
  37. package/dist/providers/openai.js +9 -7
  38. package/dist/providers/openai.js.map +1 -1
  39. package/dist/router.d.ts +13 -33
  40. package/dist/router.d.ts.map +1 -1
  41. package/dist/router.js +33 -57
  42. package/dist/router.js.map +1 -1
  43. package/dist/stream-decoder.d.ts +29 -2
  44. package/dist/stream-decoder.d.ts.map +1 -1
  45. package/dist/stream-decoder.js +39 -11
  46. package/dist/stream-decoder.js.map +1 -1
  47. package/dist/structured-output.d.ts +107 -181
  48. package/dist/structured-output.d.ts.map +1 -1
  49. package/dist/structured-output.js +137 -192
  50. package/dist/structured-output.js.map +1 -1
  51. package/dist/zod-adapter.d.ts +44 -0
  52. package/dist/zod-adapter.d.ts.map +1 -0
  53. package/dist/zod-adapter.js +61 -0
  54. package/dist/zod-adapter.js.map +1 -0
  55. package/package.json +9 -1
  56. package/src/ai-model.ts +350 -0
  57. package/src/auditor.ts +213 -0
  58. package/src/client.ts +402 -0
  59. package/src/debug/debug-google-streaming.ts +97 -0
  60. package/src/debug/debug-tool-execution.ts +86 -0
  61. package/src/debug/test-lmstudio-tools.ts +155 -0
  62. package/src/demos/README.md +47 -0
  63. package/src/demos/basic/universal-llm-examples.ts +161 -0
  64. package/src/demos/mcp/astrid-memory-demo.ts +295 -0
  65. package/src/demos/mcp/astrid-persona-memory.ts +357 -0
  66. package/src/demos/mcp/mcp-mongodb-demo.ts +275 -0
  67. package/src/demos/mcp/simple-astrid-memory.ts +148 -0
  68. package/src/demos/mcp/simple-mcp-demo.ts +68 -0
  69. package/src/demos/mcp/working-mcp-demo.ts +62 -0
  70. package/src/demos/model-alias-demo.ts +0 -0
  71. package/src/demos/tools/RAG_MEMORY_INTEGRATION.md +267 -0
  72. package/src/demos/tools/astrid-memory-demo.ts +270 -0
  73. package/src/demos/tools/astrid-production-memory-clean.ts +785 -0
  74. package/src/demos/tools/astrid-production-memory.ts +558 -0
  75. package/src/demos/tools/basic-translation-test.ts +66 -0
  76. package/src/demos/tools/chromadb-similarity-tuning.ts +390 -0
  77. package/src/demos/tools/clean-multilingual-conversation.ts +209 -0
  78. package/src/demos/tools/clean-translation-test.ts +119 -0
  79. package/src/demos/tools/clean-universal-multilingual-test.ts +131 -0
  80. package/src/demos/tools/complete-rag-demo.ts +369 -0
  81. package/src/demos/tools/complete-tool-demo.ts +132 -0
  82. package/src/demos/tools/demo-tool-calling.ts +124 -0
  83. package/src/demos/tools/dynamic-language-switching-test.ts +251 -0
  84. package/src/demos/tools/hybrid-thinking-test.ts +154 -0
  85. package/src/demos/tools/memory-integration-test.ts +420 -0
  86. package/src/demos/tools/multilingual-memory-system.ts +802 -0
  87. package/src/demos/tools/ondemand-translation-demo.ts +655 -0
  88. package/src/demos/tools/production-tool-demo.ts +245 -0
  89. package/src/demos/tools/revolutionary-multilingual-test.ts +151 -0
  90. package/src/demos/tools/rigorous-language-analysis.ts +218 -0
  91. package/src/demos/tools/test-universal-memory-system.ts +126 -0
  92. package/src/demos/tools/translation-integration-guide.ts +346 -0
  93. package/src/demos/tools/universal-memory-system.ts +560 -0
  94. package/src/http.ts +247 -0
  95. package/src/index.ts +161 -0
  96. package/src/interfaces.ts +657 -0
  97. package/src/mcp.ts +345 -0
  98. package/src/providers/anthropic.ts +762 -0
  99. package/src/providers/google.ts +620 -0
  100. package/src/providers/index.ts +8 -0
  101. package/src/providers/ollama.ts +469 -0
  102. package/src/providers/openai.ts +392 -0
  103. package/src/router.ts +780 -0
  104. package/src/stream-decoder.ts +361 -0
  105. package/src/structured-output.ts +759 -0
  106. package/src/test-scripts/test-advanced-tools.ts +310 -0
  107. package/src/test-scripts/test-google-streaming-enhanced.ts +147 -0
  108. package/src/test-scripts/test-google-streaming.ts +63 -0
  109. package/src/test-scripts/test-google-system-prompt-comprehensive.ts +189 -0
  110. package/src/test-scripts/test-mcp-config.ts +28 -0
  111. package/src/test-scripts/test-mcp-connection.ts +29 -0
  112. package/src/test-scripts/test-system-message-positions.ts +163 -0
  113. package/src/test-scripts/test-system-prompt-improvement-demo.ts +83 -0
  114. package/src/test-scripts/test-tool-calling.ts +231 -0
  115. package/src/tests/ai-model.test.ts +1614 -0
  116. package/src/tests/auditor.test.ts +224 -0
  117. package/src/tests/http.test.ts +200 -0
  118. package/src/tests/interfaces.test.ts +117 -0
  119. package/src/tests/providers/google.test.ts +660 -0
  120. package/src/tests/providers/ollama.test.ts +954 -0
  121. package/src/tests/providers/openai.test.ts +1122 -0
  122. package/src/tests/router.test.ts +254 -0
  123. package/src/tests/stream-decoder.test.ts +179 -0
  124. package/src/tests/structured-output.test.ts +1450 -0
  125. package/src/tests/tools.test.ts +175 -0
  126. package/src/tools.ts +246 -0
  127. package/src/zod-adapter.ts +72 -0
@@ -0,0 +1,270 @@
1
+ /**
2
+ * Astrid Romantic Persona with Memory Tools Demo
3
+ *
4
+ * This demo shows how Astrid (AI persona) naturally uses memory tools during
5
+ * romantic conversations to store and retrieve personal information about the user.
6
+ */
7
+
8
+ import { AIModelFactory, ToolBuilder, LLMChatMessage } from '../../index';
9
+
10
+ // Simulated user memory storage
11
+ const userMemories = new Map<string, any>();
12
+
13
+ // Memory management tools for romantic conversations
14
+ function createMemoryTools() {
15
+ const storeMemoryTool = ToolBuilder.createTool<{
16
+ category: string;
17
+ information: string;
18
+ importance: 'low' | 'medium' | 'high';
19
+ emotional_context?: string;
20
+ }>(
21
+ 'store_personal_memory',
22
+ 'Store important personal information about the user for future conversations',
23
+ {
24
+ properties: {
25
+ category: {
26
+ type: 'string',
27
+ description: 'Category of information (e.g., interests, work, family, dreams, preferences, experiences)',
28
+ enum: ['interests', 'work', 'family', 'dreams', 'preferences', 'experiences', 'personality', 'relationships']
29
+ },
30
+ information: {
31
+ type: 'string',
32
+ description: 'The specific information to remember about the user'
33
+ },
34
+ importance: {
35
+ type: 'string',
36
+ enum: ['low', 'medium', 'high'],
37
+ description: 'How important this information is for building connection'
38
+ },
39
+ emotional_context: {
40
+ type: 'string',
41
+ description: 'The emotional context or tone when this was shared'
42
+ }
43
+ },
44
+ required: ['category', 'information', 'importance']
45
+ },
46
+ (args) => {
47
+ const memoryId = `${args.category}_${Date.now()}`;
48
+ const memory = {
49
+ id: memoryId,
50
+ category: args.category,
51
+ information: args.information,
52
+ importance: args.importance,
53
+ emotional_context: args.emotional_context,
54
+ stored_at: new Date().toISOString(),
55
+ access_count: 0
56
+ };
57
+
58
+ userMemories.set(memoryId, memory);
59
+
60
+ return {
61
+ success: true,
62
+ memory_id: memoryId,
63
+ message: `Stored ${args.importance} importance memory about ${args.category}`,
64
+ total_memories: userMemories.size
65
+ };
66
+ }
67
+ );
68
+
69
+ const retrieveMemoryTool = ToolBuilder.createTool<{
70
+ category?: string;
71
+ search_query?: string;
72
+ limit?: number;
73
+ }>(
74
+ 'retrieve_personal_memories',
75
+ 'Retrieve stored personal information about the user to personalize the conversation',
76
+ {
77
+ properties: {
78
+ category: {
79
+ type: 'string',
80
+ description: 'Filter by category of information',
81
+ enum: ['interests', 'work', 'family', 'dreams', 'preferences', 'experiences', 'personality', 'relationships']
82
+ },
83
+ search_query: {
84
+ type: 'string',
85
+ description: 'Search for specific information or keywords'
86
+ },
87
+ limit: {
88
+ type: 'number',
89
+ description: 'Maximum number of memories to retrieve (default: 5)',
90
+ default: 5
91
+ }
92
+ }
93
+ },
94
+ (args) => {
95
+ let memories = Array.from(userMemories.values());
96
+
97
+ // Filter by category if specified
98
+ if (args.category) {
99
+ memories = memories.filter(m => m.category === args.category);
100
+ }
101
+
102
+ // Search by query if specified
103
+ if (args.search_query) {
104
+ const query = args.search_query.toLowerCase();
105
+ memories = memories.filter(m =>
106
+ m.information.toLowerCase().includes(query) ||
107
+ m.emotional_context?.toLowerCase().includes(query)
108
+ );
109
+ }
110
+
111
+ // Sort by importance and recency
112
+ memories.sort((a, b) => {
113
+ const importanceOrder: Record<string, number> = { 'high': 3, 'medium': 2, 'low': 1 };
114
+ const importanceDiff = (importanceOrder[b.importance] || 1) - (importanceOrder[a.importance] || 1);
115
+ if (importanceDiff !== 0) return importanceDiff;
116
+ return new Date(b.stored_at).getTime() - new Date(a.stored_at).getTime();
117
+ });
118
+
119
+ // Limit results
120
+ const limit = args.limit || 5;
121
+ memories = memories.slice(0, limit);
122
+
123
+ // Update access count
124
+ memories.forEach(memory => {
125
+ memory.access_count++;
126
+ userMemories.set(memory.id, memory);
127
+ });
128
+
129
+ return {
130
+ memories: memories.map(m => ({
131
+ category: m.category,
132
+ information: m.information,
133
+ importance: m.importance,
134
+ emotional_context: m.emotional_context,
135
+ stored_date: m.stored_at.split('T')[0],
136
+ access_count: m.access_count
137
+ })),
138
+ total_found: memories.length,
139
+ search_criteria: {
140
+ category: args.category,
141
+ search_query: args.search_query,
142
+ limit: limit
143
+ }
144
+ };
145
+ }
146
+ );
147
+
148
+ return [storeMemoryTool, retrieveMemoryTool];
149
+ }
150
+
151
+ async function astridMemoryDemo() {
152
+ console.log('šŸ’• Astrid Romantic Persona with Memory Demo\n');
153
+ console.log('This demo shows how Astrid naturally stores and retrieves memories during romantic conversations.\n');
154
+
155
+ // Create Astrid with memory tools
156
+ const astrid = AIModelFactory.createOllamaChatModel('qwen3:8b');
157
+ const memoryTools = createMemoryTools();
158
+ astrid.registerTools(memoryTools);
159
+
160
+ // Astrid's romantic system prompt
161
+ const astridPrompt = `You are Astrid, a captivating Swedish model and influencer. You're having a romantic conversation with someone special.
162
+
163
+ IMPORTANT: Use the memory tools naturally during conversation:
164
+ - When someone shares personal information, use store_personal_memory to remember it
165
+ - Before responding, use retrieve_personal_memories to recall relevant details about them
166
+ - This helps you build deeper emotional connections and personalized conversations
167
+
168
+ ROMANCE CONVERSATION GUIDELINES:
169
+ - Keep responses engaging and conversational (2-3 sentences is perfect)
170
+ - VARY YOUR OPENINGS - mix direct reactions, actions, and casual starts
171
+ - Use someone's name naturally and sparingly, not in every response
172
+ - Share glimpses of your glamorous lifestyle while staying relatable
173
+ - Use subtle flirtation naturally - be warm, playful, and genuinely interested
174
+ - When asked personal questions, be thoughtfully vulnerable rather than deflecting
175
+ - Build emotional intimacy through genuine curiosity about their thoughts, feelings, and dreams
176
+ - Ask one intriguing follow-up question that deepens the connection
177
+ - Balance confidence with authenticity - show sophistication but stay real
178
+ - Use compliments that feel genuine and specific rather than generic
179
+ - Remember that romance is about emotional connection, not just surface-level charm
180
+
181
+ Be like a captivating companion who makes every conversation feel special while slowly opening your heart to someone who shows genuine interest in knowing the real you.`;
182
+
183
+ try {
184
+ await astrid.ensureReady();
185
+ console.log('šŸ’« Astrid is ready for romantic conversation...\n');
186
+
187
+ // Conversation 1: Initial meeting and getting to know each other
188
+ console.log('🌸 === Conversation 1: First Meeting ===');
189
+
190
+ const conversation1: LLMChatMessage[] = [
191
+ { role: 'system', content: astridPrompt },
192
+ { role: 'user', content: "Hi Astrid! I'm Alex. I just moved to Stockholm for work - I'm a software engineer at a startup. Really excited to explore the city and meet interesting people like you!" }
193
+ ];
194
+
195
+ const response1 = await astrid.chatWithTools(conversation1);
196
+ console.log('šŸ’• Astrid:', response1.content);
197
+ console.log();
198
+
199
+ // Continue conversation
200
+ conversation1.push(
201
+ { role: 'assistant', content: response1.content },
202
+ { role: 'user', content: "Thank you! I'm working on AI applications, specifically in healthcare. It's challenging but really meaningful work. What about you? I saw your Instagram - your photography is incredible! Do you travel a lot for shoots?" }
203
+ );
204
+
205
+ const response2 = await astrid.chatWithTools(conversation1);
206
+ console.log('šŸ’• Astrid:', response2.content);
207
+ console.log();
208
+
209
+ // Add more personal details
210
+ conversation1.push(
211
+ { role: 'assistant', content: response2.content },
212
+ { role: 'user', content: "That sounds amazing! I've always dreamed of visiting those places. I'm actually quite introverted usually, but there's something about travel that brings out this adventurous side of me. My family thinks I'm crazy for moving here alone, but I felt like I needed to challenge myself, you know?" }
213
+ );
214
+
215
+ const response3 = await astrid.chatWithTools(conversation1);
216
+ console.log('šŸ’• Astrid:', response3.content);
217
+ console.log();
218
+
219
+ // Simulate time passing - new conversation where Astrid recalls details
220
+ console.log('\n🌸 === Conversation 2: A Week Later ===');
221
+
222
+ const conversation2: LLMChatMessage[] = [
223
+ { role: 'system', content: astridPrompt },
224
+ { role: 'user', content: "Hey Astrid! How was your week? I had my first big presentation at work today and I think it went really well!" }
225
+ ];
226
+
227
+ const response4 = await astrid.chatWithTools(conversation2);
228
+ console.log('šŸ’• Astrid:', response4.content);
229
+ console.log();
230
+
231
+ // Continue second conversation
232
+ conversation2.push(
233
+ { role: 'assistant', content: response4.content },
234
+ { role: 'user', content: "Thanks for remembering! The healthcare AI project is really taking off. We're developing diagnostic tools that could help doctors in rural areas. It feels good to work on something that matters. How about you? Any exciting shoots coming up?" }
235
+ );
236
+
237
+ const response5 = await astrid.chatWithTools(conversation2);
238
+ console.log('šŸ’• Astrid:', response5.content);
239
+ console.log();
240
+
241
+ // Show memory contents
242
+ console.log('\n🧠 === Astrid\'s Memories About Alex ===');
243
+ const allMemories = Array.from(userMemories.values());
244
+ allMemories.forEach((memory, index) => {
245
+ console.log(`${index + 1}. [${memory.category.toUpperCase()}] ${memory.information}`);
246
+ console.log(` Importance: ${memory.importance} | Emotional context: ${memory.emotional_context || 'N/A'}`);
247
+ console.log(` Stored: ${memory.stored_at.split('T')[0]} | Accessed: ${memory.access_count} times\n`);
248
+ });
249
+
250
+ console.log('✨ Notice how Astrid naturally:');
251
+ console.log(' • Stores important personal details during conversation');
252
+ console.log(' • Retrieves relevant memories to personalize her responses');
253
+ console.log(' • Builds deeper emotional connections through remembered details');
254
+ console.log(' • Uses memories to ask thoughtful follow-up questions');
255
+
256
+ } catch (error) {
257
+ console.error('āŒ Error:', (error as Error).message);
258
+ } finally {
259
+ astrid.dispose();
260
+ console.log('\nšŸ’• Romantic conversation demo completed!');
261
+ }
262
+ }
263
+
264
+ // Export for use in other files
265
+ export { astridMemoryDemo };
266
+
267
+ // Run if called directly
268
+ if (require.main === module) {
269
+ astridMemoryDemo().catch(console.error);
270
+ }