@bytexbyte/nxtlinq-ai-agent-sdk 1.3.0 → 1.3.2
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/dist/api/nxtlinq-api.d.ts.map +1 -1
- package/dist/api/nxtlinq-api.js +53 -1
- package/dist/components/context/ChatBotContext.d.ts.map +1 -1
- package/dist/components/context/ChatBotContext.js +56 -6
- package/dist/components/types/ChatBotTypes.d.ts +8 -1
- package/dist/components/types/ChatBotTypes.d.ts.map +1 -1
- package/dist/components/ui/MessageInput.d.ts.map +1 -1
- package/dist/components/ui/MessageInput.js +7 -2
- package/dist/components/ui/PresetMessages.d.ts.map +1 -1
- package/dist/components/ui/PresetMessages.js +3 -4
- package/dist/core/lib/useSpeechToTextFromMic/helper.d.ts +23 -0
- package/dist/core/lib/useSpeechToTextFromMic/helper.d.ts.map +1 -0
- package/dist/core/lib/useSpeechToTextFromMic/helper.js +77 -0
- package/dist/core/lib/useSpeechToTextFromMic/index.d.ts +13 -0
- package/dist/core/lib/useSpeechToTextFromMic/index.d.ts.map +1 -0
- package/dist/core/lib/useSpeechToTextFromMic/index.js +41 -0
- package/dist/core/utils/index.d.ts +2 -0
- package/dist/core/utils/index.d.ts.map +1 -0
- package/dist/core/utils/index.js +3 -0
- package/dist/types/ait-api.d.ts +20 -0
- package/dist/types/ait-api.d.ts.map +1 -1
- package/package.json +11 -4
|
@@ -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;AAsP1C,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,EAAE,WAAW,MAAM,KAAG,MAUpE,CAAC"}
|
package/dist/api/nxtlinq-api.js
CHANGED
|
@@ -93,6 +93,32 @@ const createAgentApi = () => ({
|
|
|
93
93
|
console.error('Failed to send message:', error);
|
|
94
94
|
return { error: error instanceof Error ? error.message : 'Failed to send message' };
|
|
95
95
|
}
|
|
96
|
+
},
|
|
97
|
+
generateSuggestions: async (params) => {
|
|
98
|
+
try {
|
|
99
|
+
const response = await fetch(`${AI_AGENT_API_HOST}/api/suggestions`, {
|
|
100
|
+
method: 'POST',
|
|
101
|
+
headers: {
|
|
102
|
+
'Content-Type': 'application/json',
|
|
103
|
+
'X-API-Key': params.apiKey,
|
|
104
|
+
'X-API-Secret': params.apiSecret,
|
|
105
|
+
...getAuthHeader()
|
|
106
|
+
},
|
|
107
|
+
body: JSON.stringify({
|
|
108
|
+
apiKey: params.apiKey,
|
|
109
|
+
apiSecret: params.apiSecret,
|
|
110
|
+
context: params.context || []
|
|
111
|
+
}),
|
|
112
|
+
});
|
|
113
|
+
if (!response.ok) {
|
|
114
|
+
throw new Error('Failed to generate suggestions');
|
|
115
|
+
}
|
|
116
|
+
return await response.json();
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
console.error('Failed to generate suggestions:', error);
|
|
120
|
+
return { error: error instanceof Error ? error.message : 'Failed to generate suggestions' };
|
|
121
|
+
}
|
|
96
122
|
}
|
|
97
123
|
});
|
|
98
124
|
// Permissions API module
|
|
@@ -123,6 +149,31 @@ const createPermissionsApi = (apiKey, apiSecret) => ({
|
|
|
123
149
|
}
|
|
124
150
|
}
|
|
125
151
|
});
|
|
152
|
+
// Cognitive API Module
|
|
153
|
+
const createCognitiveApi = (apiKey, apiSecret) => ({
|
|
154
|
+
getCognitiveToken: async () => {
|
|
155
|
+
try {
|
|
156
|
+
const url = new URL(`${AI_AGENT_API_HOST}/api/cognitive/token`);
|
|
157
|
+
const response = await fetch(url.toString(), {
|
|
158
|
+
method: 'GET',
|
|
159
|
+
headers: {
|
|
160
|
+
'X-API-Key': apiKey,
|
|
161
|
+
'X-API-Secret': apiSecret,
|
|
162
|
+
'Content-Type': 'application/json',
|
|
163
|
+
...getAuthHeader()
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
if (!response.ok) {
|
|
167
|
+
throw new Error('Failed to fetch permissions');
|
|
168
|
+
}
|
|
169
|
+
return await response.json();
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
console.error('Failed to fetch cognitive token:', error);
|
|
173
|
+
return { error: error instanceof Error ? error.message : 'Failed to fetch cognitive token' };
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
});
|
|
126
177
|
// Main API factory
|
|
127
178
|
export const createNxtlinqApi = (apiKey, apiSecret) => {
|
|
128
179
|
return {
|
|
@@ -131,6 +182,7 @@ export const createNxtlinqApi = (apiKey, apiSecret) => {
|
|
|
131
182
|
metadata: createMetadataApi(apiKey, apiSecret),
|
|
132
183
|
auth: createAuthApi(apiKey, apiSecret),
|
|
133
184
|
agent: createAgentApi(),
|
|
134
|
-
permissions: createPermissionsApi(apiKey, apiSecret)
|
|
185
|
+
permissions: createPermissionsApi(apiKey, apiSecret),
|
|
186
|
+
cognitive: createCognitiveApi(apiKey, apiSecret)
|
|
135
187
|
};
|
|
136
188
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBotContext.d.ts","sourceRoot":"","sources":["../../../src/components/context/ChatBotContext.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ChatBotContext.d.ts","sourceRoot":"","sources":["../../../src/components/context/ChatBotContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,OAAO,EACL,kBAAkB,EAClB,YAAY,EAGb,MAAM,uBAAuB,CAAC;AAI/B,eAAO,MAAM,UAAU,0BAMtB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CA86ClD,CAAC"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import * as React from 'react';
|
|
3
2
|
import { ethers } from 'ethers';
|
|
4
|
-
import { createNxtlinqApi } from '../../api/nxtlinq-api';
|
|
5
3
|
import stringify from 'fast-json-stable-stringify';
|
|
6
|
-
import
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { createNxtlinqApi } from '../../api/nxtlinq-api';
|
|
7
6
|
import useLocalStorage from '../../core/lib/useLocalStorage';
|
|
7
|
+
import { useSpeechToTextFromMic } from '../../core/lib/useSpeechToTextFromMic';
|
|
8
|
+
import metakeepClient from '../../core/metakeepClient';
|
|
9
|
+
import { sleep } from '../../core/utils';
|
|
8
10
|
import { DEFAULT_AI_MODELS } from '../types/ChatBotTypes';
|
|
9
11
|
const ChatBotContext = React.createContext(undefined);
|
|
10
12
|
export const useChatBot = () => {
|
|
@@ -17,6 +19,12 @@ export const useChatBot = () => {
|
|
|
17
19
|
export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages = [], placeholder = 'Type a message...', className = '', maxRetries = 3, retryDelay = 2000, serviceId, apiKey, apiSecret, onVerifyWallet, permissionGroup, children,
|
|
18
20
|
// AI Model related attributes
|
|
19
21
|
availableModels = DEFAULT_AI_MODELS, defaultModelIndex = 0, showModelSelector = true, onModelChange }) => {
|
|
22
|
+
const nxtlinqApi = React.useMemo(() => createNxtlinqApi(apiKey, apiSecret), [apiKey, apiSecret]);
|
|
23
|
+
// Custom hook
|
|
24
|
+
const { isRecording, transcript, start: startRecording, stop: stopRecording } = useSpeechToTextFromMic({
|
|
25
|
+
apiKey,
|
|
26
|
+
apiSecret
|
|
27
|
+
});
|
|
20
28
|
// State
|
|
21
29
|
const [messages, setMessages] = React.useState([]);
|
|
22
30
|
const [inputValue, setInputValue] = React.useState('');
|
|
@@ -36,12 +44,16 @@ availableModels = DEFAULT_AI_MODELS, defaultModelIndex = 0, showModelSelector =
|
|
|
36
44
|
const [isAutoConnecting, setIsAutoConnecting] = React.useState(false);
|
|
37
45
|
const [justAutoConnected, setJustAutoConnected] = React.useState(false);
|
|
38
46
|
const [nxtlinqAITServiceAccessToken, setNxtlinqAITServiceAccessToken] = useLocalStorage('nxtlinqAITServiceAccessToken', '');
|
|
47
|
+
const [suggestions, setSuggestions] = React.useState(presetMessages);
|
|
39
48
|
// Use refs to get latest state values in hasPermission function
|
|
40
49
|
const hitAddressRef = React.useRef(hitAddress);
|
|
41
50
|
const aitRef = React.useRef(ait);
|
|
42
51
|
const permissionsRef = React.useRef(permissions);
|
|
43
52
|
const nxtlinqAITServiceAccessTokenRef = React.useRef(nxtlinqAITServiceAccessToken);
|
|
44
53
|
const signerRef = React.useRef(signer);
|
|
54
|
+
// Refs for input value and recording state
|
|
55
|
+
const isRecordingRef = React.useRef(false);
|
|
56
|
+
const textInputRef = React.useRef(null);
|
|
45
57
|
// Update refs when state changes
|
|
46
58
|
React.useEffect(() => {
|
|
47
59
|
hitAddressRef.current = hitAddress;
|
|
@@ -58,6 +70,15 @@ availableModels = DEFAULT_AI_MODELS, defaultModelIndex = 0, showModelSelector =
|
|
|
58
70
|
React.useEffect(() => {
|
|
59
71
|
signerRef.current = signer;
|
|
60
72
|
}, [signer]);
|
|
73
|
+
React.useEffect(() => {
|
|
74
|
+
if (!transcript) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
setInputValue(transcript);
|
|
78
|
+
}, [transcript]);
|
|
79
|
+
React.useEffect(() => {
|
|
80
|
+
isRecordingRef.current = isRecording;
|
|
81
|
+
}, [isRecording]);
|
|
61
82
|
const [notification, setNotification] = React.useState({
|
|
62
83
|
show: false,
|
|
63
84
|
type: 'info',
|
|
@@ -68,7 +89,6 @@ availableModels = DEFAULT_AI_MODELS, defaultModelIndex = 0, showModelSelector =
|
|
|
68
89
|
// AI Model related state
|
|
69
90
|
const [selectedModelIndex, setSelectedModelIndex] = useLocalStorage('selectedAIModelIndex', defaultModelIndex);
|
|
70
91
|
const [showModelSelectorState, setShowModelSelectorState] = React.useState(showModelSelector);
|
|
71
|
-
const nxtlinqApi = React.useMemo(() => createNxtlinqApi(apiKey, apiSecret), [apiKey, apiSecret]);
|
|
72
92
|
// Notification functions
|
|
73
93
|
const showNotification = (type, message, duration = 5000) => {
|
|
74
94
|
setNotification({
|
|
@@ -674,6 +694,22 @@ availableModels = DEFAULT_AI_MODELS, defaultModelIndex = 0, showModelSelector =
|
|
|
674
694
|
const getCurrentModel = React.useCallback(() => {
|
|
675
695
|
return availableModels[selectedModelIndex];
|
|
676
696
|
}, [availableModels, selectedModelIndex]);
|
|
697
|
+
const updateSuggestions = React.useCallback(async (context) => {
|
|
698
|
+
const result = await nxtlinqApi.agent.generateSuggestions({
|
|
699
|
+
apiKey,
|
|
700
|
+
apiSecret,
|
|
701
|
+
context
|
|
702
|
+
});
|
|
703
|
+
if ('error' in result) {
|
|
704
|
+
console.error('Failed to fetch suggestions:', result.error);
|
|
705
|
+
setSuggestions([]);
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
setSuggestions(result.suggestions.map((sug) => ({
|
|
709
|
+
text: sug,
|
|
710
|
+
autoSend: true
|
|
711
|
+
})));
|
|
712
|
+
}, []);
|
|
677
713
|
// Updated sendMessage function to support different AI models
|
|
678
714
|
const sendMessage = async (content, retryCount = 0, isPresetMessage = false) => {
|
|
679
715
|
if (!content.trim() || isLoading)
|
|
@@ -820,6 +856,7 @@ availableModels = DEFAULT_AI_MODELS, defaultModelIndex = 0, showModelSelector =
|
|
|
820
856
|
.map((item) => item.text.replace(/<thinking>/g, '').replace(/<\/thinking>/g, ''))
|
|
821
857
|
.join(' ') || 'Sorry, I cannot understand your question'
|
|
822
858
|
: response.reply.replace(/<thinking>/g, '').replace(/<\/thinking>/g, '') || 'Sorry, I cannot understand your question';
|
|
859
|
+
updateSuggestions([...contextMessages, { role: 'assistant', text: replyText }]);
|
|
823
860
|
botResponse = {
|
|
824
861
|
id: (Date.now() + 1).toString(),
|
|
825
862
|
content: replyText,
|
|
@@ -894,7 +931,13 @@ availableModels = DEFAULT_AI_MODELS, defaultModelIndex = 0, showModelSelector =
|
|
|
894
931
|
// Handle submit
|
|
895
932
|
const handleSubmit = async (e) => {
|
|
896
933
|
e.preventDefault();
|
|
897
|
-
|
|
934
|
+
while (isRecordingRef.current) {
|
|
935
|
+
stopRecording();
|
|
936
|
+
await sleep(1000);
|
|
937
|
+
}
|
|
938
|
+
if (!textInputRef.current)
|
|
939
|
+
return;
|
|
940
|
+
if (!textInputRef.current.value.trim() || isLoading)
|
|
898
941
|
return;
|
|
899
942
|
// Show loading message if AIT is still loading
|
|
900
943
|
if (isAITLoading) {
|
|
@@ -913,7 +956,7 @@ availableModels = DEFAULT_AI_MODELS, defaultModelIndex = 0, showModelSelector =
|
|
|
913
956
|
return;
|
|
914
957
|
}
|
|
915
958
|
try {
|
|
916
|
-
await sendMessage(
|
|
959
|
+
await sendMessage(textInputRef.current.value);
|
|
917
960
|
}
|
|
918
961
|
catch (error) {
|
|
919
962
|
console.error('Failed to send message:', error);
|
|
@@ -1226,10 +1269,14 @@ availableModels = DEFAULT_AI_MODELS, defaultModelIndex = 0, showModelSelector =
|
|
|
1226
1269
|
isWalletLoading,
|
|
1227
1270
|
isAutoConnecting,
|
|
1228
1271
|
notification,
|
|
1272
|
+
isRecording,
|
|
1273
|
+
transcript,
|
|
1274
|
+
textInputRef,
|
|
1229
1275
|
// AI Model related state
|
|
1230
1276
|
availableModels,
|
|
1231
1277
|
selectedModelIndex,
|
|
1232
1278
|
showModelSelector: showModelSelectorState,
|
|
1279
|
+
suggestions,
|
|
1233
1280
|
// Actions
|
|
1234
1281
|
setInputValue,
|
|
1235
1282
|
setIsOpen,
|
|
@@ -1242,6 +1289,7 @@ availableModels = DEFAULT_AI_MODELS, defaultModelIndex = 0, showModelSelector =
|
|
|
1242
1289
|
// AI Model related actions
|
|
1243
1290
|
setSelectedModelIndex,
|
|
1244
1291
|
setShowModelSelector: setShowModelSelectorState,
|
|
1292
|
+
setSuggestions,
|
|
1245
1293
|
// Functions
|
|
1246
1294
|
connectWallet,
|
|
1247
1295
|
signInWallet,
|
|
@@ -1256,6 +1304,8 @@ availableModels = DEFAULT_AI_MODELS, defaultModelIndex = 0, showModelSelector =
|
|
|
1256
1304
|
showWarning,
|
|
1257
1305
|
showInfo,
|
|
1258
1306
|
refreshAIT,
|
|
1307
|
+
startRecording,
|
|
1308
|
+
stopRecording,
|
|
1259
1309
|
// AI Model related functions
|
|
1260
1310
|
handleModelChange,
|
|
1261
1311
|
getCurrentModel,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AIT, AITApi, Message, ServicePermission } from '../../types/ait-api';
|
|
2
2
|
export interface PresetMessage {
|
|
3
3
|
text: string;
|
|
4
4
|
autoSend?: boolean;
|
|
@@ -76,9 +76,13 @@ export interface ChatBotContextType {
|
|
|
76
76
|
autoHide?: boolean;
|
|
77
77
|
duration?: number;
|
|
78
78
|
};
|
|
79
|
+
isRecording: boolean;
|
|
80
|
+
transcript: string;
|
|
81
|
+
textInputRef: React.RefObject<HTMLInputElement>;
|
|
79
82
|
availableModels: AIModel[];
|
|
80
83
|
selectedModelIndex: number;
|
|
81
84
|
showModelSelector: boolean;
|
|
85
|
+
suggestions: PresetMessage[];
|
|
82
86
|
setInputValue: (value: string) => void;
|
|
83
87
|
setIsOpen: (open: boolean) => void;
|
|
84
88
|
setShowPermissionForm: (show: boolean) => void;
|
|
@@ -89,6 +93,7 @@ export interface ChatBotContextType {
|
|
|
89
93
|
setNotification: (notification: any) => void;
|
|
90
94
|
setSelectedModelIndex: (index: number) => void;
|
|
91
95
|
setShowModelSelector: (show: boolean) => void;
|
|
96
|
+
setSuggestions: (suggestions: PresetMessage[]) => void;
|
|
92
97
|
connectWallet: (autoShowSignInMessage?: boolean) => Promise<string | undefined>;
|
|
93
98
|
signInWallet: (autoShowSuccessMessage?: boolean) => Promise<void>;
|
|
94
99
|
sendMessage: (content: string, retryCount?: number) => Promise<void>;
|
|
@@ -102,6 +107,8 @@ export interface ChatBotContextType {
|
|
|
102
107
|
showWarning: (message: string) => void;
|
|
103
108
|
showInfo: (message: string) => void;
|
|
104
109
|
refreshAIT: (forceUpdatePermissions?: boolean) => Promise<void>;
|
|
110
|
+
startRecording: () => Promise<void>;
|
|
111
|
+
stopRecording: () => void;
|
|
105
112
|
handleModelChange: (modelIndex: number) => void;
|
|
106
113
|
getCurrentModel: () => AIModel;
|
|
107
114
|
onSave: (newPermissions?: string[]) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBotTypes.d.ts","sourceRoot":"","sources":["../../../src/components/types/ChatBotTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ChatBotTypes.d.ts","sourceRoot":"","sources":["../../../src/components/types/ChatBotTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,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,EA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,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,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;IAChE,cAAc,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,aAAa,EAAE,MAAM,IAAI,CAAC;IAE1B,iBAAiB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,eAAe,EAAE,MAAM,OAAO,CAAC;IAG/B,MAAM,EAAE,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,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 @@
|
|
|
1
|
-
{"version":3,"file":"MessageInput.d.ts","sourceRoot":"","sources":["../../../src/components/ui/MessageInput.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MessageInput.d.ts","sourceRoot":"","sources":["../../../src/components/ui/MessageInput.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAmGhC,CAAC"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import MicIcon from '@mui/icons-material/Mic';
|
|
3
|
+
import MicOffIcon from '@mui/icons-material/MicOff';
|
|
4
|
+
import { IconButton, InputBase } from '@mui/material';
|
|
2
5
|
import { useChatBot } from '../context/ChatBotContext';
|
|
3
6
|
export const MessageInput = () => {
|
|
4
|
-
const { inputValue, setInputValue, isLoading, isAITLoading, handleSubmit, props: { placeholder = 'Type a message...' } } = useChatBot();
|
|
7
|
+
const { inputValue, setInputValue, isLoading, isAITLoading, handleSubmit, isRecording, startRecording, stopRecording, textInputRef, props: { placeholder = 'Type a message...' } } = useChatBot();
|
|
5
8
|
const isDisabled = isLoading || isAITLoading;
|
|
6
9
|
const inputPlaceholder = isAITLoading ? 'Loading wallet configuration...' : placeholder;
|
|
7
10
|
const handleKeyPress = (e) => {
|
|
@@ -15,7 +18,9 @@ export const MessageInput = () => {
|
|
|
15
18
|
display: 'flex',
|
|
16
19
|
gap: '10px',
|
|
17
20
|
borderTop: '1px solid #eee'
|
|
18
|
-
}, children: [_jsx(
|
|
21
|
+
}, children: [_jsx(InputBase, { value: inputValue, onChange: (e) => setInputValue(e.target.value), onKeyPress: handleKeyPress, placeholder: inputPlaceholder, disabled: isDisabled, fullWidth: true, inputProps: {
|
|
22
|
+
ref: textInputRef
|
|
23
|
+
}, endAdornment: _jsx(IconButton, { onClick: () => isRecording ? stopRecording() : startRecording(), disabled: isDisabled, children: isRecording ? _jsx(MicIcon, {}) : _jsx(MicOffIcon, {}) }), onFocus: () => stopRecording(), style: {
|
|
19
24
|
flex: 1,
|
|
20
25
|
padding: '10px',
|
|
21
26
|
border: '1px solid #ddd',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresetMessages.d.ts","sourceRoot":"","sources":["../../../src/components/ui/PresetMessages.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"PresetMessages.d.ts","sourceRoot":"","sources":["../../../src/components/ui/PresetMessages.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAgDlC,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useChatBot } from '../context/ChatBotContext';
|
|
3
3
|
export const PresetMessages = () => {
|
|
4
|
-
const {
|
|
5
|
-
|
|
6
|
-
if (!presetMessages || presetMessages.length === 0) {
|
|
4
|
+
const { suggestions, handlePresetMessage } = useChatBot();
|
|
5
|
+
if (!suggestions || suggestions.length === 0) {
|
|
7
6
|
return null;
|
|
8
7
|
}
|
|
9
8
|
return (_jsx("div", { style: {
|
|
@@ -14,7 +13,7 @@ export const PresetMessages = () => {
|
|
|
14
13
|
display: 'flex',
|
|
15
14
|
gap: '10px',
|
|
16
15
|
alignItems: 'center'
|
|
17
|
-
}, children:
|
|
16
|
+
}, children: suggestions.map((preset, index) => (_jsx("button", { onClick: () => handlePresetMessage(preset), style: {
|
|
18
17
|
backgroundColor: '#007bff',
|
|
19
18
|
color: 'white',
|
|
20
19
|
border: 'none',
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SpeechRecognizer } from 'microsoft-cognitiveservices-speech-sdk';
|
|
2
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* 啟動語音辨識,會不斷更新 speechToTextArray(每段句子為一個陣列元素)
|
|
5
|
+
*/
|
|
6
|
+
export declare const startSpeechToTextFromMic: (setSpeechToTextArray: Dispatch<SetStateAction<string[]>>, config: {
|
|
7
|
+
apiKey: string;
|
|
8
|
+
apiSecret: string;
|
|
9
|
+
}) => Promise<SpeechRecognizer | undefined>;
|
|
10
|
+
/**
|
|
11
|
+
* 停止語音辨識
|
|
12
|
+
*/
|
|
13
|
+
export declare const stopRecognition: (recognizer: SpeechRecognizer | undefined) => void;
|
|
14
|
+
export declare function getTokenOrRefresh(apiKey: string, apiSecret: string): Promise<{
|
|
15
|
+
authToken: null;
|
|
16
|
+
error: string;
|
|
17
|
+
region?: undefined;
|
|
18
|
+
} | {
|
|
19
|
+
authToken: any;
|
|
20
|
+
region: any;
|
|
21
|
+
error?: undefined;
|
|
22
|
+
}>;
|
|
23
|
+
//# sourceMappingURL=helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../../../src/core/lib/useSpeechToTextFromMic/helper.ts"],"names":[],"mappings":"AACA,OAAO,EAML,gBAAgB,EACjB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAMjD;;GAEG;AACH,eAAO,MAAM,wBAAwB,GACnC,sBAAsB,QAAQ,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC,EACxD,QAAQ;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,KAC5C,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAyCtC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,YAAY,gBAAgB,GAAG,SAAS,SAIvE,CAAC;AAEF,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;;;;;;;;GAyBxE"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { AudioConfig, CancellationReason, PropertyId, ResultReason, SpeechConfig, SpeechRecognizer, } from 'microsoft-cognitiveservices-speech-sdk';
|
|
2
|
+
import Cookie from 'universal-cookie';
|
|
3
|
+
import { createNxtlinqApi } from '../../../api/nxtlinq-api';
|
|
4
|
+
let recognizer;
|
|
5
|
+
/**
|
|
6
|
+
* 啟動語音辨識,會不斷更新 speechToTextArray(每段句子為一個陣列元素)
|
|
7
|
+
*/
|
|
8
|
+
export const startSpeechToTextFromMic = async (setSpeechToTextArray, config) => {
|
|
9
|
+
const tokenRes = await getTokenOrRefresh(config.apiKey, config.apiSecret);
|
|
10
|
+
const speechConfig = SpeechConfig.fromAuthorizationToken(tokenRes.authToken, tokenRes.region);
|
|
11
|
+
speechConfig.speechRecognitionLanguage = 'en-US';
|
|
12
|
+
speechConfig.setProperty(PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs, '10000');
|
|
13
|
+
speechConfig.setProperty(PropertyId.SpeechServiceConnection_EndSilenceTimeoutMs, '86400000');
|
|
14
|
+
speechConfig.setProperty(PropertyId.Speech_SegmentationSilenceTimeoutMs, '2500');
|
|
15
|
+
const audioConfig = AudioConfig.fromDefaultMicrophoneInput();
|
|
16
|
+
recognizer = new SpeechRecognizer(speechConfig, audioConfig);
|
|
17
|
+
const conversationHistory = [];
|
|
18
|
+
let index = 0;
|
|
19
|
+
recognizer.recognizing = (_s, e) => {
|
|
20
|
+
console.log(`RECOGNIZING: Text=${e.result.text}`);
|
|
21
|
+
conversationHistory[index] = e.result.text;
|
|
22
|
+
setSpeechToTextArray([...conversationHistory]);
|
|
23
|
+
};
|
|
24
|
+
recognizer.recognized = (_s, e) => {
|
|
25
|
+
if (e.result.reason === ResultReason.RecognizedSpeech) {
|
|
26
|
+
console.log(`RECOGNIZED: Text=${e.result.text}`);
|
|
27
|
+
conversationHistory[index] = e.result.text;
|
|
28
|
+
setSpeechToTextArray([...conversationHistory]);
|
|
29
|
+
index += 1;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
recognizer.canceled = (_s, e) => {
|
|
33
|
+
console.log(`CANCELED: Reason=${e.reason}`);
|
|
34
|
+
if (e.reason === CancellationReason.Error) {
|
|
35
|
+
console.error(`CANCELED: ErrorCode=${e.errorCode}`);
|
|
36
|
+
console.error(`CANCELED: ErrorDetails=${e.errorDetails}`);
|
|
37
|
+
console.error('CANCELED: Did you set the speech resource key and region values?');
|
|
38
|
+
}
|
|
39
|
+
stopRecognition(recognizer);
|
|
40
|
+
};
|
|
41
|
+
recognizer.startContinuousRecognitionAsync();
|
|
42
|
+
return recognizer;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* 停止語音辨識
|
|
46
|
+
*/
|
|
47
|
+
export const stopRecognition = (recognizer) => {
|
|
48
|
+
if (recognizer) {
|
|
49
|
+
recognizer.stopContinuousRecognitionAsync();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
export async function getTokenOrRefresh(apiKey, apiSecret) {
|
|
53
|
+
const nxtlinqApi = createNxtlinqApi(apiKey, apiSecret);
|
|
54
|
+
const cookie = new Cookie();
|
|
55
|
+
const speechToken = cookie.get('speech-token');
|
|
56
|
+
if (speechToken === undefined) {
|
|
57
|
+
try {
|
|
58
|
+
const res = await nxtlinqApi.cognitive.getCognitiveToken();
|
|
59
|
+
if ('error' in res) {
|
|
60
|
+
throw new Error(res.error);
|
|
61
|
+
}
|
|
62
|
+
const token = res.token;
|
|
63
|
+
const region = res.region;
|
|
64
|
+
cookie.set('speech-token', region + ':' + token, { maxAge: 540, path: '/' });
|
|
65
|
+
return { authToken: token, region: region };
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
const err = e;
|
|
69
|
+
console.log(err.response.data);
|
|
70
|
+
return { authToken: null, error: err.response.data };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
const idx = speechToken.indexOf(':');
|
|
75
|
+
return { authToken: speechToken.slice(idx + 1), region: speechToken.slice(0, idx) };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
apiSecret: string;
|
|
4
|
+
}
|
|
5
|
+
type UseSpeechToTextFromMicResult = {
|
|
6
|
+
start: () => Promise<void>;
|
|
7
|
+
stop: () => void;
|
|
8
|
+
isRecording: boolean;
|
|
9
|
+
transcript: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function useSpeechToTextFromMic({ apiKey, apiSecret }: Props): UseSpeechToTextFromMicResult;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/lib/useSpeechToTextFromMic/index.ts"],"names":[],"mappings":"AAIA,UAAU,KAAK;IACb,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,KAAK,4BAA4B,GAAG;IAClC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,KAAK,GAAG,4BAA4B,CA0CjG"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useRef, useState } from 'react';
|
|
2
|
+
import { startSpeechToTextFromMic, stopRecognition } from './helper';
|
|
3
|
+
export function useSpeechToTextFromMic({ apiKey, apiSecret }) {
|
|
4
|
+
const [isRecording, setIsRecording] = useState(false);
|
|
5
|
+
const [transcriptArray, setTranscriptArray] = useState([]);
|
|
6
|
+
const [recognizer, setRecognizer] = useState();
|
|
7
|
+
const wakelock = useRef();
|
|
8
|
+
const canWakeLock = () => 'wakeLock' in navigator;
|
|
9
|
+
async function lockWakeState() {
|
|
10
|
+
if (!canWakeLock())
|
|
11
|
+
return;
|
|
12
|
+
try {
|
|
13
|
+
wakelock.current = await navigator.wakeLock.request('screen');
|
|
14
|
+
wakelock.current.addEventListener('release', () => {
|
|
15
|
+
console.log('Wake lock released');
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
console.error('Wake lock error:', err);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const start = async () => {
|
|
23
|
+
await lockWakeState();
|
|
24
|
+
setIsRecording(true);
|
|
25
|
+
const recognizerInstance = await startSpeechToTextFromMic(setTranscriptArray, { apiKey, apiSecret });
|
|
26
|
+
setRecognizer(recognizerInstance);
|
|
27
|
+
};
|
|
28
|
+
const stop = () => {
|
|
29
|
+
wakelock.current?.release();
|
|
30
|
+
stopRecognition(recognizer);
|
|
31
|
+
setIsRecording(false);
|
|
32
|
+
setRecognizer(undefined);
|
|
33
|
+
};
|
|
34
|
+
const transcript = transcriptArray.join(' ');
|
|
35
|
+
return {
|
|
36
|
+
start,
|
|
37
|
+
stop,
|
|
38
|
+
isRecording,
|
|
39
|
+
transcript,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/utils/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,GAAI,IAAI,MAAM,qBAE/B,CAAA"}
|
package/dist/types/ait-api.d.ts
CHANGED
|
@@ -169,6 +169,18 @@ export interface AITApi {
|
|
|
169
169
|
} | {
|
|
170
170
|
error: string;
|
|
171
171
|
}>;
|
|
172
|
+
generateSuggestions: (params: {
|
|
173
|
+
apiKey: string;
|
|
174
|
+
apiSecret: string;
|
|
175
|
+
context: Array<{
|
|
176
|
+
role: string;
|
|
177
|
+
text: string;
|
|
178
|
+
}>;
|
|
179
|
+
}) => Promise<{
|
|
180
|
+
suggestions: Array<string>;
|
|
181
|
+
} | {
|
|
182
|
+
error: string;
|
|
183
|
+
}>;
|
|
172
184
|
};
|
|
173
185
|
permissions: {
|
|
174
186
|
getServicePermissions: (params: {
|
|
@@ -180,5 +192,13 @@ export interface AITApi {
|
|
|
180
192
|
error: string;
|
|
181
193
|
}>;
|
|
182
194
|
};
|
|
195
|
+
cognitive: {
|
|
196
|
+
getCognitiveToken: () => Promise<{
|
|
197
|
+
token: string;
|
|
198
|
+
region: string;
|
|
199
|
+
} | {
|
|
200
|
+
error: string;
|
|
201
|
+
}>;
|
|
202
|
+
};
|
|
183
203
|
}
|
|
184
204
|
//# sourceMappingURL=ait-api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ait-api.d.ts","sourceRoot":"","sources":["../../src/types/ait-api.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE;QACT,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE;YACR,IAAI,EAAE,MAAM,CAAC;YACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;SAC5B,CAAC;QACF,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED,MAAM,WAAW,GAAG;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,WAAW,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,M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AAM,CAAC;YACf,SAAS,EAAE,MAAM,CAAC;YAClB,OAAO,EAAE,KAAK,CAAC;gBAAE,IAAI,EAAE,MAAM,CAAC;gBAAC,IAAI,EAAE,MAAM,CAAA;aAAE,CAAC,CAAC;SAChD,KAAK,OAAO,CAAC;YAAE,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;SAAE,GAAG;YAAE,KAAK,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KACnE,CAAC;IACF,WAAW,EAAE;QACX,qBAAqB,EAAE,CAAC,MAAM,EAAE;YAAE,SAAS,EAAE,MAAM,CAAC;YAAC,SAAS,CAAC,EAAE,MAAM,CAAA;SAAE,KAAK,OAAO,CAAC;YAAE,WAAW,EAAE,iBAAiB,EAAE,CAAA;SAAE,GAAG;YAAE,KAAK,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KACjJ,CAAC;IACF,SAAS,EAAE;QACT,iBAAiB,EAAE,MAAM,OAAO,CAAC;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,GAAG;YAAE,KAAK,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KACzF,CAAC;CACH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytexbyte/nxtlinq-ai-agent-sdk",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Nxtlinq AI Agent SDK - Proprietary Software with enhanced async operation handling",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "tsc",
|
|
12
12
|
"prepare": "npm run build",
|
|
13
|
-
"test": "jest"
|
|
13
|
+
"test": "jest",
|
|
14
|
+
"publish": "npm run build && npm pack && npm publish"
|
|
14
15
|
},
|
|
15
16
|
"keywords": [
|
|
16
17
|
"nxtlinq",
|
|
@@ -34,8 +35,14 @@
|
|
|
34
35
|
"typescript": "^5.4.2"
|
|
35
36
|
},
|
|
36
37
|
"dependencies": {
|
|
38
|
+
"@emotion/react": "^11.14.0",
|
|
39
|
+
"@emotion/styled": "^11.14.1",
|
|
40
|
+
"@mui/icons-material": "^7.2.0",
|
|
41
|
+
"@mui/material": "^7.2.0",
|
|
37
42
|
"ethers": "5.7.0",
|
|
38
43
|
"json-stable-stringify": "^1.0.2",
|
|
39
|
-
"metakeep": "^2.2.8"
|
|
44
|
+
"metakeep": "^2.2.8",
|
|
45
|
+
"microsoft-cognitiveservices-speech-sdk": "^1.45.0",
|
|
46
|
+
"universal-cookie": "^8.0.1"
|
|
40
47
|
}
|
|
41
|
-
}
|
|
48
|
+
}
|