@bytexbyte/nxtlinq-ai-agent-sdk 1.2.4 → 1.2.6

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/README.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  A powerful AI Agent SDK that supports multiple AI model switching, wallet connection, permission management, and more.
4
4
 
5
+ ## 🚀 What's New in v1.2.4
6
+
7
+ - **🎯 AI Model Switching**: Real-time switching between multiple AI models during conversations
8
+ - **🤖 Multi-Model Support**: Support for Nova, Claude, ChatGPT, Llama, and Gemini
9
+ - **🎨 Enhanced UI**: Model selector dropdown and model badges for messages
10
+ - **💾 Persistent Preferences**: Model selection saved in localStorage
11
+ - **🔧 Improved API**: Enhanced API client with dynamic model endpoints
12
+
5
13
  ## Features
6
14
 
7
15
  - 🤖 **Multiple AI Models Support**: Supports Nova, Claude, ChatGPT, Llama, Gemini, and other AI models
@@ -10,21 +18,39 @@ A powerful AI Agent SDK that supports multiple AI model switching, wallet connec
10
18
  - 🔐 **Permission Management**: AIT (AI Identity Token) based permission control system
11
19
  - 💬 **Real-time Chat**: Context-aware conversation functionality
12
20
  - 🎨 **Customizable UI**: Complete UI components and style customization options
21
+ - 📱 **Responsive Design**: Works seamlessly across different screen sizes
22
+ - 🔒 **Type Safety**: Full TypeScript support with comprehensive type definitions
13
23
 
14
24
  ## Installation
15
25
 
16
26
  ```bash
17
- npm install nxtlinq-ai-agent-sdk
27
+ npm install @bytexbyte/nxtlinq-ai-agent-sdk
18
28
  # or
19
- yarn add nxtlinq-ai-agent-sdk
29
+ yarn add @bytexbyte/nxtlinq-ai-agent-sdk
20
30
  ```
21
31
 
22
- ## Basic Usage
32
+ ## Quick Start
33
+
34
+ ### Basic Configuration
35
+
36
+ ```tsx
37
+ import { ChatBot } from '@bytexbyte/nxtlinq-ai-agent-sdk';
38
+
39
+ function App() {
40
+ return (
41
+ <ChatBot
42
+ serviceId="your-service-id"
43
+ apiKey="your-api-key"
44
+ apiSecret="your-api-secret"
45
+ />
46
+ );
47
+ }
48
+ ```
23
49
 
24
- ### 1. Basic Configuration
50
+ ### AI Model Switching
25
51
 
26
52
  ```tsx
27
- import { ChatBot } from 'nxtlinq-ai-agent-sdk';
53
+ import { ChatBot, DEFAULT_AI_MODELS } from '@bytexbyte/nxtlinq-ai-agent-sdk';
28
54
 
29
55
  function App() {
30
56
  return (
@@ -32,15 +58,23 @@ function App() {
32
58
  serviceId="your-service-id"
33
59
  apiKey="your-api-key"
34
60
  apiSecret="your-api-secret"
61
+ // Enable AI model switching
62
+ showModelSelector={true}
63
+ defaultModelIndex={0} // Start with Nova
64
+ onModelChange={(model) => {
65
+ console.log('Switched to:', model.label);
66
+ // Track model usage
67
+ analytics.track('model_changed', { model: model.value });
68
+ }}
35
69
  />
36
70
  );
37
71
  }
38
72
  ```
39
73
 
40
- ### 2. Custom AI Models
74
+ ### Custom Model Configuration
41
75
 
42
76
  ```tsx
43
- import { ChatBot, DEFAULT_AI_MODELS } from 'nxtlinq-ai-agent-sdk';
77
+ import { ChatBot } from '@bytexbyte/nxtlinq-ai-agent-sdk';
44
78
 
45
79
  function App() {
46
80
  // Custom available AI models
@@ -48,7 +82,7 @@ function App() {
48
82
  { label: 'Nova', value: 'nova' },
49
83
  { label: 'Claude', value: 'claude' },
50
84
  { label: 'ChatGPT', value: 'open-ai' },
51
- // Add more models...
85
+ // Add more models as needed
52
86
  ];
53
87
 
54
88
  return (
@@ -60,17 +94,17 @@ function App() {
60
94
  defaultModelIndex={1} // Default to Claude
61
95
  showModelSelector={true}
62
96
  onModelChange={(model) => {
63
- console.log('Switched to:', model.label);
97
+ console.log('Model changed to:', model.label);
64
98
  }}
65
99
  />
66
100
  );
67
101
  }
68
102
  ```
69
103
 
70
- ### 3. Advanced Configuration
104
+ ### Advanced Configuration
71
105
 
72
106
  ```tsx
73
- import { ChatBot } from 'nxtlinq-ai-agent-sdk';
107
+ import { ChatBot, DEFAULT_AI_MODELS } from '@bytexbyte/nxtlinq-ai-agent-sdk';
74
108
 
75
109
  function App() {
76
110
  return (
@@ -84,18 +118,28 @@ function App() {
84
118
  showModelSelector={true}
85
119
  onModelChange={(model) => {
86
120
  console.log('Model changed to:', model.label);
121
+ // Update user preferences
122
+ localStorage.setItem('preferred-model', model.value);
87
123
  }}
88
124
  // Preset messages
89
125
  presetMessages={[
90
126
  { text: 'Hello, how can you help me?', autoSend: true },
91
- { text: 'I want to know about your services.', autoSend: false }
127
+ { text: 'I want to switch to a different AI model.', autoSend: false },
128
+ { text: 'What are the differences between the available models?', autoSend: false }
92
129
  ]}
93
130
  // Callback functions
94
131
  onMessage={(message) => {
95
- console.log('New message:', message);
132
+ console.log('New message:', {
133
+ content: message.content,
134
+ role: message.role,
135
+ model: message.metadata?.model,
136
+ timestamp: message.timestamp
137
+ });
96
138
  }}
97
139
  onError={(error) => {
98
- console.error('Error:', error);
140
+ console.error('ChatBot error:', error);
141
+ // Add error reporting
142
+ errorReporting.captureException(error);
99
143
  }}
100
144
  onToolUse={async (toolUse) => {
101
145
  console.log('Tool used:', toolUse);
@@ -128,32 +172,32 @@ function App() {
128
172
 
129
173
  ### ChatBot Props
130
174
 
131
- | Property | Type | Default | Description |
132
- |----------|------|---------|-------------|
133
- | `serviceId` | `string` | - | Service ID (required) |
134
- | `apiKey` | `string` | - | API Key (required) |
135
- | `apiSecret` | `string` | - | API Secret (required) |
136
- | `availableModels` | `AIModel[]` | `DEFAULT_AI_MODELS` | Available AI models list |
137
- | `defaultModelIndex` | `number` | `0` | Default selected model index |
138
- | `showModelSelector` | `boolean` | `true` | Whether to show model selector |
139
- | `onModelChange` | `(model: AIModel) => void` | - | Model change callback |
140
- | `presetMessages` | `PresetMessage[]` | `[]` | Preset messages list |
141
- | `placeholder` | `string` | `'Type a message...'` | Input placeholder |
142
- | `className` | `string` | `''` | Custom CSS class name |
143
- | `maxRetries` | `number` | `3` | Maximum retry attempts |
144
- | `retryDelay` | `number` | `1000` | Retry delay (milliseconds) |
145
- | `onMessage` | `(message: Message) => void` | - | Message callback |
146
- | `onError` | `(error: Error) => void` | - | Error callback |
147
- | `onToolUse` | `(toolUse: ToolUse) => Promise<Message \| void>` | - | Tool use callback |
148
- | `onVerifyWallet` | `() => Promise<{token: string} \| undefined>` | - | Wallet verification callback |
149
- | `permissionGroup` | `string` | - | Permission group name |
175
+ | Property | Type | Default | Required | Description |
176
+ |----------|------|---------|----------|-------------|
177
+ | `serviceId` | `string` | - | ✅ | Service ID |
178
+ | `apiKey` | `string` | - | ✅ | API Key |
179
+ | `apiSecret` | `string` | - | ✅ | API Secret |
180
+ | `availableModels` | `AIModel[]` | `DEFAULT_AI_MODELS` | ❌ | Available AI models list |
181
+ | `defaultModelIndex` | `number` | `0` | ❌ | Default selected model index |
182
+ | `showModelSelector` | `boolean` | `true` | ❌ | Whether to show model selector |
183
+ | `onModelChange` | `(model: AIModel) => void` | - | ❌ | Model change callback |
184
+ | `presetMessages` | `PresetMessage[]` | `[]` | ❌ | Preset messages list |
185
+ | `placeholder` | `string` | `'Type a message...'` | ❌ | Input placeholder |
186
+ | `className` | `string` | `''` | ❌ | Custom CSS class name |
187
+ | `maxRetries` | `number` | `3` | ❌ | Maximum retry attempts |
188
+ | `retryDelay` | `number` | `1000` | ❌ | Retry delay (milliseconds) |
189
+ | `onMessage` | `(message: Message) => void` | - | ❌ | Message callback |
190
+ | `onError` | `(error: Error) => void` | - | ❌ | Error callback |
191
+ | `onToolUse` | `(toolUse: ToolUse) => Promise<Message \| void>` | - | ❌ | Tool use callback |
192
+ | `onVerifyWallet` | `() => Promise<{token: string} \| undefined>` | - | ❌ | Wallet verification callback |
193
+ | `permissionGroup` | `string` | - | ❌ | Permission group name |
150
194
 
151
195
  ### AIModel Type
152
196
 
153
197
  ```typescript
154
198
  interface AIModel {
155
- label: string; // Display name
156
- value: string; // Model identifier
199
+ label: string; // Display name (e.g., "Nova", "Claude")
200
+ value: string; // Model identifier (e.g., "nova", "claude")
157
201
  }
158
202
  ```
159
203
 
@@ -169,6 +213,26 @@ const DEFAULT_AI_MODELS = [
169
213
  ];
170
214
  ```
171
215
 
216
+ ### Message Type with Model Metadata
217
+
218
+ ```typescript
219
+ interface Message {
220
+ id: string;
221
+ content: string;
222
+ role: 'user' | 'assistant';
223
+ timestamp: string;
224
+ metadata?: {
225
+ model?: string; // AI model used
226
+ permissions?: string[]; // User permissions
227
+ issuedBy?: string; // Wallet address
228
+ toolUse?: { // Tool call information
229
+ name: string;
230
+ input: Record<string, any>;
231
+ };
232
+ };
233
+ }
234
+ ```
235
+
172
236
  ## Component Usage
173
237
 
174
238
  ### Using Components Individually
@@ -180,7 +244,7 @@ import {
180
244
  ModelSelector,
181
245
  MessageList,
182
246
  MessageInput
183
- } from 'nxtlinq-ai-agent-sdk';
247
+ } from '@bytexbyte/nxtlinq-ai-agent-sdk';
184
248
 
185
249
  function CustomChatBot() {
186
250
  return (
@@ -197,7 +261,7 @@ function CustomChatBot() {
197
261
  }
198
262
  ```
199
263
 
200
- ### Custom Layout
264
+ ### Custom Layout with Model Selector
201
265
 
202
266
  ```tsx
203
267
  import {
@@ -206,7 +270,7 @@ import {
206
270
  ModelSelector,
207
271
  MessageList,
208
272
  MessageInput
209
- } from 'nxtlinq-ai-agent-sdk';
273
+ } from '@bytexbyte/nxtlinq-ai-agent-sdk';
210
274
 
211
275
  function CustomLayout() {
212
276
  const { isOpen, setIsOpen } = useChatBot();
@@ -214,7 +278,7 @@ function CustomLayout() {
214
278
  if (!isOpen) {
215
279
  return (
216
280
  <button onClick={() => setIsOpen(true)}>
217
- Open Chat
281
+ Open AI Agent
218
282
  </button>
219
283
  );
220
284
  }
@@ -274,6 +338,11 @@ function App() {
274
338
  .nxtlinq-model-selector {
275
339
  /* Custom styles */
276
340
  }
341
+
342
+ /* Model badge */
343
+ .nxtlinq-model-badge {
344
+ /* Custom styles */
345
+ }
277
346
  ```
278
347
 
279
348
  ### Inline Style Override
@@ -287,7 +356,9 @@ function App() {
287
356
  style={{
288
357
  '--primary-color': '#007bff',
289
358
  '--secondary-color': '#6c757d',
290
- '--border-radius': '10px'
359
+ '--border-radius': '10px',
360
+ '--model-badge-bg': '#e3f2fd',
361
+ '--model-badge-color': '#1976d2'
291
362
  }}
292
363
  />
293
364
  ```
@@ -303,16 +374,17 @@ function App() {
303
374
  apiSecret="your-api-secret"
304
375
  onModelChange={(model) => {
305
376
  console.log('Model changed to:', model.label);
306
- // You can add analytics tracking here
377
+ // Add analytics tracking
307
378
  analytics.track('model_changed', {
308
379
  model: model.value,
309
- label: model.label
380
+ label: model.label,
381
+ timestamp: new Date().toISOString()
310
382
  });
311
383
  }}
312
384
  />
313
385
  ```
314
386
 
315
- ### Message Events
387
+ ### Message Events with Model Information
316
388
 
317
389
  ```tsx
318
390
  <ChatBot
@@ -321,11 +393,18 @@ function App() {
321
393
  apiSecret="your-api-secret"
322
394
  onMessage={(message) => {
323
395
  console.log('New message:', message);
324
- // You can add message storage or analytics here
396
+ // Track message with model info
325
397
  if (message.role === 'user') {
326
398
  analytics.track('user_message', {
327
399
  content: message.content,
328
- model: message.metadata?.model
400
+ model: message.metadata?.model,
401
+ timestamp: message.timestamp
402
+ });
403
+ } else if (message.role === 'assistant') {
404
+ analytics.track('ai_response', {
405
+ model: message.metadata?.model,
406
+ hasToolUse: !!message.metadata?.toolUse,
407
+ timestamp: message.timestamp
329
408
  });
330
409
  }
331
410
  }}
@@ -341,24 +420,94 @@ function App() {
341
420
  apiSecret="your-api-secret"
342
421
  onError={(error) => {
343
422
  console.error('ChatBot error:', error);
344
- // You can add error reporting here
423
+ // Add error reporting
345
424
  errorReporting.captureException(error);
425
+
426
+ // Track error with context
427
+ analytics.track('chatbot_error', {
428
+ error: error.message,
429
+ stack: error.stack,
430
+ timestamp: new Date().toISOString()
431
+ });
346
432
  }}
347
433
  />
348
434
  ```
349
435
 
350
436
  ## Best Practices
351
437
 
352
- 1. **Model Selection**: Choose appropriate AI models based on use cases
353
- 2. **Error Handling**: Always provide `onError` callback to handle errors
354
- 3. **User Experience**: Use preset messages to guide users
355
- 4. **Performance Optimization**: Set reasonable retry counts and delays
356
- 5. **Security**: Keep API keys secure and use environment variables
438
+ ### 1. Model Selection
439
+ - Choose appropriate AI models based on use cases
440
+ - Consider user preferences and requirements
441
+ - Monitor model performance and usage
442
+
443
+ ### 2. Error Handling
444
+ - Always provide `onError` callback to handle errors
445
+ - Implement proper error reporting and monitoring
446
+ - Provide fallback mechanisms for failed requests
447
+
448
+ ### 3. User Experience
449
+ - Use preset messages to guide users
450
+ - Provide clear model switching feedback
451
+ - Maintain conversation context across model switches
452
+
453
+ ### 4. Performance Optimization
454
+ - Set reasonable retry counts and delays
455
+ - Implement proper loading states
456
+ - Optimize for different network conditions
457
+
458
+ ### 5. Security
459
+ - Keep API keys secure and use environment variables
460
+ - Validate user permissions before tool calls
461
+ - Implement proper wallet verification
462
+
463
+ ## Migration Guide
464
+
465
+ ### From v1.2.3 to v1.2.4
466
+
467
+ 1. **Update package version**:
468
+ ```bash
469
+ npm install @bytexbyte/nxtlinq-ai-agent-sdk@1.2.4
470
+ ```
471
+
472
+ 2. **Add model switching props** (optional):
473
+ ```tsx
474
+ <ChatBot
475
+ // ... existing props
476
+ showModelSelector={true}
477
+ onModelChange={(model) => console.log('Model:', model.label)}
478
+ />
479
+ ```
480
+
481
+ 3. **Update message handling** (if needed):
482
+ ```tsx
483
+ onMessage={(message) => {
484
+ // Now includes model information
485
+ console.log('Model used:', message.metadata?.model);
486
+ }}
487
+ ```
488
+
489
+ ## Changelog
490
+
491
+ ### v1.2.4 (Latest)
492
+ - ✨ **NEW**: AI model switching functionality
493
+ - ✨ **NEW**: Support for 5 AI models (Nova, Claude, ChatGPT, Llama, Gemini)
494
+ - ✨ **NEW**: ModelSelector dropdown component
495
+ - ✨ **NEW**: Model badges in messages
496
+ - ✨ **NEW**: Persistent model preferences
497
+ - 🔧 **IMPROVED**: Enhanced API client with dynamic endpoints
498
+ - 🔧 **IMPROVED**: Better TypeScript types and interfaces
499
+ - 📚 **UPDATED**: Comprehensive documentation and examples
500
+
501
+ ### v1.2.3
502
+ - Initial release with basic functionality
357
503
 
358
- ## License
504
+ ## Support
359
505
 
360
- MIT License
506
+ For questions, issues, or feature requests:
507
+ - 📧 Email: support@nxtlinq.ai
508
+ - 📖 Documentation: https://docs.nxtlinq.ai
509
+ - 🐛 Issues: https://github.com/bytexbyte/nxtlinq-ai-agent-sdk/issues
361
510
 
362
- ## Support
511
+ ## License
363
512
 
364
- For questions or suggestions, please submit an Issue or contact our support team.
513
+ MIT License - see [LICENSE](LICENSE) file for details.
@@ -1 +1 @@
1
- {"version":3,"file":"ChatBotContext.d.ts","sourceRoot":"","sources":["../../../src/components/context/ChatBotContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,OAAO,EACL,kBAAkB,EAClB,YAAY,EAOb,MAAM,uBAAuB,CAAC;AAI/B,eAAO,MAAM,UAAU,0BAMtB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAg6BlD,CAAC"}
1
+ {"version":3,"file":"ChatBotContext.d.ts","sourceRoot":"","sources":["../../../src/components/context/ChatBotContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,OAAO,EACL,kBAAkB,EAClB,YAAY,EAOb,MAAM,uBAAuB,CAAC;AAI/B,eAAO,MAAM,UAAU,0BAMtB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAqpClD,CAAC"}