@bytexbyte/nxtlinq-ai-agent-sdk 1.2.2 → 1.2.4
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 +282 -200
- package/dist/api/nxtlinq-api.d.ts.map +1 -1
- package/dist/api/nxtlinq-api.js +127 -142
- package/dist/components/ChatBot.d.ts +2 -44
- package/dist/components/ChatBot.d.ts.map +1 -1
- package/dist/components/ChatBot.js +5 -1241
- package/dist/components/context/ChatBotContext.d.ts +5 -0
- package/dist/components/context/ChatBotContext.d.ts.map +1 -0
- package/dist/components/context/ChatBotContext.js +865 -0
- package/dist/components/types/ChatBotTypes.d.ts +115 -0
- package/dist/components/types/ChatBotTypes.d.ts.map +1 -0
- package/dist/components/types/ChatBotTypes.js +14 -0
- package/dist/components/ui/ChatBotUI.d.ts +3 -0
- package/dist/components/ui/ChatBotUI.d.ts.map +1 -0
- package/dist/components/ui/ChatBotUI.js +147 -0
- package/dist/components/ui/MessageInput.d.ts +3 -0
- package/dist/components/ui/MessageInput.d.ts.map +1 -0
- package/dist/components/ui/MessageInput.js +46 -0
- package/dist/components/ui/MessageList.d.ts +3 -0
- package/dist/components/ui/MessageList.d.ts.map +1 -0
- package/dist/components/ui/MessageList.js +84 -0
- package/dist/components/ui/ModelSelector.d.ts +3 -0
- package/dist/components/ui/ModelSelector.d.ts.map +1 -0
- package/dist/components/ui/ModelSelector.js +65 -0
- package/dist/components/ui/NotificationModal.d.ts +14 -0
- package/dist/components/ui/NotificationModal.d.ts.map +1 -0
- package/dist/components/ui/NotificationModal.js +79 -0
- package/dist/components/ui/PermissionForm.d.ts +8 -0
- package/dist/components/ui/PermissionForm.d.ts.map +1 -0
- package/dist/components/ui/PermissionForm.js +299 -0
- package/dist/components/ui/PresetMessages.d.ts +3 -0
- package/dist/components/ui/PresetMessages.d.ts.map +1 -0
- package/dist/components/ui/PresetMessages.js +35 -0
- package/dist/core/utils/aitUtils.d.ts +28 -0
- package/dist/core/utils/aitUtils.d.ts.map +1 -0
- package/dist/core/utils/aitUtils.js +34 -0
- package/dist/core/utils/notificationUtils.d.ts +29 -0
- package/dist/core/utils/notificationUtils.d.ts.map +1 -0
- package/dist/core/utils/notificationUtils.js +47 -0
- package/dist/core/utils/walletUtils.d.ts +10 -0
- package/dist/core/utils/walletUtils.d.ts.map +1 -0
- package/dist/core/utils/walletUtils.js +38 -0
- package/dist/index.d.ts +14 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -0
- package/dist/types/ait-api.d.ts +32 -1
- package/dist/types/ait-api.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,113 +1,124 @@
|
|
|
1
1
|
# Nxtlinq AI Agent SDK
|
|
2
2
|
|
|
3
|
-
A powerful SDK
|
|
3
|
+
A powerful AI Agent SDK that supports multiple AI model switching, wallet connection, permission management, and more.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
- 🎨 Customizable
|
|
13
|
-
- 🔌 Easy integration with React applications
|
|
14
|
-
- 🔒 Secure authentication and API key management
|
|
15
|
-
- 👛 MetaMask wallet integration
|
|
16
|
-
- 🔐 AIT (AI Identity Token) management
|
|
17
|
-
- 🔑 Permission-based access control
|
|
18
|
-
- 🔍 Enhanced error handling and debugging
|
|
19
|
-
- ⚡ Improved async operation handling
|
|
20
|
-
- 🔔 Unified notification system with Modal prompts
|
|
7
|
+
- 🤖 **Multiple AI Models Support**: Supports Nova, Claude, ChatGPT, Llama, Gemini, and other AI models
|
|
8
|
+
- 🔄 **Real-time Model Switching**: Users can switch AI models at any time during conversations
|
|
9
|
+
- 👛 **Wallet Integration**: Supports MetaKeep wallet connection and verification
|
|
10
|
+
- 🔐 **Permission Management**: AIT (AI Identity Token) based permission control system
|
|
11
|
+
- 💬 **Real-time Chat**: Context-aware conversation functionality
|
|
12
|
+
- 🎨 **Customizable UI**: Complete UI components and style customization options
|
|
21
13
|
|
|
22
14
|
## Installation
|
|
23
15
|
|
|
24
16
|
```bash
|
|
25
|
-
npm install
|
|
17
|
+
npm install nxtlinq-ai-agent-sdk
|
|
26
18
|
# or
|
|
27
|
-
yarn add
|
|
19
|
+
yarn add nxtlinq-ai-agent-sdk
|
|
28
20
|
```
|
|
29
21
|
|
|
30
|
-
##
|
|
22
|
+
## Basic Usage
|
|
23
|
+
|
|
24
|
+
### 1. Basic Configuration
|
|
31
25
|
|
|
32
26
|
```tsx
|
|
33
|
-
import { ChatBot } from '
|
|
27
|
+
import { ChatBot } from 'nxtlinq-ai-agent-sdk';
|
|
34
28
|
|
|
35
29
|
function App() {
|
|
36
|
-
const handleMessage = (message) => {
|
|
37
|
-
console.log('Received new message:', message);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const handleToolUse = async (toolUse) => {
|
|
41
|
-
console.log('Tool use:', toolUse);
|
|
42
|
-
return {
|
|
43
|
-
id: Date.now().toString(),
|
|
44
|
-
content: 'Tool execution response',
|
|
45
|
-
role: 'assistant',
|
|
46
|
-
timestamp: new Date().toISOString()
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const presetMessages = [
|
|
51
|
-
{ text: 'Hello, how can you help me?' },
|
|
52
|
-
{ text: 'I want to add a new member' },
|
|
53
|
-
{ text: 'I want to view the analytics page' },
|
|
54
|
-
{ text: 'I want to change my name' }
|
|
55
|
-
];
|
|
56
|
-
|
|
57
30
|
return (
|
|
58
31
|
<ChatBot
|
|
59
32
|
serviceId="your-service-id"
|
|
60
33
|
apiKey="your-api-key"
|
|
61
34
|
apiSecret="your-api-secret"
|
|
62
|
-
onMessage={handleMessage}
|
|
63
|
-
onToolUse={handleToolUse}
|
|
64
|
-
presetMessages={presetMessages}
|
|
65
|
-
onVerifyWallet={async () => {
|
|
66
|
-
// Implement Berify.me verification
|
|
67
|
-
return { token: 'verification-token' };
|
|
68
|
-
}}
|
|
69
35
|
/>
|
|
70
36
|
);
|
|
71
37
|
}
|
|
72
38
|
```
|
|
73
39
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
## Berify.me Integration
|
|
77
|
-
|
|
78
|
-
The SDK supports Berify.me wallet verification for enhanced security:
|
|
40
|
+
### 2. Custom AI Models
|
|
79
41
|
|
|
80
42
|
```tsx
|
|
81
|
-
import { ChatBot } from '
|
|
43
|
+
import { ChatBot, DEFAULT_AI_MODELS } from 'nxtlinq-ai-agent-sdk';
|
|
82
44
|
|
|
83
45
|
function App() {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
46
|
+
// Custom available AI models
|
|
47
|
+
const customModels = [
|
|
48
|
+
{ label: 'Nova', value: 'nova' },
|
|
49
|
+
{ label: 'Claude', value: 'claude' },
|
|
50
|
+
{ label: 'ChatGPT', value: 'open-ai' },
|
|
51
|
+
// Add more models...
|
|
52
|
+
];
|
|
91
53
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
54
|
+
return (
|
|
55
|
+
<ChatBot
|
|
56
|
+
serviceId="your-service-id"
|
|
57
|
+
apiKey="your-api-key"
|
|
58
|
+
apiSecret="your-api-secret"
|
|
59
|
+
availableModels={customModels}
|
|
60
|
+
defaultModelIndex={1} // Default to Claude
|
|
61
|
+
showModelSelector={true}
|
|
62
|
+
onModelChange={(model) => {
|
|
63
|
+
console.log('Switched to:', model.label);
|
|
64
|
+
}}
|
|
65
|
+
/>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
```
|
|
100
69
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
70
|
+
### 3. Advanced Configuration
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
import { ChatBot } from 'nxtlinq-ai-agent-sdk';
|
|
104
74
|
|
|
75
|
+
function App() {
|
|
105
76
|
return (
|
|
106
77
|
<ChatBot
|
|
107
78
|
serviceId="your-service-id"
|
|
108
79
|
apiKey="your-api-key"
|
|
109
80
|
apiSecret="your-api-secret"
|
|
110
|
-
|
|
81
|
+
// AI Model configuration
|
|
82
|
+
availableModels={DEFAULT_AI_MODELS}
|
|
83
|
+
defaultModelIndex={0}
|
|
84
|
+
showModelSelector={true}
|
|
85
|
+
onModelChange={(model) => {
|
|
86
|
+
console.log('Model changed to:', model.label);
|
|
87
|
+
}}
|
|
88
|
+
// Preset messages
|
|
89
|
+
presetMessages={[
|
|
90
|
+
{ text: 'Hello, how can you help me?', autoSend: true },
|
|
91
|
+
{ text: 'I want to know about your services.', autoSend: false }
|
|
92
|
+
]}
|
|
93
|
+
// Callback functions
|
|
94
|
+
onMessage={(message) => {
|
|
95
|
+
console.log('New message:', message);
|
|
96
|
+
}}
|
|
97
|
+
onError={(error) => {
|
|
98
|
+
console.error('Error:', error);
|
|
99
|
+
}}
|
|
100
|
+
onToolUse={async (toolUse) => {
|
|
101
|
+
console.log('Tool used:', toolUse);
|
|
102
|
+
// Handle tool calls
|
|
103
|
+
return {
|
|
104
|
+
id: Date.now().toString(),
|
|
105
|
+
content: 'Tool executed successfully',
|
|
106
|
+
role: 'assistant',
|
|
107
|
+
timestamp: new Date().toISOString()
|
|
108
|
+
};
|
|
109
|
+
}}
|
|
110
|
+
// Wallet verification
|
|
111
|
+
onVerifyWallet={async () => {
|
|
112
|
+
// Custom wallet verification logic
|
|
113
|
+
return { token: 'your-token' };
|
|
114
|
+
}}
|
|
115
|
+
// Permission group
|
|
116
|
+
permissionGroup="default"
|
|
117
|
+
// UI configuration
|
|
118
|
+
placeholder="Type your message..."
|
|
119
|
+
className="custom-chatbot"
|
|
120
|
+
maxRetries={3}
|
|
121
|
+
retryDelay={1000}
|
|
111
122
|
/>
|
|
112
123
|
);
|
|
113
124
|
}
|
|
@@ -115,168 +126,239 @@ function App() {
|
|
|
115
126
|
|
|
116
127
|
## API Reference
|
|
117
128
|
|
|
118
|
-
### ChatBot
|
|
119
|
-
|
|
120
|
-
|
|
|
121
|
-
|
|
122
|
-
| serviceId | string |
|
|
123
|
-
| apiKey | string |
|
|
124
|
-
| apiSecret | string |
|
|
125
|
-
|
|
|
126
|
-
|
|
|
127
|
-
|
|
|
128
|
-
|
|
|
129
|
-
| presetMessages | PresetMessage[] |
|
|
130
|
-
| placeholder | string |
|
|
131
|
-
| className | string |
|
|
132
|
-
| maxRetries | number |
|
|
133
|
-
| retryDelay | number |
|
|
134
|
-
|
|
|
129
|
+
### ChatBot Props
|
|
130
|
+
|
|
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 |
|
|
150
|
+
|
|
151
|
+
### AIModel Type
|
|
135
152
|
|
|
136
|
-
|
|
153
|
+
```typescript
|
|
154
|
+
interface AIModel {
|
|
155
|
+
label: string; // Display name
|
|
156
|
+
value: string; // Model identifier
|
|
157
|
+
}
|
|
158
|
+
```
|
|
137
159
|
|
|
138
|
-
|
|
160
|
+
### Default AI Models
|
|
139
161
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
162
|
+
```typescript
|
|
163
|
+
const DEFAULT_AI_MODELS = [
|
|
164
|
+
{ label: 'Nova', value: 'nova' },
|
|
165
|
+
{ label: 'Claude', value: 'claude' },
|
|
166
|
+
{ label: 'ChatGPT', value: 'open-ai' },
|
|
167
|
+
{ label: 'Llama', value: 'llama' },
|
|
168
|
+
{ label: 'Gemini', value: 'gemini' },
|
|
169
|
+
];
|
|
170
|
+
```
|
|
144
171
|
|
|
145
|
-
|
|
172
|
+
## Component Usage
|
|
146
173
|
|
|
147
|
-
|
|
174
|
+
### Using Components Individually
|
|
148
175
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
176
|
+
```tsx
|
|
177
|
+
import {
|
|
178
|
+
ChatBotProvider,
|
|
179
|
+
ChatBotUI,
|
|
180
|
+
ModelSelector,
|
|
181
|
+
MessageList,
|
|
182
|
+
MessageInput
|
|
183
|
+
} from 'nxtlinq-ai-agent-sdk';
|
|
184
|
+
|
|
185
|
+
function CustomChatBot() {
|
|
186
|
+
return (
|
|
187
|
+
<ChatBotProvider
|
|
188
|
+
serviceId="your-service-id"
|
|
189
|
+
apiKey="your-api-key"
|
|
190
|
+
apiSecret="your-api-secret"
|
|
191
|
+
>
|
|
192
|
+
<div className="custom-chatbot-container">
|
|
193
|
+
<ChatBotUI />
|
|
194
|
+
</div>
|
|
195
|
+
</ChatBotProvider>
|
|
196
|
+
);
|
|
158
197
|
}
|
|
159
198
|
```
|
|
160
199
|
|
|
161
|
-
###
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
200
|
+
### Custom Layout
|
|
201
|
+
|
|
202
|
+
```tsx
|
|
203
|
+
import {
|
|
204
|
+
ChatBotProvider,
|
|
205
|
+
useChatBot,
|
|
206
|
+
ModelSelector,
|
|
207
|
+
MessageList,
|
|
208
|
+
MessageInput
|
|
209
|
+
} from 'nxtlinq-ai-agent-sdk';
|
|
210
|
+
|
|
211
|
+
function CustomLayout() {
|
|
212
|
+
const { isOpen, setIsOpen } = useChatBot();
|
|
213
|
+
|
|
214
|
+
if (!isOpen) {
|
|
215
|
+
return (
|
|
216
|
+
<button onClick={() => setIsOpen(true)}>
|
|
217
|
+
Open Chat
|
|
218
|
+
</button>
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return (
|
|
223
|
+
<div className="custom-layout">
|
|
224
|
+
<header>
|
|
225
|
+
<h3>AI Assistant</h3>
|
|
226
|
+
<ModelSelector />
|
|
227
|
+
<button onClick={() => setIsOpen(false)}>Close</button>
|
|
228
|
+
</header>
|
|
229
|
+
<MessageList />
|
|
230
|
+
<MessageInput />
|
|
231
|
+
</div>
|
|
232
|
+
);
|
|
166
233
|
}
|
|
167
|
-
```
|
|
168
234
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
235
|
+
function App() {
|
|
236
|
+
return (
|
|
237
|
+
<ChatBotProvider
|
|
238
|
+
serviceId="your-service-id"
|
|
239
|
+
apiKey="your-api-key"
|
|
240
|
+
apiSecret="your-api-secret"
|
|
241
|
+
>
|
|
242
|
+
<CustomLayout />
|
|
243
|
+
</ChatBotProvider>
|
|
244
|
+
);
|
|
174
245
|
}
|
|
175
246
|
```
|
|
176
247
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
aitId: string;
|
|
181
|
-
controller: string;
|
|
182
|
-
metadata: AITMetadata;
|
|
183
|
-
metadataHash: string;
|
|
184
|
-
metadataCid: string;
|
|
185
|
-
}
|
|
248
|
+
## Style Customization
|
|
249
|
+
|
|
250
|
+
### CSS Classes
|
|
186
251
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
serviceId?: string;
|
|
252
|
+
```css
|
|
253
|
+
/* Main container */
|
|
254
|
+
.nxtlinq-chatbot-container {
|
|
255
|
+
/* Custom styles */
|
|
192
256
|
}
|
|
193
|
-
```
|
|
194
257
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
id: string;
|
|
199
|
-
label: string;
|
|
200
|
-
description: string;
|
|
201
|
-
groups: string[];
|
|
258
|
+
/* Message list */
|
|
259
|
+
.nxtlinq-message-list {
|
|
260
|
+
/* Custom styles */
|
|
202
261
|
}
|
|
203
|
-
```
|
|
204
262
|
|
|
205
|
-
|
|
263
|
+
/* User message */
|
|
264
|
+
.nxtlinq-user-message {
|
|
265
|
+
/* Custom styles */
|
|
266
|
+
}
|
|
206
267
|
|
|
207
|
-
|
|
208
|
-
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
- AIT (AI Identity Token) generation and management
|
|
212
|
-
|
|
213
|
-
### Authentication Flow
|
|
214
|
-
1. Connect MetaMask wallet
|
|
215
|
-
2. Verify wallet ownership (optional, via Berify.me)
|
|
216
|
-
3. Sign in with wallet
|
|
217
|
-
4. Generate and register AIT with required permissions
|
|
218
|
-
5. Use AIT for authenticated operations
|
|
219
|
-
|
|
220
|
-
### Enhanced Error Handling
|
|
221
|
-
- Improved async operation handling
|
|
222
|
-
- Better state management
|
|
223
|
-
- Detailed error messages
|
|
224
|
-
- Comprehensive debugging logs
|
|
268
|
+
/* AI message */
|
|
269
|
+
.nxtlinq-ai-message {
|
|
270
|
+
/* Custom styles */
|
|
271
|
+
}
|
|
225
272
|
|
|
226
|
-
|
|
273
|
+
/* Model selector */
|
|
274
|
+
.nxtlinq-model-selector {
|
|
275
|
+
/* Custom styles */
|
|
276
|
+
}
|
|
277
|
+
```
|
|
227
278
|
|
|
228
|
-
|
|
229
|
-
- Automatic retry mechanism for failed requests
|
|
230
|
-
- Error callback for custom error handling
|
|
231
|
-
- User-friendly error messages
|
|
232
|
-
- Wallet connection error handling
|
|
233
|
-
- Authentication error handling
|
|
234
|
-
- Detailed console logging for debugging
|
|
279
|
+
### Inline Style Override
|
|
235
280
|
|
|
236
|
-
|
|
281
|
+
```tsx
|
|
282
|
+
<ChatBot
|
|
283
|
+
serviceId="your-service-id"
|
|
284
|
+
apiKey="your-api-key"
|
|
285
|
+
apiSecret="your-api-secret"
|
|
286
|
+
className="my-custom-chatbot"
|
|
287
|
+
style={{
|
|
288
|
+
'--primary-color': '#007bff',
|
|
289
|
+
'--secondary-color': '#6c757d',
|
|
290
|
+
'--border-radius': '10px'
|
|
291
|
+
}}
|
|
292
|
+
/>
|
|
293
|
+
```
|
|
237
294
|
|
|
238
|
-
|
|
239
|
-
2. Handle AIT permissions appropriately
|
|
240
|
-
3. Set appropriate timeout values
|
|
241
|
-
4. Implement error retry mechanisms
|
|
242
|
-
5. Use context management to maintain conversation coherence
|
|
243
|
-
6. Handle wallet connection errors gracefully
|
|
244
|
-
7. Implement proper error handling for authentication flow
|
|
245
|
-
8. Monitor console logs for debugging
|
|
295
|
+
## Event Handling
|
|
246
296
|
|
|
247
|
-
|
|
297
|
+
### Model Change Events
|
|
248
298
|
|
|
249
|
-
|
|
299
|
+
```tsx
|
|
300
|
+
<ChatBot
|
|
301
|
+
serviceId="your-service-id"
|
|
302
|
+
apiKey="your-api-key"
|
|
303
|
+
apiSecret="your-api-secret"
|
|
304
|
+
onModelChange={(model) => {
|
|
305
|
+
console.log('Model changed to:', model.label);
|
|
306
|
+
// You can add analytics tracking here
|
|
307
|
+
analytics.track('model_changed', {
|
|
308
|
+
model: model.value,
|
|
309
|
+
label: model.label
|
|
310
|
+
});
|
|
311
|
+
}}
|
|
312
|
+
/>
|
|
313
|
+
```
|
|
250
314
|
|
|
251
|
-
|
|
252
|
-
- Authentication debugging steps
|
|
253
|
-
- Permission issue resolution
|
|
254
|
-
- Best practice recommendations
|
|
315
|
+
### Message Events
|
|
255
316
|
|
|
256
|
-
|
|
317
|
+
```tsx
|
|
318
|
+
<ChatBot
|
|
319
|
+
serviceId="your-service-id"
|
|
320
|
+
apiKey="your-api-key"
|
|
321
|
+
apiSecret="your-api-secret"
|
|
322
|
+
onMessage={(message) => {
|
|
323
|
+
console.log('New message:', message);
|
|
324
|
+
// You can add message storage or analytics here
|
|
325
|
+
if (message.role === 'user') {
|
|
326
|
+
analytics.track('user_message', {
|
|
327
|
+
content: message.content,
|
|
328
|
+
model: message.metadata?.model
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
}}
|
|
332
|
+
/>
|
|
333
|
+
```
|
|
257
334
|
|
|
258
|
-
|
|
259
|
-
A: This is usually due to expired authentication tokens or address mismatches. Check browser console logs and refer to the [Troubleshooting Guide](./TROUBLESHOOTING.md) for detailed solutions.
|
|
335
|
+
## Error Handling
|
|
260
336
|
|
|
261
|
-
|
|
262
|
-
|
|
337
|
+
```tsx
|
|
338
|
+
<ChatBot
|
|
339
|
+
serviceId="your-service-id"
|
|
340
|
+
apiKey="your-api-key"
|
|
341
|
+
apiSecret="your-api-secret"
|
|
342
|
+
onError={(error) => {
|
|
343
|
+
console.error('ChatBot error:', error);
|
|
344
|
+
// You can add error reporting here
|
|
345
|
+
errorReporting.captureException(error);
|
|
346
|
+
}}
|
|
347
|
+
/>
|
|
348
|
+
```
|
|
263
349
|
|
|
264
|
-
##
|
|
350
|
+
## Best Practices
|
|
265
351
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
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
|
|
271
357
|
|
|
272
358
|
## License
|
|
273
359
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
Copyright (c) 2025 ByteXByte. All rights reserved.
|
|
277
|
-
|
|
278
|
-
This software and associated documentation files (the "Software") are proprietary and confidential. The Software is protected by copyright laws and international copyright treaties, as well as other intellectual property laws and treaties.
|
|
360
|
+
MIT License
|
|
279
361
|
|
|
280
|
-
|
|
362
|
+
## Support
|
|
281
363
|
|
|
282
|
-
For
|
|
364
|
+
For questions or suggestions, please submit an Issue or contact our support team.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nxtlinq-api.d.ts","sourceRoot":"","sources":["../../src/api/nxtlinq-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"nxtlinq-api.d.ts","sourceRoot":"","sources":["../../src/api/nxtlinq-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AA6L1C,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,EAAE,WAAW,MAAM,KAAG,MASpE,CAAC"}
|