@bytexbyte/nxtlinq-ai-agent-sdk 1.2.3 → 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 +275 -147
- package/dist/api/nxtlinq-api.d.ts.map +1 -1
- package/dist/api/nxtlinq-api.js +8 -2
- package/dist/components/context/ChatBotContext.d.ts.map +1 -1
- package/dist/components/context/ChatBotContext.js +173 -45
- package/dist/components/types/ChatBotTypes.d.ts +17 -0
- package/dist/components/types/ChatBotTypes.d.ts.map +1 -1
- package/dist/components/types/ChatBotTypes.js +14 -1
- package/dist/components/ui/ChatBotUI.d.ts.map +1 -1
- package/dist/components/ui/ChatBotUI.js +2 -1
- package/dist/components/ui/MessageList.d.ts.map +1 -1
- package/dist/components/ui/MessageList.js +46 -16
- 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/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -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,29 +1,30 @@
|
|
|
1
1
|
# Nxtlinq AI Agent SDK
|
|
2
2
|
|
|
3
|
-
A
|
|
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
|
-
- **Permission
|
|
11
|
-
- **Real-time Chat**:
|
|
12
|
-
- **
|
|
13
|
-
- **Responsive UI**: Modern user interface design
|
|
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
|
|
14
13
|
|
|
15
|
-
##
|
|
14
|
+
## Installation
|
|
16
15
|
|
|
17
16
|
```bash
|
|
18
|
-
npm install
|
|
17
|
+
npm install nxtlinq-ai-agent-sdk
|
|
18
|
+
# or
|
|
19
|
+
yarn add nxtlinq-ai-agent-sdk
|
|
19
20
|
```
|
|
20
21
|
|
|
21
|
-
##
|
|
22
|
+
## Basic Usage
|
|
22
23
|
|
|
23
|
-
### Basic
|
|
24
|
+
### 1. Basic Configuration
|
|
24
25
|
|
|
25
26
|
```tsx
|
|
26
|
-
import { ChatBot } from '
|
|
27
|
+
import { ChatBot } from 'nxtlinq-ai-agent-sdk';
|
|
27
28
|
|
|
28
29
|
function App() {
|
|
29
30
|
return (
|
|
@@ -31,21 +32,45 @@ function App() {
|
|
|
31
32
|
serviceId="your-service-id"
|
|
32
33
|
apiKey="your-api-key"
|
|
33
34
|
apiSecret="your-api-secret"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 2. Custom AI Models
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import { ChatBot, DEFAULT_AI_MODELS } from 'nxtlinq-ai-agent-sdk';
|
|
44
|
+
|
|
45
|
+
function App() {
|
|
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
|
+
];
|
|
53
|
+
|
|
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);
|
|
39
64
|
}}
|
|
40
65
|
/>
|
|
41
66
|
);
|
|
42
67
|
}
|
|
43
68
|
```
|
|
44
69
|
|
|
45
|
-
### Advanced Configuration
|
|
70
|
+
### 3. Advanced Configuration
|
|
46
71
|
|
|
47
72
|
```tsx
|
|
48
|
-
import { ChatBot } from '
|
|
73
|
+
import { ChatBot } from 'nxtlinq-ai-agent-sdk';
|
|
49
74
|
|
|
50
75
|
function App() {
|
|
51
76
|
return (
|
|
@@ -53,184 +78,287 @@ function App() {
|
|
|
53
78
|
serviceId="your-service-id"
|
|
54
79
|
apiKey="your-api-key"
|
|
55
80
|
apiSecret="your-api-secret"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
|
60
89
|
presetMessages={[
|
|
61
|
-
{ text:
|
|
62
|
-
{ text:
|
|
90
|
+
{ text: 'Hello, how can you help me?', autoSend: true },
|
|
91
|
+
{ text: 'I want to know about your services.', autoSend: false }
|
|
63
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
|
|
64
111
|
onVerifyWallet={async () => {
|
|
65
112
|
// Custom wallet verification logic
|
|
66
|
-
return { token:
|
|
113
|
+
return { token: 'your-token' };
|
|
67
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}
|
|
68
122
|
/>
|
|
69
123
|
);
|
|
70
124
|
}
|
|
71
125
|
```
|
|
72
126
|
|
|
73
|
-
##
|
|
74
|
-
|
|
75
|
-
```
|
|
76
|
-
src/
|
|
77
|
-
├── components/ # React Components
|
|
78
|
-
│ ├── ChatBot.tsx # Main component entry
|
|
79
|
-
│ ├── context/ # Context and state management
|
|
80
|
-
│ │ └── ChatBotContext.tsx
|
|
81
|
-
│ ├── types/ # Type definitions
|
|
82
|
-
│ │ └── ChatBotTypes.ts
|
|
83
|
-
│ └── ui/ # UI Components
|
|
84
|
-
│ ├── ChatBotUI.tsx
|
|
85
|
-
│ ├── MessageList.tsx
|
|
86
|
-
│ ├── MessageInput.tsx
|
|
87
|
-
│ ├── PresetMessages.tsx
|
|
88
|
-
│ ├── PermissionForm.tsx
|
|
89
|
-
│ └── NotificationModal.tsx
|
|
90
|
-
├── api/ # API Layer
|
|
91
|
-
│ └── nxtlinq-api.ts # API Client
|
|
92
|
-
├── core/ # Core functionality
|
|
93
|
-
│ ├── metakeepClient.ts
|
|
94
|
-
│ ├── lib/ # Utility libraries
|
|
95
|
-
│ │ └── useLocalStorage.ts
|
|
96
|
-
│ └── utils/ # Utility functions
|
|
97
|
-
│ ├── walletUtils.ts
|
|
98
|
-
│ ├── aitUtils.ts
|
|
99
|
-
│ └── notificationUtils.ts
|
|
100
|
-
├── types/ # Global type definitions
|
|
101
|
-
│ ├── ait-api.ts
|
|
102
|
-
│ └── window.d.ts
|
|
103
|
-
└── index.ts # Main entry file
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
## 🔧 API Reference
|
|
127
|
+
## API Reference
|
|
107
128
|
|
|
108
129
|
### ChatBot Props
|
|
109
130
|
|
|
110
|
-
| Property | Type |
|
|
111
|
-
|
|
112
|
-
| `serviceId` | `string` |
|
|
113
|
-
| `apiKey` | `string` |
|
|
114
|
-
| `apiSecret` | `string` |
|
|
115
|
-
| `
|
|
116
|
-
| `
|
|
117
|
-
| `
|
|
118
|
-
| `
|
|
119
|
-
| `
|
|
120
|
-
| `
|
|
121
|
-
| `
|
|
122
|
-
| `
|
|
123
|
-
| `
|
|
124
|
-
| `
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
disconnectWallet();
|
|
138
|
-
|
|
139
|
-
// Validate token
|
|
140
|
-
const isValid = validateToken(token, address);
|
|
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
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
interface AIModel {
|
|
155
|
+
label: string; // Display name
|
|
156
|
+
value: string; // Model identifier
|
|
157
|
+
}
|
|
141
158
|
```
|
|
142
159
|
|
|
143
|
-
|
|
160
|
+
### Default AI Models
|
|
144
161
|
|
|
145
|
-
```
|
|
146
|
-
|
|
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
|
+
```
|
|
147
171
|
|
|
148
|
-
|
|
149
|
-
const aitId = generateAITId(address);
|
|
172
|
+
## Component Usage
|
|
150
173
|
|
|
151
|
-
|
|
152
|
-
const metadata = createAITMetadata(permissions, address);
|
|
174
|
+
### Using Components Individually
|
|
153
175
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
+
);
|
|
197
|
+
}
|
|
160
198
|
```
|
|
161
199
|
|
|
162
|
-
|
|
200
|
+
### Custom Layout
|
|
163
201
|
|
|
164
202
|
```tsx
|
|
165
|
-
import {
|
|
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
|
+
}
|
|
166
221
|
|
|
167
|
-
|
|
168
|
-
|
|
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
|
+
);
|
|
233
|
+
}
|
|
169
234
|
|
|
170
|
-
|
|
171
|
-
|
|
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
|
+
);
|
|
245
|
+
}
|
|
172
246
|
```
|
|
173
247
|
|
|
174
|
-
##
|
|
248
|
+
## Style Customization
|
|
175
249
|
|
|
176
|
-
|
|
250
|
+
### CSS Classes
|
|
177
251
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
252
|
+
```css
|
|
253
|
+
/* Main container */
|
|
254
|
+
.nxtlinq-chatbot-container {
|
|
255
|
+
/* Custom styles */
|
|
256
|
+
}
|
|
182
257
|
|
|
183
|
-
|
|
258
|
+
/* Message list */
|
|
259
|
+
.nxtlinq-message-list {
|
|
260
|
+
/* Custom styles */
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/* User message */
|
|
264
|
+
.nxtlinq-user-message {
|
|
265
|
+
/* Custom styles */
|
|
266
|
+
}
|
|
184
267
|
|
|
185
|
-
|
|
268
|
+
/* AI message */
|
|
269
|
+
.nxtlinq-ai-message {
|
|
270
|
+
/* Custom styles */
|
|
271
|
+
}
|
|
186
272
|
|
|
187
|
-
|
|
188
|
-
.nxtlinq-
|
|
273
|
+
/* Model selector */
|
|
274
|
+
.nxtlinq-model-selector {
|
|
189
275
|
/* Custom styles */
|
|
190
|
-
border-radius: 15px;
|
|
191
|
-
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
|
|
192
276
|
}
|
|
193
277
|
```
|
|
194
278
|
|
|
195
|
-
|
|
279
|
+
### Inline Style Override
|
|
196
280
|
|
|
197
|
-
|
|
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
|
+
```
|
|
198
294
|
|
|
199
|
-
|
|
200
|
-
- Ensure MetaKeep extension is installed
|
|
201
|
-
- Check network connection
|
|
295
|
+
## Event Handling
|
|
202
296
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
297
|
+
### Model Change Events
|
|
298
|
+
|
|
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
|
+
```
|
|
206
314
|
|
|
207
|
-
|
|
208
|
-
- Check network connection
|
|
209
|
-
- Verify API key and secret
|
|
315
|
+
### Message Events
|
|
210
316
|
|
|
211
|
-
|
|
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
|
+
```
|
|
212
334
|
|
|
213
|
-
|
|
335
|
+
## Error Handling
|
|
214
336
|
|
|
215
337
|
```tsx
|
|
216
338
|
<ChatBot
|
|
217
|
-
|
|
339
|
+
serviceId="your-service-id"
|
|
340
|
+
apiKey="your-api-key"
|
|
341
|
+
apiSecret="your-api-secret"
|
|
218
342
|
onError={(error) => {
|
|
219
|
-
console.error('ChatBot
|
|
343
|
+
console.error('ChatBot error:', error);
|
|
344
|
+
// You can add error reporting here
|
|
345
|
+
errorReporting.captureException(error);
|
|
220
346
|
}}
|
|
221
347
|
/>
|
|
222
348
|
```
|
|
223
349
|
|
|
224
|
-
##
|
|
350
|
+
## Best Practices
|
|
225
351
|
|
|
226
|
-
|
|
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
|
|
227
357
|
|
|
228
|
-
##
|
|
358
|
+
## License
|
|
229
359
|
|
|
230
|
-
|
|
360
|
+
MIT License
|
|
231
361
|
|
|
232
|
-
##
|
|
362
|
+
## Support
|
|
233
363
|
|
|
234
|
-
For questions, please contact
|
|
235
|
-
- Email: support@nxtlinq.ai
|
|
236
|
-
- Documentation: https://docs.nxtlinq.ai
|
|
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"}
|
package/dist/api/nxtlinq-api.js
CHANGED
|
@@ -71,12 +71,18 @@ const createAuthApi = (apiKey, apiSecret) => ({
|
|
|
71
71
|
const createAgentApi = () => ({
|
|
72
72
|
sendMessage: async (params) => {
|
|
73
73
|
try {
|
|
74
|
-
const
|
|
74
|
+
const model = params.model || 'nova';
|
|
75
|
+
const response = await fetch(`${AI_AGENT_API_HOST}/api/${model}`, {
|
|
75
76
|
method: 'POST',
|
|
76
77
|
headers: {
|
|
77
78
|
'Content-Type': 'application/json',
|
|
78
79
|
},
|
|
79
|
-
body: JSON.stringify(
|
|
80
|
+
body: JSON.stringify({
|
|
81
|
+
apiKey: params.apiKey,
|
|
82
|
+
apiSecret: params.apiSecret,
|
|
83
|
+
message: params.message,
|
|
84
|
+
context: params.context || []
|
|
85
|
+
}),
|
|
80
86
|
});
|
|
81
87
|
if (!response.ok) {
|
|
82
88
|
throw new Error('Failed to send message');
|
|
@@ -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,
|
|
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"}
|
|
@@ -5,6 +5,7 @@ import { createNxtlinqApi } from '../../api/nxtlinq-api';
|
|
|
5
5
|
import stringify from 'fast-json-stable-stringify';
|
|
6
6
|
import metakeepClient from '../../core/metakeepClient';
|
|
7
7
|
import useLocalStorage from '../../core/lib/useLocalStorage';
|
|
8
|
+
import { DEFAULT_AI_MODELS } from '../types/ChatBotTypes';
|
|
8
9
|
const ChatBotContext = React.createContext(undefined);
|
|
9
10
|
export const useChatBot = () => {
|
|
10
11
|
const context = React.useContext(ChatBotContext);
|
|
@@ -13,7 +14,9 @@ export const useChatBot = () => {
|
|
|
13
14
|
}
|
|
14
15
|
return context;
|
|
15
16
|
};
|
|
16
|
-
export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages = [], placeholder = 'Type a message...', className = '', maxRetries = 3, retryDelay = 1000, serviceId, apiKey, apiSecret, onVerifyWallet, permissionGroup, children
|
|
17
|
+
export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages = [], placeholder = 'Type a message...', className = '', maxRetries = 3, retryDelay = 1000, serviceId, apiKey, apiSecret, onVerifyWallet, permissionGroup, children,
|
|
18
|
+
// AI Model related attributes
|
|
19
|
+
availableModels = DEFAULT_AI_MODELS, defaultModelIndex = 0, showModelSelector = true, onModelChange }) => {
|
|
17
20
|
// State
|
|
18
21
|
const [messages, setMessages] = React.useState([]);
|
|
19
22
|
const [inputValue, setInputValue] = React.useState('');
|
|
@@ -38,6 +41,9 @@ export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages
|
|
|
38
41
|
autoHide: true,
|
|
39
42
|
duration: 5000
|
|
40
43
|
});
|
|
44
|
+
// AI Model related state
|
|
45
|
+
const [selectedModelIndex, setSelectedModelIndex] = useLocalStorage('selectedAIModelIndex', defaultModelIndex);
|
|
46
|
+
const [showModelSelectorState, setShowModelSelectorState] = React.useState(showModelSelector);
|
|
41
47
|
const nxtlinqApi = React.useMemo(() => createNxtlinqApi(apiKey, apiSecret), [apiKey, apiSecret]);
|
|
42
48
|
// Notification functions
|
|
43
49
|
const showNotification = (type, message, duration = 5000) => {
|
|
@@ -336,55 +342,155 @@ export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages
|
|
|
336
342
|
}
|
|
337
343
|
return true;
|
|
338
344
|
};
|
|
339
|
-
//
|
|
345
|
+
// AI Model related functions
|
|
346
|
+
const handleModelChange = React.useCallback((modelIndex) => {
|
|
347
|
+
setSelectedModelIndex(modelIndex);
|
|
348
|
+
const selectedModel = availableModels[modelIndex];
|
|
349
|
+
onModelChange?.(selectedModel);
|
|
350
|
+
}, [availableModels, onModelChange]);
|
|
351
|
+
const getCurrentModel = React.useCallback(() => {
|
|
352
|
+
return availableModels[selectedModelIndex];
|
|
353
|
+
}, [availableModels, selectedModelIndex]);
|
|
354
|
+
// Updated sendMessage function to support different AI models
|
|
340
355
|
const sendMessage = async (content, retryCount = 0) => {
|
|
356
|
+
if (!content.trim() || isLoading)
|
|
357
|
+
return;
|
|
358
|
+
const currentModel = getCurrentModel();
|
|
359
|
+
const userMessage = {
|
|
360
|
+
id: Date.now().toString(),
|
|
361
|
+
content,
|
|
362
|
+
role: 'user',
|
|
363
|
+
timestamp: new Date().toISOString(),
|
|
364
|
+
metadata: {
|
|
365
|
+
model: currentModel.value,
|
|
366
|
+
permissions: permissions,
|
|
367
|
+
issuedBy: hitAddress || ''
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
setMessages(prev => [...prev, userMessage]);
|
|
371
|
+
setInputValue('');
|
|
372
|
+
setIsLoading(true);
|
|
341
373
|
try {
|
|
342
|
-
|
|
374
|
+
// Build context messages
|
|
375
|
+
const contextMessages = messages.map(msg => ({
|
|
376
|
+
role: msg.role,
|
|
377
|
+
text: msg.content
|
|
378
|
+
}));
|
|
343
379
|
const response = await nxtlinqApi.agent.sendMessage({
|
|
344
380
|
message: content,
|
|
345
381
|
apiKey,
|
|
346
382
|
apiSecret,
|
|
383
|
+
model: currentModel.value,
|
|
384
|
+
context: contextMessages
|
|
347
385
|
});
|
|
348
386
|
if ('error' in response) {
|
|
349
387
|
throw new Error(response.error);
|
|
350
388
|
}
|
|
351
|
-
|
|
352
|
-
if (
|
|
389
|
+
let botResponse;
|
|
390
|
+
if (response.toolCall?.toolUse) {
|
|
391
|
+
// Handle tool calls
|
|
392
|
+
const toolUse = response.toolCall.toolUse;
|
|
353
393
|
if (onToolUse) {
|
|
354
|
-
const
|
|
355
|
-
if (
|
|
356
|
-
|
|
394
|
+
const toolResult = await onToolUse(toolUse);
|
|
395
|
+
if (toolResult) {
|
|
396
|
+
// Ensure the tool result has model information
|
|
397
|
+
botResponse = {
|
|
398
|
+
...toolResult,
|
|
399
|
+
metadata: {
|
|
400
|
+
...toolResult.metadata,
|
|
401
|
+
model: currentModel.value,
|
|
402
|
+
permissions: permissions,
|
|
403
|
+
issuedBy: hitAddress || '',
|
|
404
|
+
toolUse: toolUse
|
|
405
|
+
}
|
|
406
|
+
};
|
|
357
407
|
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
408
|
+
else {
|
|
409
|
+
botResponse = {
|
|
410
|
+
id: (Date.now() + 1).toString(),
|
|
411
|
+
content: `Tool ${toolUse.name} executed successfully`,
|
|
412
|
+
role: 'assistant',
|
|
413
|
+
timestamp: new Date().toISOString(),
|
|
414
|
+
metadata: {
|
|
415
|
+
model: currentModel.value,
|
|
416
|
+
permissions: permissions,
|
|
417
|
+
issuedBy: hitAddress || '',
|
|
418
|
+
toolUse: toolUse
|
|
419
|
+
}
|
|
420
|
+
};
|
|
362
421
|
}
|
|
363
422
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
.join(' ') || '';
|
|
369
|
-
if (replyText) {
|
|
370
|
-
const message = {
|
|
371
|
-
id: Date.now().toString(),
|
|
372
|
-
content: replyText,
|
|
423
|
+
else {
|
|
424
|
+
botResponse = {
|
|
425
|
+
id: (Date.now() + 1).toString(),
|
|
426
|
+
content: `Tool ${toolUse.name} executed successfully`,
|
|
373
427
|
role: 'assistant',
|
|
374
|
-
timestamp: new Date().toISOString()
|
|
428
|
+
timestamp: new Date().toISOString(),
|
|
429
|
+
metadata: {
|
|
430
|
+
model: currentModel.value,
|
|
431
|
+
permissions: permissions,
|
|
432
|
+
issuedBy: hitAddress || '',
|
|
433
|
+
toolUse: toolUse
|
|
434
|
+
}
|
|
375
435
|
};
|
|
376
|
-
setMessages(prev => [...prev, message]);
|
|
377
|
-
return;
|
|
378
436
|
}
|
|
379
437
|
}
|
|
380
|
-
|
|
438
|
+
else if (response.reply) {
|
|
439
|
+
const replyText = Array.isArray(response.reply)
|
|
440
|
+
? response.reply
|
|
441
|
+
.map((item) => item.text.replace(/<thinking>/g, '').replace(/<\/thinking>/g, ''))
|
|
442
|
+
.join(' ') || 'Sorry, I cannot understand your question'
|
|
443
|
+
: response.reply.replace(/<thinking>/g, '').replace(/<\/thinking>/g, '') || 'Sorry, I cannot understand your question';
|
|
444
|
+
botResponse = {
|
|
445
|
+
id: (Date.now() + 1).toString(),
|
|
446
|
+
content: replyText,
|
|
447
|
+
role: 'assistant',
|
|
448
|
+
timestamp: new Date().toISOString(),
|
|
449
|
+
metadata: {
|
|
450
|
+
model: currentModel.value,
|
|
451
|
+
permissions: permissions,
|
|
452
|
+
issuedBy: hitAddress || ''
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
else {
|
|
457
|
+
const replyText = response.fullResponse?.output?.message?.content
|
|
458
|
+
?.find((item) => item.text)?.text || 'Sorry, I cannot understand your question';
|
|
459
|
+
botResponse = {
|
|
460
|
+
id: (Date.now() + 1).toString(),
|
|
461
|
+
content: replyText,
|
|
462
|
+
role: 'assistant',
|
|
463
|
+
timestamp: new Date().toISOString(),
|
|
464
|
+
metadata: {
|
|
465
|
+
model: currentModel.value,
|
|
466
|
+
permissions: permissions,
|
|
467
|
+
issuedBy: hitAddress || ''
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
setMessages(prev => [...prev, botResponse]);
|
|
381
472
|
}
|
|
382
473
|
catch (error) {
|
|
474
|
+
console.error('Failed to send message:', error);
|
|
383
475
|
if (retryCount < maxRetries) {
|
|
384
|
-
|
|
385
|
-
|
|
476
|
+
setTimeout(() => {
|
|
477
|
+
sendMessage(content, retryCount + 1);
|
|
478
|
+
}, retryDelay);
|
|
479
|
+
return;
|
|
386
480
|
}
|
|
387
|
-
|
|
481
|
+
const errorMessage = {
|
|
482
|
+
id: (Date.now() + 1).toString(),
|
|
483
|
+
content: error instanceof Error ? error.message : 'An error occurred while sending the message',
|
|
484
|
+
role: 'assistant',
|
|
485
|
+
timestamp: new Date().toISOString(),
|
|
486
|
+
metadata: {
|
|
487
|
+
model: currentModel.value,
|
|
488
|
+
permissions: permissions,
|
|
489
|
+
issuedBy: hitAddress || ''
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
setMessages(prev => [...prev, errorMessage]);
|
|
493
|
+
onError?.(error instanceof Error ? error : new Error('Unknown error'));
|
|
388
494
|
}
|
|
389
495
|
finally {
|
|
390
496
|
setIsLoading(false);
|
|
@@ -401,20 +507,16 @@ export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages
|
|
|
401
507
|
id: Date.now().toString(),
|
|
402
508
|
content: 'Loading your wallet configuration... Please wait a moment.',
|
|
403
509
|
role: 'assistant',
|
|
404
|
-
timestamp: new Date().toISOString()
|
|
510
|
+
timestamp: new Date().toISOString(),
|
|
511
|
+
metadata: {
|
|
512
|
+
model: getCurrentModel().value,
|
|
513
|
+
permissions: permissions,
|
|
514
|
+
issuedBy: hitAddress || ''
|
|
515
|
+
}
|
|
405
516
|
};
|
|
406
517
|
setMessages(prev => [...prev, loadingMessage]);
|
|
407
518
|
return;
|
|
408
519
|
}
|
|
409
|
-
const userMessage = {
|
|
410
|
-
id: Date.now().toString(),
|
|
411
|
-
content: inputValue,
|
|
412
|
-
role: 'user',
|
|
413
|
-
timestamp: new Date().toISOString()
|
|
414
|
-
};
|
|
415
|
-
setMessages(prev => [...prev, userMessage]);
|
|
416
|
-
setInputValue('');
|
|
417
|
-
setIsLoading(true);
|
|
418
520
|
try {
|
|
419
521
|
await sendMessage(inputValue);
|
|
420
522
|
}
|
|
@@ -425,13 +527,15 @@ export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages
|
|
|
425
527
|
id: Date.now().toString(),
|
|
426
528
|
content: 'Sorry, there was an error processing your message. Please try again.',
|
|
427
529
|
role: 'assistant',
|
|
428
|
-
timestamp: new Date().toISOString()
|
|
530
|
+
timestamp: new Date().toISOString(),
|
|
531
|
+
metadata: {
|
|
532
|
+
model: getCurrentModel().value,
|
|
533
|
+
permissions: permissions,
|
|
534
|
+
issuedBy: hitAddress || ''
|
|
535
|
+
}
|
|
429
536
|
};
|
|
430
537
|
setMessages(prev => [...prev, errorMessage]);
|
|
431
538
|
}
|
|
432
|
-
finally {
|
|
433
|
-
setIsLoading(false);
|
|
434
|
-
}
|
|
435
539
|
};
|
|
436
540
|
// Handle preset message
|
|
437
541
|
const handlePresetMessage = (message) => {
|
|
@@ -441,7 +545,12 @@ export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages
|
|
|
441
545
|
id: Date.now().toString(),
|
|
442
546
|
content: 'Loading your wallet configuration... Please wait a moment.',
|
|
443
547
|
role: 'assistant',
|
|
444
|
-
timestamp: new Date().toISOString()
|
|
548
|
+
timestamp: new Date().toISOString(),
|
|
549
|
+
metadata: {
|
|
550
|
+
model: getCurrentModel().value,
|
|
551
|
+
permissions: permissions,
|
|
552
|
+
issuedBy: hitAddress || ''
|
|
553
|
+
}
|
|
445
554
|
};
|
|
446
555
|
setMessages(prev => [...prev, loadingMessage]);
|
|
447
556
|
return;
|
|
@@ -451,7 +560,12 @@ export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages
|
|
|
451
560
|
id: Date.now().toString(),
|
|
452
561
|
content: message.text,
|
|
453
562
|
role: 'user',
|
|
454
|
-
timestamp: new Date().toISOString()
|
|
563
|
+
timestamp: new Date().toISOString(),
|
|
564
|
+
metadata: {
|
|
565
|
+
model: getCurrentModel().value,
|
|
566
|
+
permissions: permissions,
|
|
567
|
+
issuedBy: hitAddress || ''
|
|
568
|
+
}
|
|
455
569
|
}]);
|
|
456
570
|
sendMessage(message.text);
|
|
457
571
|
}
|
|
@@ -685,6 +799,10 @@ export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages
|
|
|
685
799
|
walletInfo,
|
|
686
800
|
isWalletLoading,
|
|
687
801
|
notification,
|
|
802
|
+
// AI Model related state
|
|
803
|
+
availableModels,
|
|
804
|
+
selectedModelIndex,
|
|
805
|
+
showModelSelector: showModelSelectorState,
|
|
688
806
|
// Actions
|
|
689
807
|
setInputValue,
|
|
690
808
|
setIsOpen,
|
|
@@ -694,6 +812,9 @@ export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages
|
|
|
694
812
|
setIsDisabled,
|
|
695
813
|
setIsWalletLoading,
|
|
696
814
|
setNotification,
|
|
815
|
+
// AI Model related actions
|
|
816
|
+
setSelectedModelIndex,
|
|
817
|
+
setShowModelSelector: setShowModelSelectorState,
|
|
697
818
|
// Functions
|
|
698
819
|
connectWallet,
|
|
699
820
|
signInWallet,
|
|
@@ -707,6 +828,9 @@ export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages
|
|
|
707
828
|
showWarning,
|
|
708
829
|
showInfo,
|
|
709
830
|
refreshAIT,
|
|
831
|
+
// AI Model related functions
|
|
832
|
+
handleModelChange,
|
|
833
|
+
getCurrentModel,
|
|
710
834
|
// Additional properties for PermissionForm
|
|
711
835
|
onSave: savePermissions,
|
|
712
836
|
onConnectWallet: () => connectWallet(false),
|
|
@@ -729,7 +853,11 @@ export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages
|
|
|
729
853
|
apiKey,
|
|
730
854
|
apiSecret,
|
|
731
855
|
onVerifyWallet,
|
|
732
|
-
permissionGroup
|
|
856
|
+
permissionGroup,
|
|
857
|
+
availableModels,
|
|
858
|
+
defaultModelIndex,
|
|
859
|
+
showModelSelector,
|
|
860
|
+
onModelChange
|
|
733
861
|
},
|
|
734
862
|
nxtlinqApi
|
|
735
863
|
};
|
|
@@ -25,6 +25,12 @@ export interface AITMetadata {
|
|
|
25
25
|
permissions: string[];
|
|
26
26
|
issuedBy: string;
|
|
27
27
|
}
|
|
28
|
+
export interface AIModel {
|
|
29
|
+
label: string;
|
|
30
|
+
value: string;
|
|
31
|
+
}
|
|
32
|
+
export declare const DEFAULT_AI_MODELS: AIModel[];
|
|
33
|
+
export declare const AI_MODEL_MAP: Record<string, string>;
|
|
28
34
|
export interface ChatBotProps {
|
|
29
35
|
onMessage?: (message: Message) => void;
|
|
30
36
|
onError?: (error: Error) => void;
|
|
@@ -42,6 +48,10 @@ export interface ChatBotProps {
|
|
|
42
48
|
} | undefined>;
|
|
43
49
|
permissionGroup?: string;
|
|
44
50
|
children?: React.ReactNode;
|
|
51
|
+
availableModels?: AIModel[];
|
|
52
|
+
defaultModelIndex?: number;
|
|
53
|
+
showModelSelector?: boolean;
|
|
54
|
+
onModelChange?: (model: AIModel) => void;
|
|
45
55
|
}
|
|
46
56
|
export interface ChatBotContextType {
|
|
47
57
|
messages: Message[];
|
|
@@ -65,6 +75,9 @@ export interface ChatBotContextType {
|
|
|
65
75
|
autoHide?: boolean;
|
|
66
76
|
duration?: number;
|
|
67
77
|
};
|
|
78
|
+
availableModels: AIModel[];
|
|
79
|
+
selectedModelIndex: number;
|
|
80
|
+
showModelSelector: boolean;
|
|
68
81
|
setInputValue: (value: string) => void;
|
|
69
82
|
setIsOpen: (open: boolean) => void;
|
|
70
83
|
setShowPermissionForm: (show: boolean) => void;
|
|
@@ -73,6 +86,8 @@ export interface ChatBotContextType {
|
|
|
73
86
|
setIsDisabled: (disabled: boolean) => void;
|
|
74
87
|
setIsWalletLoading: (loading: boolean) => void;
|
|
75
88
|
setNotification: (notification: any) => void;
|
|
89
|
+
setSelectedModelIndex: (index: number) => void;
|
|
90
|
+
setShowModelSelector: (show: boolean) => void;
|
|
76
91
|
connectWallet: (autoShowSignInMessage?: boolean) => Promise<string | undefined>;
|
|
77
92
|
signInWallet: (autoShowSuccessMessage?: boolean) => Promise<void>;
|
|
78
93
|
sendMessage: (content: string, retryCount?: number) => Promise<void>;
|
|
@@ -85,6 +100,8 @@ export interface ChatBotContextType {
|
|
|
85
100
|
showWarning: (message: string) => void;
|
|
86
101
|
showInfo: (message: string) => void;
|
|
87
102
|
refreshAIT: (forceUpdatePermissions?: boolean) => Promise<void>;
|
|
103
|
+
handleModelChange: (modelIndex: number) => void;
|
|
104
|
+
getCurrentModel: () => AIModel;
|
|
88
105
|
onSave: () => Promise<void>;
|
|
89
106
|
onConnectWallet: () => Promise<string | undefined>;
|
|
90
107
|
onSignIn: () => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBotTypes.d.ts","sourceRoot":"","sources":["../../../src/components/types/ChatBotTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE9E,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC5B;AAED,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/B,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,WAA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AAI,CAAC;IACvC,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,UAAU,EAAE,CAAC,sBAAsB,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhE,iBAAiB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,eAAe,EAAE,MAAM,OAAO,CAAC;IAG/B,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,eAAe,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACnD,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,sBAAsB,EAAE,OAAO,CAAC;IAChC,cAAc,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IAGzB,KAAK,EAAE,YAAY,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -1 +1,14 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const DEFAULT_AI_MODELS = [
|
|
2
|
+
{ label: 'Nova', value: 'nova' },
|
|
3
|
+
{ label: 'Claude', value: 'claude' },
|
|
4
|
+
{ label: 'ChatGPT', value: 'open-ai' },
|
|
5
|
+
{ label: 'Llama', value: 'llama' },
|
|
6
|
+
{ label: 'Gemini', value: 'gemini' },
|
|
7
|
+
];
|
|
8
|
+
export const AI_MODEL_MAP = {
|
|
9
|
+
nova: 'Nova',
|
|
10
|
+
claude: 'Claude',
|
|
11
|
+
'open-ai': 'ChatGPT',
|
|
12
|
+
llama: 'Llama',
|
|
13
|
+
gemini: 'Gemini',
|
|
14
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBotUI.d.ts","sourceRoot":"","sources":["../../../src/components/ui/ChatBotUI.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ChatBotUI.d.ts","sourceRoot":"","sources":["../../../src/components/ui/ChatBotUI.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAS/B,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAsP7B,CAAC"}
|
|
@@ -6,6 +6,7 @@ import { PermissionForm } from './PermissionForm';
|
|
|
6
6
|
import { MessageList } from './MessageList';
|
|
7
7
|
import { MessageInput } from './MessageInput';
|
|
8
8
|
import { PresetMessages } from './PresetMessages';
|
|
9
|
+
import { ModelSelector } from './ModelSelector';
|
|
9
10
|
export const ChatBotUI = () => {
|
|
10
11
|
const { isOpen, setIsOpen, showPermissionForm, setShowPermissionForm, notification, setNotification, isAITLoading, props: { className = '' } } = useChatBot();
|
|
11
12
|
// Add CSS animation for loading spinner
|
|
@@ -90,7 +91,7 @@ export const ChatBotUI = () => {
|
|
|
90
91
|
margin: 0,
|
|
91
92
|
fontSize: '16px',
|
|
92
93
|
fontWeight: '600'
|
|
93
|
-
}, children: "AI Agent" }), isAITLoading && (_jsxs("div", { style: {
|
|
94
|
+
}, children: "AI Agent" }), _jsx("div", { style: { position: 'relative' }, children: _jsx(ModelSelector, {}) }), isAITLoading && (_jsxs("div", { style: {
|
|
94
95
|
display: 'flex',
|
|
95
96
|
alignItems: 'center',
|
|
96
97
|
gap: '5px',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageList.d.ts","sourceRoot":"","sources":["../../../src/components/ui/MessageList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"MessageList.d.ts","sourceRoot":"","sources":["../../../src/components/ui/MessageList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAyI/B,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useChatBot } from '../context/ChatBotContext';
|
|
4
|
+
import { AI_MODEL_MAP } from '../types/ChatBotTypes';
|
|
4
5
|
export const MessageList = () => {
|
|
5
6
|
const { messages, isLoading, connectWallet, signInWallet, hitAddress, ait, setShowPermissionForm, isWalletLoading } = useChatBot();
|
|
6
7
|
const messagesEndRef = React.useRef(null);
|
|
@@ -18,6 +19,11 @@ export const MessageList = () => {
|
|
|
18
19
|
signInWallet(true);
|
|
19
20
|
}
|
|
20
21
|
};
|
|
22
|
+
const getModelDisplayName = (modelValue) => {
|
|
23
|
+
if (!modelValue)
|
|
24
|
+
return '';
|
|
25
|
+
return AI_MODEL_MAP[modelValue] || modelValue;
|
|
26
|
+
};
|
|
21
27
|
return (_jsxs("div", { style: {
|
|
22
28
|
flex: 1,
|
|
23
29
|
padding: '15px',
|
|
@@ -27,23 +33,47 @@ export const MessageList = () => {
|
|
|
27
33
|
gap: '10px'
|
|
28
34
|
}, children: [messages.map((message) => (_jsxs("div", { style: {
|
|
29
35
|
alignSelf: message.role === 'user' ? 'flex-end' : 'flex-start',
|
|
30
|
-
backgroundColor: message.role === 'user' ? '#007bff' : '#f1f1f1',
|
|
31
|
-
color: message.role === 'user' ? 'white' : '#333',
|
|
32
|
-
padding: '10px 15px',
|
|
33
|
-
borderRadius: '15px',
|
|
34
36
|
maxWidth: '80%',
|
|
35
|
-
marginBottom: '10px'
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
37
|
+
marginBottom: '10px'
|
|
38
|
+
}, children: [_jsxs("div", { style: {
|
|
39
|
+
backgroundColor: message.role === 'user' ? '#007bff' : '#f1f1f1',
|
|
40
|
+
color: message.role === 'user' ? 'white' : '#333',
|
|
41
|
+
padding: '10px 15px',
|
|
42
|
+
borderRadius: '15px',
|
|
43
|
+
wordWrap: 'break-word',
|
|
44
|
+
position: 'relative'
|
|
45
|
+
}, children: [message.content, message.button && (_jsx("div", { style: { marginTop: '10px' }, children: _jsx("button", { onClick: () => handleButtonClick(message.button), style: {
|
|
46
|
+
padding: '8px 16px',
|
|
47
|
+
backgroundColor: message.role === 'user' ? 'rgba(255, 255, 255, 0.2)' : '#007bff',
|
|
48
|
+
color: message.role === 'user' ? 'white' : 'white',
|
|
49
|
+
border: 'none',
|
|
50
|
+
borderRadius: '5px',
|
|
51
|
+
cursor: 'pointer',
|
|
52
|
+
fontSize: '14px'
|
|
53
|
+
}, children: message.button === 'connect' ? 'Connect Wallet' :
|
|
54
|
+
message.button === 'signIn' ? 'Sign In' : message.button }) }))] }), message.role === 'assistant' && message.metadata?.model && (_jsx("div", { style: {
|
|
55
|
+
display: 'flex',
|
|
56
|
+
alignItems: 'center',
|
|
57
|
+
marginTop: '4px',
|
|
58
|
+
marginLeft: '8px'
|
|
59
|
+
}, children: _jsxs("div", { style: {
|
|
60
|
+
backgroundColor: '#e3f2fd',
|
|
61
|
+
color: '#1976d2',
|
|
62
|
+
padding: '2px 8px',
|
|
63
|
+
borderRadius: '10px',
|
|
64
|
+
fontSize: '10px',
|
|
65
|
+
fontWeight: '500',
|
|
66
|
+
border: '1px solid #bbdefb',
|
|
67
|
+
display: 'flex',
|
|
68
|
+
alignItems: 'center',
|
|
69
|
+
gap: '4px'
|
|
70
|
+
}, children: [_jsx("span", { style: {
|
|
71
|
+
width: '6px',
|
|
72
|
+
height: '6px',
|
|
73
|
+
backgroundColor: '#1976d2',
|
|
74
|
+
borderRadius: '50%',
|
|
75
|
+
display: 'inline-block'
|
|
76
|
+
} }), getModelDisplayName(message.metadata.model)] }) }))] }, message.id))), isLoading && (_jsx("div", { style: {
|
|
47
77
|
alignSelf: 'flex-start',
|
|
48
78
|
backgroundColor: '#f1f1f1',
|
|
49
79
|
color: '#333',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModelSelector.d.ts","sourceRoot":"","sources":["../../../src/components/ui/ModelSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAkHjC,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useChatBot } from '../context/ChatBotContext';
|
|
4
|
+
export const ModelSelector = () => {
|
|
5
|
+
const { availableModels, selectedModelIndex, showModelSelector, handleModelChange } = useChatBot();
|
|
6
|
+
const [anchorEl, setAnchorEl] = React.useState(null);
|
|
7
|
+
const open = Boolean(anchorEl);
|
|
8
|
+
const handleClick = (event) => {
|
|
9
|
+
setAnchorEl(event.currentTarget);
|
|
10
|
+
};
|
|
11
|
+
const handleMenuItemClick = (event, index) => {
|
|
12
|
+
handleModelChange(index);
|
|
13
|
+
setAnchorEl(null);
|
|
14
|
+
};
|
|
15
|
+
const handleClose = () => {
|
|
16
|
+
setAnchorEl(null);
|
|
17
|
+
};
|
|
18
|
+
if (!showModelSelector) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return (_jsxs("div", { style: { display: 'flex', alignItems: 'center' }, children: [_jsxs("div", { style: {
|
|
22
|
+
display: 'flex',
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
cursor: 'pointer',
|
|
25
|
+
padding: '4px 8px',
|
|
26
|
+
borderRadius: '4px',
|
|
27
|
+
backgroundColor: 'rgba(255, 255, 255, 0.1)',
|
|
28
|
+
transition: 'background-color 0.2s',
|
|
29
|
+
fontSize: '12px',
|
|
30
|
+
fontWeight: '500'
|
|
31
|
+
}, onClick: handleClick, onMouseOver: (e) => e.currentTarget.style.backgroundColor = 'rgba(255, 255, 255, 0.2)', onMouseOut: (e) => e.currentTarget.style.backgroundColor = 'rgba(255, 255, 255, 0.1)', title: "Change AI Model", children: [_jsx("span", { style: { marginRight: '4px' }, children: availableModels[selectedModelIndex]?.label || 'Nova' }), _jsx("span", { style: { fontSize: '10px' }, children: "\u25BC" })] }), open && (_jsx("div", { style: {
|
|
32
|
+
position: 'absolute',
|
|
33
|
+
top: '100%',
|
|
34
|
+
left: '0',
|
|
35
|
+
backgroundColor: 'white',
|
|
36
|
+
border: '1px solid #ddd',
|
|
37
|
+
borderRadius: '4px',
|
|
38
|
+
boxShadow: '0 2px 8px rgba(0,0,0,0.1)',
|
|
39
|
+
zIndex: 1000,
|
|
40
|
+
minWidth: '120px',
|
|
41
|
+
marginTop: '4px'
|
|
42
|
+
}, children: availableModels.map((model, index) => (_jsx("div", { style: {
|
|
43
|
+
padding: '8px 12px',
|
|
44
|
+
cursor: 'pointer',
|
|
45
|
+
backgroundColor: index === selectedModelIndex ? '#f0f0f0' : 'transparent',
|
|
46
|
+
color: index === selectedModelIndex ? '#007bff' : '#333',
|
|
47
|
+
fontSize: '12px',
|
|
48
|
+
borderBottom: index < availableModels.length - 1 ? '1px solid #eee' : 'none'
|
|
49
|
+
}, onClick: (event) => handleMenuItemClick(event, index), onMouseOver: (e) => {
|
|
50
|
+
if (index !== selectedModelIndex) {
|
|
51
|
+
e.currentTarget.style.backgroundColor = '#f8f9fa';
|
|
52
|
+
}
|
|
53
|
+
}, onMouseOut: (e) => {
|
|
54
|
+
if (index !== selectedModelIndex) {
|
|
55
|
+
e.currentTarget.style.backgroundColor = 'transparent';
|
|
56
|
+
}
|
|
57
|
+
}, children: model.label }, model.value))) })), open && (_jsx("div", { style: {
|
|
58
|
+
position: 'fixed',
|
|
59
|
+
top: 0,
|
|
60
|
+
left: 0,
|
|
61
|
+
right: 0,
|
|
62
|
+
bottom: 0,
|
|
63
|
+
zIndex: 999
|
|
64
|
+
}, onClick: handleClose }))] }));
|
|
65
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,8 @@ export { MessageInput } from './components/ui/MessageInput';
|
|
|
6
6
|
export { PresetMessages } from './components/ui/PresetMessages';
|
|
7
7
|
export { PermissionForm } from './components/ui/PermissionForm';
|
|
8
8
|
export { NotificationModal } from './components/ui/NotificationModal';
|
|
9
|
-
export
|
|
9
|
+
export { ModelSelector } from './components/ui/ModelSelector';
|
|
10
|
+
export type { ChatBotProps, ChatBotContextType, PresetMessage, ToolUse, ToolCall, NovaResponse, NovaError, AITMetadata, AIModel, DEFAULT_AI_MODELS, AI_MODEL_MAP } from './components/types/ChatBotTypes';
|
|
10
11
|
export { connectWallet, disconnectWallet, validateToken } from './core/utils/walletUtils';
|
|
11
12
|
export { generateAITId, createAITMetadata, prepareAITCreation } from './core/utils/aitUtils';
|
|
12
13
|
export { createNotification, getNotificationIcon } from './core/utils/notificationUtils';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAGlF,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAGlF,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAG9D,YAAY,EACV,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,WAAW,EAEX,OAAO,EACP,iBAAiB,EACjB,YAAY,EACb,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,aAAa,EACd,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGrD,YAAY,EACV,OAAO,EACP,GAAG,EACH,iBAAiB,EACjB,MAAM,EACP,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,4BAA4B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export { MessageInput } from './components/ui/MessageInput';
|
|
|
9
9
|
export { PresetMessages } from './components/ui/PresetMessages';
|
|
10
10
|
export { PermissionForm } from './components/ui/PermissionForm';
|
|
11
11
|
export { NotificationModal } from './components/ui/NotificationModal';
|
|
12
|
+
export { ModelSelector } from './components/ui/ModelSelector';
|
|
12
13
|
// Utility functions
|
|
13
14
|
export { connectWallet, disconnectWallet, validateToken } from './core/utils/walletUtils';
|
|
14
15
|
export { generateAITId, createAITMetadata, prepareAITCreation } from './core/utils/aitUtils';
|
package/dist/types/ait-api.d.ts
CHANGED
|
@@ -5,6 +5,15 @@ export interface Message {
|
|
|
5
5
|
timestamp: string;
|
|
6
6
|
button?: string;
|
|
7
7
|
error?: string;
|
|
8
|
+
metadata?: {
|
|
9
|
+
model?: string;
|
|
10
|
+
permissions?: string[];
|
|
11
|
+
issuedBy?: string;
|
|
12
|
+
toolUse?: {
|
|
13
|
+
name: string;
|
|
14
|
+
input: Record<string, any>;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
8
17
|
}
|
|
9
18
|
export interface AIT {
|
|
10
19
|
aitId: string;
|
|
@@ -129,8 +138,30 @@ export interface AITApi {
|
|
|
129
138
|
message: string;
|
|
130
139
|
apiKey: string;
|
|
131
140
|
apiSecret: string;
|
|
141
|
+
model?: string;
|
|
142
|
+
context?: Array<{
|
|
143
|
+
role: string;
|
|
144
|
+
text: string;
|
|
145
|
+
}>;
|
|
132
146
|
}) => Promise<{
|
|
133
|
-
reply: string
|
|
147
|
+
reply: string | Array<{
|
|
148
|
+
text: string;
|
|
149
|
+
}>;
|
|
150
|
+
toolCall?: {
|
|
151
|
+
toolUse: {
|
|
152
|
+
name: string;
|
|
153
|
+
input: Record<string, any>;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
fullResponse?: {
|
|
157
|
+
output?: {
|
|
158
|
+
message?: {
|
|
159
|
+
content?: Array<{
|
|
160
|
+
text: string;
|
|
161
|
+
}>;
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
};
|
|
134
165
|
} | {
|
|
135
166
|
error: string;
|
|
136
167
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ait-api.d.ts","sourceRoot":"","sources":["../../src/types/ait-api.ts"],"names":[],"mappings":"AAAA,M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