@bytexbyte/nxtlinq-ai-agent-sdk 1.2.3 → 1.2.5
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 +424 -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 +188 -47
- package/dist/components/types/ChatBotTypes.d.ts +19 -2
- 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 +75 -9
- package/dist/components/ui/MessageInput.d.ts.map +1 -1
- package/dist/components/ui/MessageInput.js +7 -4
- package/dist/components/ui/MessageList.d.ts.map +1 -1
- package/dist/components/ui/MessageList.js +53 -17
- 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/PermissionForm.d.ts.map +1 -1
- package/dist/components/ui/PermissionForm.js +60 -23
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -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
|
@@ -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,CAg7BlD,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) => {
|
|
@@ -316,6 +322,15 @@ export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages
|
|
|
316
322
|
return false;
|
|
317
323
|
}
|
|
318
324
|
const availablePermissionLabels = availablePermissions.map(p => p.label);
|
|
325
|
+
if (availablePermissions.length === 0) {
|
|
326
|
+
setMessages(prev => [...prev, {
|
|
327
|
+
id: Date.now().toString(),
|
|
328
|
+
content: `No permissions available for your current identity provider. Please check your service configuration or contact support. Service ID: ${serviceId}, Permission Group: ${permissionGroup || 'None'}`,
|
|
329
|
+
role: 'assistant',
|
|
330
|
+
timestamp: new Date().toISOString()
|
|
331
|
+
}]);
|
|
332
|
+
return false;
|
|
333
|
+
}
|
|
319
334
|
if (!availablePermissionLabels.includes(toolName)) {
|
|
320
335
|
setMessages(prev => [...prev, {
|
|
321
336
|
id: Date.now().toString(),
|
|
@@ -336,55 +351,159 @@ export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages
|
|
|
336
351
|
}
|
|
337
352
|
return true;
|
|
338
353
|
};
|
|
339
|
-
//
|
|
354
|
+
// AI Model related functions
|
|
355
|
+
const handleModelChange = React.useCallback((modelIndex) => {
|
|
356
|
+
setSelectedModelIndex(modelIndex);
|
|
357
|
+
const selectedModel = availableModels[modelIndex];
|
|
358
|
+
onModelChange?.(selectedModel);
|
|
359
|
+
}, [availableModels, onModelChange]);
|
|
360
|
+
const getCurrentModel = React.useCallback(() => {
|
|
361
|
+
return availableModels[selectedModelIndex];
|
|
362
|
+
}, [availableModels, selectedModelIndex]);
|
|
363
|
+
// Updated sendMessage function to support different AI models
|
|
340
364
|
const sendMessage = async (content, retryCount = 0) => {
|
|
365
|
+
if (!content.trim() || isLoading)
|
|
366
|
+
return;
|
|
367
|
+
const currentModel = getCurrentModel();
|
|
368
|
+
const userMessage = {
|
|
369
|
+
id: Date.now().toString(),
|
|
370
|
+
content,
|
|
371
|
+
role: 'user',
|
|
372
|
+
timestamp: new Date().toISOString(),
|
|
373
|
+
metadata: {
|
|
374
|
+
model: currentModel.value,
|
|
375
|
+
permissions: permissions,
|
|
376
|
+
issuedBy: hitAddress || ''
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
setMessages(prev => [...prev, userMessage]);
|
|
380
|
+
setInputValue('');
|
|
381
|
+
setIsLoading(true);
|
|
341
382
|
try {
|
|
342
|
-
|
|
383
|
+
// Build context messages
|
|
384
|
+
const contextMessages = messages.map(msg => ({
|
|
385
|
+
role: msg.role,
|
|
386
|
+
text: msg.content
|
|
387
|
+
}));
|
|
343
388
|
const response = await nxtlinqApi.agent.sendMessage({
|
|
344
389
|
message: content,
|
|
345
390
|
apiKey,
|
|
346
391
|
apiSecret,
|
|
392
|
+
model: currentModel.value,
|
|
393
|
+
context: contextMessages
|
|
347
394
|
});
|
|
348
395
|
if ('error' in response) {
|
|
349
396
|
throw new Error(response.error);
|
|
350
397
|
}
|
|
351
|
-
|
|
352
|
-
if (
|
|
398
|
+
let botResponse;
|
|
399
|
+
if (response.toolCall?.toolUse) {
|
|
400
|
+
// Handle tool calls
|
|
401
|
+
const toolUse = response.toolCall.toolUse;
|
|
353
402
|
if (onToolUse) {
|
|
354
|
-
const isToolAllowed = await hasPermission(
|
|
403
|
+
const isToolAllowed = await hasPermission(toolUse.name);
|
|
355
404
|
if (!isToolAllowed) {
|
|
356
405
|
return;
|
|
357
406
|
}
|
|
358
|
-
const
|
|
359
|
-
if (
|
|
360
|
-
|
|
361
|
-
|
|
407
|
+
const toolResult = await onToolUse(toolUse);
|
|
408
|
+
if (toolResult) {
|
|
409
|
+
// Ensure the tool result has model information
|
|
410
|
+
botResponse = {
|
|
411
|
+
...toolResult,
|
|
412
|
+
metadata: {
|
|
413
|
+
...toolResult.metadata,
|
|
414
|
+
model: currentModel.value,
|
|
415
|
+
permissions: permissions,
|
|
416
|
+
issuedBy: hitAddress || '',
|
|
417
|
+
toolUse: toolUse
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
else {
|
|
422
|
+
botResponse = {
|
|
423
|
+
id: (Date.now() + 1).toString(),
|
|
424
|
+
content: `Tool ${toolUse.name} executed successfully`,
|
|
425
|
+
role: 'assistant',
|
|
426
|
+
timestamp: new Date().toISOString(),
|
|
427
|
+
metadata: {
|
|
428
|
+
model: currentModel.value,
|
|
429
|
+
permissions: permissions,
|
|
430
|
+
issuedBy: hitAddress || '',
|
|
431
|
+
toolUse: toolUse
|
|
432
|
+
}
|
|
433
|
+
};
|
|
362
434
|
}
|
|
363
435
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
.join(' ') || '';
|
|
369
|
-
if (replyText) {
|
|
370
|
-
const message = {
|
|
371
|
-
id: Date.now().toString(),
|
|
372
|
-
content: replyText,
|
|
436
|
+
else {
|
|
437
|
+
botResponse = {
|
|
438
|
+
id: (Date.now() + 1).toString(),
|
|
439
|
+
content: `Tool ${toolUse.name} executed successfully`,
|
|
373
440
|
role: 'assistant',
|
|
374
|
-
timestamp: new Date().toISOString()
|
|
441
|
+
timestamp: new Date().toISOString(),
|
|
442
|
+
metadata: {
|
|
443
|
+
model: currentModel.value,
|
|
444
|
+
permissions: permissions,
|
|
445
|
+
issuedBy: hitAddress || '',
|
|
446
|
+
toolUse: toolUse
|
|
447
|
+
}
|
|
375
448
|
};
|
|
376
|
-
setMessages(prev => [...prev, message]);
|
|
377
|
-
return;
|
|
378
449
|
}
|
|
379
450
|
}
|
|
380
|
-
|
|
451
|
+
else if (response.reply) {
|
|
452
|
+
const replyText = Array.isArray(response.reply)
|
|
453
|
+
? response.reply
|
|
454
|
+
.map((item) => item.text.replace(/<thinking>/g, '').replace(/<\/thinking>/g, ''))
|
|
455
|
+
.join(' ') || 'Sorry, I cannot understand your question'
|
|
456
|
+
: response.reply.replace(/<thinking>/g, '').replace(/<\/thinking>/g, '') || 'Sorry, I cannot understand your question';
|
|
457
|
+
botResponse = {
|
|
458
|
+
id: (Date.now() + 1).toString(),
|
|
459
|
+
content: replyText,
|
|
460
|
+
role: 'assistant',
|
|
461
|
+
timestamp: new Date().toISOString(),
|
|
462
|
+
metadata: {
|
|
463
|
+
model: currentModel.value,
|
|
464
|
+
permissions: permissions,
|
|
465
|
+
issuedBy: hitAddress || ''
|
|
466
|
+
}
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
else {
|
|
470
|
+
const replyText = response.fullResponse?.output?.message?.content
|
|
471
|
+
?.find((item) => item.text)?.text || 'Sorry, I cannot understand your question';
|
|
472
|
+
botResponse = {
|
|
473
|
+
id: (Date.now() + 1).toString(),
|
|
474
|
+
content: replyText,
|
|
475
|
+
role: 'assistant',
|
|
476
|
+
timestamp: new Date().toISOString(),
|
|
477
|
+
metadata: {
|
|
478
|
+
model: currentModel.value,
|
|
479
|
+
permissions: permissions,
|
|
480
|
+
issuedBy: hitAddress || ''
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
setMessages(prev => [...prev, botResponse]);
|
|
381
485
|
}
|
|
382
486
|
catch (error) {
|
|
487
|
+
console.error('Failed to send message:', error);
|
|
383
488
|
if (retryCount < maxRetries) {
|
|
384
|
-
|
|
385
|
-
|
|
489
|
+
setTimeout(() => {
|
|
490
|
+
sendMessage(content, retryCount + 1);
|
|
491
|
+
}, retryDelay);
|
|
492
|
+
return;
|
|
386
493
|
}
|
|
387
|
-
|
|
494
|
+
const errorMessage = {
|
|
495
|
+
id: (Date.now() + 1).toString(),
|
|
496
|
+
content: error instanceof Error ? error.message : 'An error occurred while sending the message',
|
|
497
|
+
role: 'assistant',
|
|
498
|
+
timestamp: new Date().toISOString(),
|
|
499
|
+
metadata: {
|
|
500
|
+
model: currentModel.value,
|
|
501
|
+
permissions: permissions,
|
|
502
|
+
issuedBy: hitAddress || ''
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
setMessages(prev => [...prev, errorMessage]);
|
|
506
|
+
onError?.(error instanceof Error ? error : new Error('Unknown error'));
|
|
388
507
|
}
|
|
389
508
|
finally {
|
|
390
509
|
setIsLoading(false);
|
|
@@ -401,20 +520,16 @@ export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages
|
|
|
401
520
|
id: Date.now().toString(),
|
|
402
521
|
content: 'Loading your wallet configuration... Please wait a moment.',
|
|
403
522
|
role: 'assistant',
|
|
404
|
-
timestamp: new Date().toISOString()
|
|
523
|
+
timestamp: new Date().toISOString(),
|
|
524
|
+
metadata: {
|
|
525
|
+
model: getCurrentModel().value,
|
|
526
|
+
permissions: permissions,
|
|
527
|
+
issuedBy: hitAddress || ''
|
|
528
|
+
}
|
|
405
529
|
};
|
|
406
530
|
setMessages(prev => [...prev, loadingMessage]);
|
|
407
531
|
return;
|
|
408
532
|
}
|
|
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
533
|
try {
|
|
419
534
|
await sendMessage(inputValue);
|
|
420
535
|
}
|
|
@@ -425,13 +540,15 @@ export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages
|
|
|
425
540
|
id: Date.now().toString(),
|
|
426
541
|
content: 'Sorry, there was an error processing your message. Please try again.',
|
|
427
542
|
role: 'assistant',
|
|
428
|
-
timestamp: new Date().toISOString()
|
|
543
|
+
timestamp: new Date().toISOString(),
|
|
544
|
+
metadata: {
|
|
545
|
+
model: getCurrentModel().value,
|
|
546
|
+
permissions: permissions,
|
|
547
|
+
issuedBy: hitAddress || ''
|
|
548
|
+
}
|
|
429
549
|
};
|
|
430
550
|
setMessages(prev => [...prev, errorMessage]);
|
|
431
551
|
}
|
|
432
|
-
finally {
|
|
433
|
-
setIsLoading(false);
|
|
434
|
-
}
|
|
435
552
|
};
|
|
436
553
|
// Handle preset message
|
|
437
554
|
const handlePresetMessage = (message) => {
|
|
@@ -441,7 +558,12 @@ export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages
|
|
|
441
558
|
id: Date.now().toString(),
|
|
442
559
|
content: 'Loading your wallet configuration... Please wait a moment.',
|
|
443
560
|
role: 'assistant',
|
|
444
|
-
timestamp: new Date().toISOString()
|
|
561
|
+
timestamp: new Date().toISOString(),
|
|
562
|
+
metadata: {
|
|
563
|
+
model: getCurrentModel().value,
|
|
564
|
+
permissions: permissions,
|
|
565
|
+
issuedBy: hitAddress || ''
|
|
566
|
+
}
|
|
445
567
|
};
|
|
446
568
|
setMessages(prev => [...prev, loadingMessage]);
|
|
447
569
|
return;
|
|
@@ -451,7 +573,12 @@ export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages
|
|
|
451
573
|
id: Date.now().toString(),
|
|
452
574
|
content: message.text,
|
|
453
575
|
role: 'user',
|
|
454
|
-
timestamp: new Date().toISOString()
|
|
576
|
+
timestamp: new Date().toISOString(),
|
|
577
|
+
metadata: {
|
|
578
|
+
model: getCurrentModel().value,
|
|
579
|
+
permissions: permissions,
|
|
580
|
+
issuedBy: hitAddress || ''
|
|
581
|
+
}
|
|
455
582
|
}]);
|
|
456
583
|
sendMessage(message.text);
|
|
457
584
|
}
|
|
@@ -460,7 +587,7 @@ export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages
|
|
|
460
587
|
}
|
|
461
588
|
};
|
|
462
589
|
// Generate and register AIT
|
|
463
|
-
const generateAndRegisterAIT = async () => {
|
|
590
|
+
const generateAndRegisterAIT = async (newPermissions) => {
|
|
464
591
|
if (!signer || !hitAddress) {
|
|
465
592
|
throw new Error('Missing signer or wallet address');
|
|
466
593
|
}
|
|
@@ -468,7 +595,7 @@ export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages
|
|
|
468
595
|
const aitId = `did:polygon:ike-dashboard:${hitAddress}:${timestamp}`;
|
|
469
596
|
const metadata = {
|
|
470
597
|
model: 'gpt-4',
|
|
471
|
-
permissions,
|
|
598
|
+
permissions: newPermissions || permissions,
|
|
472
599
|
issuedBy: hitAddress,
|
|
473
600
|
};
|
|
474
601
|
const metadataStr = stringify(metadata);
|
|
@@ -499,10 +626,10 @@ export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages
|
|
|
499
626
|
setPermissions(permissions);
|
|
500
627
|
};
|
|
501
628
|
// Save permissions
|
|
502
|
-
const savePermissions = async () => {
|
|
629
|
+
const savePermissions = async (newPermissions) => {
|
|
503
630
|
setIsDisabled(true);
|
|
504
631
|
try {
|
|
505
|
-
await generateAndRegisterAIT();
|
|
632
|
+
await generateAndRegisterAIT(newPermissions);
|
|
506
633
|
showSuccess('AIT permissions saved successfully! You can now use the AI agent with your configured permissions.');
|
|
507
634
|
setShowPermissionForm(false);
|
|
508
635
|
setIsPermissionFormOpen(false);
|
|
@@ -685,6 +812,10 @@ export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages
|
|
|
685
812
|
walletInfo,
|
|
686
813
|
isWalletLoading,
|
|
687
814
|
notification,
|
|
815
|
+
// AI Model related state
|
|
816
|
+
availableModels,
|
|
817
|
+
selectedModelIndex,
|
|
818
|
+
showModelSelector: showModelSelectorState,
|
|
688
819
|
// Actions
|
|
689
820
|
setInputValue,
|
|
690
821
|
setIsOpen,
|
|
@@ -694,6 +825,9 @@ export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages
|
|
|
694
825
|
setIsDisabled,
|
|
695
826
|
setIsWalletLoading,
|
|
696
827
|
setNotification,
|
|
828
|
+
// AI Model related actions
|
|
829
|
+
setSelectedModelIndex,
|
|
830
|
+
setShowModelSelector: setShowModelSelectorState,
|
|
697
831
|
// Functions
|
|
698
832
|
connectWallet,
|
|
699
833
|
signInWallet,
|
|
@@ -707,6 +841,9 @@ export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages
|
|
|
707
841
|
showWarning,
|
|
708
842
|
showInfo,
|
|
709
843
|
refreshAIT,
|
|
844
|
+
// AI Model related functions
|
|
845
|
+
handleModelChange,
|
|
846
|
+
getCurrentModel,
|
|
710
847
|
// Additional properties for PermissionForm
|
|
711
848
|
onSave: savePermissions,
|
|
712
849
|
onConnectWallet: () => connectWallet(false),
|
|
@@ -729,7 +866,11 @@ export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages
|
|
|
729
866
|
apiKey,
|
|
730
867
|
apiSecret,
|
|
731
868
|
onVerifyWallet,
|
|
732
|
-
permissionGroup
|
|
869
|
+
permissionGroup,
|
|
870
|
+
availableModels,
|
|
871
|
+
defaultModelIndex,
|
|
872
|
+
showModelSelector,
|
|
873
|
+
onModelChange
|
|
733
874
|
},
|
|
734
875
|
nxtlinqApi
|
|
735
876
|
};
|
|
@@ -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,19 +86,23 @@ 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>;
|
|
79
94
|
handleSubmit: (e: React.FormEvent) => Promise<void>;
|
|
80
95
|
handlePresetMessage: (message: PresetMessage) => void;
|
|
81
|
-
savePermissions: () => Promise<void>;
|
|
96
|
+
savePermissions: (newPermissions?: string[]) => Promise<void>;
|
|
82
97
|
handleVerifyWalletClick: () => Promise<void>;
|
|
83
98
|
showSuccess: (message: string) => void;
|
|
84
99
|
showError: (message: string) => void;
|
|
85
100
|
showWarning: (message: string) => void;
|
|
86
101
|
showInfo: (message: string) => void;
|
|
87
102
|
refreshAIT: (forceUpdatePermissions?: boolean) => Promise<void>;
|
|
88
|
-
|
|
103
|
+
handleModelChange: (modelIndex: number) => void;
|
|
104
|
+
getCurrentModel: () => AIModel;
|
|
105
|
+
onSave: (newPermissions?: string[]) => Promise<void>;
|
|
89
106
|
onConnectWallet: () => Promise<string | undefined>;
|
|
90
107
|
onSignIn: () => Promise<void>;
|
|
91
108
|
isNeedSignInWithWallet: boolean;
|
|
@@ -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,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAC1D,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,C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D,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;AAqG/B,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAmP7B,CAAC"}
|
|
@@ -1,11 +1,81 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useChatBot } from '../context/ChatBotContext';
|
|
4
|
-
import { NotificationModal } from './NotificationModal';
|
|
5
4
|
import { PermissionForm } from './PermissionForm';
|
|
6
5
|
import { MessageList } from './MessageList';
|
|
7
6
|
import { MessageInput } from './MessageInput';
|
|
8
7
|
import { PresetMessages } from './PresetMessages';
|
|
8
|
+
import { ModelSelector } from './ModelSelector';
|
|
9
|
+
// Toast Notification Component
|
|
10
|
+
const ToastNotification = ({ type, message, onClose, isChatOpen = false }) => {
|
|
11
|
+
const getStyles = () => {
|
|
12
|
+
const baseStyles = {
|
|
13
|
+
position: 'fixed',
|
|
14
|
+
padding: '12px 24px',
|
|
15
|
+
borderRadius: 8,
|
|
16
|
+
zIndex: 2000,
|
|
17
|
+
fontWeight: 600,
|
|
18
|
+
boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)',
|
|
19
|
+
transition: 'all 0.3s ease',
|
|
20
|
+
display: 'flex',
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
gap: '12px',
|
|
23
|
+
minWidth: '300px',
|
|
24
|
+
maxWidth: '500px'
|
|
25
|
+
};
|
|
26
|
+
// Dynamically adjust position based on chat window state
|
|
27
|
+
if (isChatOpen) {
|
|
28
|
+
// When chat window is open, show notification above the chat window
|
|
29
|
+
Object.assign(baseStyles, {
|
|
30
|
+
top: 20,
|
|
31
|
+
right: 20, // Align with the right edge of chat window
|
|
32
|
+
maxWidth: '480px', // Slightly smaller than chat window width
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
// When chat window is closed, show notification in bottom right corner
|
|
37
|
+
Object.assign(baseStyles, {
|
|
38
|
+
bottom: 20,
|
|
39
|
+
right: 20,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
switch (type) {
|
|
43
|
+
case 'success':
|
|
44
|
+
return { ...baseStyles, background: '#4caf50', color: 'white' };
|
|
45
|
+
case 'error':
|
|
46
|
+
return { ...baseStyles, background: '#f44336', color: 'white' };
|
|
47
|
+
case 'warning':
|
|
48
|
+
return { ...baseStyles, background: '#ff9800', color: 'white' };
|
|
49
|
+
default:
|
|
50
|
+
return { ...baseStyles, background: '#2196f3', color: 'white' };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const getIcon = () => {
|
|
54
|
+
switch (type) {
|
|
55
|
+
case 'success':
|
|
56
|
+
return '✅';
|
|
57
|
+
case 'error':
|
|
58
|
+
return '❌';
|
|
59
|
+
case 'warning':
|
|
60
|
+
return '⚠️';
|
|
61
|
+
default:
|
|
62
|
+
return 'ℹ️';
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
return (_jsxs("div", { style: getStyles(), children: [_jsx("span", { style: { fontSize: '18px' }, children: getIcon() }), _jsx("span", { style: { flex: 1 }, children: message }), _jsx("button", { onClick: onClose, style: {
|
|
66
|
+
background: 'none',
|
|
67
|
+
border: 'none',
|
|
68
|
+
color: 'white',
|
|
69
|
+
fontSize: '18px',
|
|
70
|
+
cursor: 'pointer',
|
|
71
|
+
padding: '4px',
|
|
72
|
+
display: 'flex',
|
|
73
|
+
alignItems: 'center',
|
|
74
|
+
justifyContent: 'center',
|
|
75
|
+
borderRadius: '4px',
|
|
76
|
+
transition: 'background-color 0.2s'
|
|
77
|
+
}, onMouseOver: (e) => e.currentTarget.style.backgroundColor = 'rgba(255, 255, 255, 0.2)', onMouseOut: (e) => e.currentTarget.style.backgroundColor = 'transparent', children: "\u00D7" })] }));
|
|
78
|
+
};
|
|
9
79
|
export const ChatBotUI = () => {
|
|
10
80
|
const { isOpen, setIsOpen, showPermissionForm, setShowPermissionForm, notification, setNotification, isAITLoading, props: { className = '' } } = useChatBot();
|
|
11
81
|
// Add CSS animation for loading spinner
|
|
@@ -57,9 +127,7 @@ export const ChatBotUI = () => {
|
|
|
57
127
|
}, onMouseOut: (e) => {
|
|
58
128
|
e.currentTarget.style.backgroundColor = '#007bff';
|
|
59
129
|
e.currentTarget.style.transform = 'translateY(0)';
|
|
60
|
-
}, title: "Open AI Agent Chat", children: "AI Agent" }), notification.show && (_jsx(
|
|
61
|
-
notification.type === 'error' ? 'Error' :
|
|
62
|
-
notification.type === 'warning' ? 'Warning' : 'Info', message: notification.message, onClose: handleCloseNotification }))] }));
|
|
130
|
+
}, title: "Open AI Agent Chat", children: "AI Agent" }), notification.show && (_jsx(ToastNotification, { type: notification.type, message: notification.message, onClose: handleCloseNotification, isChatOpen: isOpen }))] }));
|
|
63
131
|
}
|
|
64
132
|
return (_jsxs(_Fragment, { children: [_jsxs("div", { style: {
|
|
65
133
|
position: 'fixed',
|
|
@@ -90,7 +158,7 @@ export const ChatBotUI = () => {
|
|
|
90
158
|
margin: 0,
|
|
91
159
|
fontSize: '16px',
|
|
92
160
|
fontWeight: '600'
|
|
93
|
-
}, children: "AI Agent" }), isAITLoading && (_jsxs("div", { style: {
|
|
161
|
+
}, children: "AI Agent" }), _jsx("div", { style: { position: 'relative' }, children: _jsx(ModelSelector, {}) }), isAITLoading && (_jsxs("div", { style: {
|
|
94
162
|
display: 'flex',
|
|
95
163
|
alignItems: 'center',
|
|
96
164
|
gap: '5px',
|
|
@@ -140,7 +208,5 @@ export const ChatBotUI = () => {
|
|
|
140
208
|
alignItems: 'center',
|
|
141
209
|
justifyContent: 'center',
|
|
142
210
|
zIndex: 1002
|
|
143
|
-
}, children: _jsx(PermissionForm, { onClose: () => setShowPermissionForm(false), onOpen: () => setShowPermissionForm(true) }) })), notification.show && (_jsx(
|
|
144
|
-
notification.type === 'error' ? 'Error' :
|
|
145
|
-
notification.type === 'warning' ? 'Warning' : 'Info', message: notification.message, onClose: handleCloseNotification }))] }));
|
|
211
|
+
}, children: _jsx(PermissionForm, { onClose: () => setShowPermissionForm(false), onOpen: () => setShowPermissionForm(true) }) })), notification.show && (_jsx(ToastNotification, { type: notification.type, message: notification.message, onClose: handleCloseNotification, isChatOpen: isOpen }))] }));
|
|
146
212
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageInput.d.ts","sourceRoot":"","sources":["../../../src/components/ui/MessageInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"MessageInput.d.ts","sourceRoot":"","sources":["../../../src/components/ui/MessageInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAsFhC,CAAC"}
|
|
@@ -3,7 +3,6 @@ import { useChatBot } from '../context/ChatBotContext';
|
|
|
3
3
|
export const MessageInput = () => {
|
|
4
4
|
const { inputValue, setInputValue, isLoading, isAITLoading, handleSubmit, props: { placeholder = 'Type a message...' } } = useChatBot();
|
|
5
5
|
const isDisabled = isLoading || isAITLoading;
|
|
6
|
-
const buttonText = isLoading ? 'Sending...' : isAITLoading ? 'Loading...' : 'Send';
|
|
7
6
|
const inputPlaceholder = isAITLoading ? 'Loading wallet configuration...' : placeholder;
|
|
8
7
|
const handleKeyPress = (e) => {
|
|
9
8
|
if (e.key === 'Enter' && !e.shiftKey) {
|
|
@@ -24,7 +23,7 @@ export const MessageInput = () => {
|
|
|
24
23
|
outline: 'none',
|
|
25
24
|
fontSize: '14px',
|
|
26
25
|
backgroundColor: isDisabled ? '#f8f9fa' : '#fff'
|
|
27
|
-
} }),
|
|
26
|
+
} }), _jsxs("button", { onClick: (e) => handleSubmit(e), disabled: isDisabled || !inputValue.trim(), style: {
|
|
28
27
|
backgroundColor: isDisabled || !inputValue.trim() ? '#e9ecef' : '#007bff',
|
|
29
28
|
color: isDisabled || !inputValue.trim() ? '#6c757d' : 'white',
|
|
30
29
|
border: 'none',
|
|
@@ -33,7 +32,11 @@ export const MessageInput = () => {
|
|
|
33
32
|
cursor: isDisabled || !inputValue.trim() ? 'not-allowed' : 'pointer',
|
|
34
33
|
fontSize: '14px',
|
|
35
34
|
fontWeight: '500',
|
|
36
|
-
transition: 'background-color 0.3s'
|
|
35
|
+
transition: 'background-color 0.3s',
|
|
36
|
+
position: 'relative',
|
|
37
|
+
display: 'flex',
|
|
38
|
+
alignItems: 'center',
|
|
39
|
+
justifyContent: 'center'
|
|
37
40
|
}, onMouseOver: (e) => {
|
|
38
41
|
if (!isDisabled && inputValue.trim()) {
|
|
39
42
|
e.currentTarget.style.backgroundColor = '#0056b3';
|
|
@@ -42,5 +45,5 @@ export const MessageInput = () => {
|
|
|
42
45
|
if (!isDisabled && inputValue.trim()) {
|
|
43
46
|
e.currentTarget.style.backgroundColor = '#007bff';
|
|
44
47
|
}
|
|
45
|
-
}, children:
|
|
48
|
+
}, children: ["Send", (isLoading || isAITLoading) && (_jsx("span", { style: { marginLeft: 8, display: 'flex', alignItems: 'center' }, children: _jsx("svg", { width: "16", height: "16", viewBox: "0 0 50 50", children: _jsx("circle", { cx: "25", cy: "25", r: "20", fill: "none", stroke: "#fff", strokeWidth: "4", strokeDasharray: "31.4 31.4", strokeLinecap: "round", children: _jsx("animateTransform", { attributeName: "transform", type: "rotate", from: "0 25 25", to: "360 25 25", dur: "1s", repeatCount: "indefinite" }) }) }) }))] })] }));
|
|
46
49
|
};
|
|
@@ -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,EAiJ/B,CAAC"}
|