@bytexbyte/nxtlinq-ai-agent-ui-react-development 0.2.5 → 0.3.1
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/context/ChatBotContext.d.ts.map +1 -1
- package/dist/context/ChatBotContext.js +48 -35
- package/dist/types/ChatBotTypes.d.ts +4 -2
- package/dist/types/ChatBotTypes.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/context/ChatBotContext.tsx +54 -35
- package/src/types/ChatBotTypes.ts +4 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBotContext.d.ts","sourceRoot":"","sources":["../../src/context/ChatBotContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAyB/B,OAAO,EAEL,kBAAkB,EAClB,YAAY,EAEb,MAAM,uBAAuB,CAAC;AAM/B,eAAO,MAAM,UAAU,0BAMtB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"ChatBotContext.d.ts","sourceRoot":"","sources":["../../src/context/ChatBotContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAyB/B,OAAO,EAEL,kBAAkB,EAClB,YAAY,EAEb,MAAM,uBAAuB,CAAC;AAM/B,eAAO,MAAM,UAAU,0BAMtB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAmuGlD,CAAC"}
|
|
@@ -14,7 +14,7 @@ export const useChatBot = () => {
|
|
|
14
14
|
}
|
|
15
15
|
return context;
|
|
16
16
|
};
|
|
17
|
-
export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages = [], placeholder = 'Type a message...', className = '', maxRetries = 3, retryDelay = 2000, serviceId, apiKey, apiSecret, environment = 'production', onVerifyWallet, permissionGroup, children,
|
|
17
|
+
export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages = [], placeholder = 'Type a message...', className = '', maxRetries = 3, retryDelay = 2000, serviceId, apiKey, apiSecret, serviceToken, getAuthToken, environment = 'production', onVerifyWallet, permissionGroup, children,
|
|
18
18
|
// AI Model related attributes
|
|
19
19
|
onModelChange,
|
|
20
20
|
// Storage mode configuration
|
|
@@ -35,14 +35,26 @@ customError,
|
|
|
35
35
|
piiDisplayMode = 'redacted', voiceThresholds, debugVoiceRms = false, sttGlossary, }) => {
|
|
36
36
|
// Set API hosts immediately based on environment (before any API calls)
|
|
37
37
|
setApiHosts(environment);
|
|
38
|
-
const nxtlinqApi = React.useMemo(() =>
|
|
38
|
+
const nxtlinqApi = React.useMemo(() => (serviceToken || getAuthToken
|
|
39
|
+
? createNxtlinqApi({ apiKey, apiSecret, serviceToken, getAuthToken })
|
|
40
|
+
: createNxtlinqApi(apiKey ?? '', apiSecret ?? '')), [apiKey, apiSecret, serviceToken, getAuthToken]);
|
|
39
41
|
const apiKeyRef = React.useRef(apiKey);
|
|
40
42
|
const apiSecretRef = React.useRef(apiSecret);
|
|
43
|
+
const serviceTokenRef = React.useRef(serviceToken);
|
|
44
|
+
const getAuthTokenRef = React.useRef(getAuthToken);
|
|
41
45
|
const clientTtsVoiceRef = React.useRef(undefined);
|
|
42
46
|
React.useEffect(() => {
|
|
43
47
|
apiKeyRef.current = apiKey;
|
|
44
48
|
apiSecretRef.current = apiSecret;
|
|
45
|
-
|
|
49
|
+
serviceTokenRef.current = serviceToken;
|
|
50
|
+
getAuthTokenRef.current = getAuthToken;
|
|
51
|
+
}, [apiKey, apiSecret, serviceToken, getAuthToken]);
|
|
52
|
+
const authFields = React.useCallback(() => ({
|
|
53
|
+
apiKey: apiKeyRef.current,
|
|
54
|
+
apiSecret: apiSecretRef.current,
|
|
55
|
+
serviceToken: serviceTokenRef.current,
|
|
56
|
+
getAuthToken: getAuthTokenRef.current,
|
|
57
|
+
}), []);
|
|
46
58
|
// Custom hook
|
|
47
59
|
const handleSttCorrected = React.useCallback((rawText, corrected) => {
|
|
48
60
|
const normalizedRaw = normalizeTranscript(rawText);
|
|
@@ -55,8 +67,10 @@ piiDisplayMode = 'redacted', voiceThresholds, debugVoiceRms = false, sttGlossary
|
|
|
55
67
|
});
|
|
56
68
|
}, []);
|
|
57
69
|
const { isMicEnabled, transcript, partialTranscript, isCorrecting, start: startRecording, stop: stopRecording, clear: clearRecording } = useSpeechToTextFromMic({
|
|
58
|
-
apiKey,
|
|
59
|
-
apiSecret,
|
|
70
|
+
apiKey: apiKey ?? '',
|
|
71
|
+
apiSecret: apiSecret ?? '',
|
|
72
|
+
serviceToken,
|
|
73
|
+
getAuthToken,
|
|
60
74
|
phraseHints: sttGlossary,
|
|
61
75
|
onCorrected: handleSttCorrected,
|
|
62
76
|
});
|
|
@@ -240,8 +254,10 @@ piiDisplayMode = 'redacted', voiceThresholds, debugVoiceRms = false, sttGlossary
|
|
|
240
254
|
}
|
|
241
255
|
await streamSpeechToAudioContext({
|
|
242
256
|
text,
|
|
243
|
-
apiKey: apiKeyRef.current,
|
|
244
|
-
apiSecret: apiSecretRef.current,
|
|
257
|
+
apiKey: apiKeyRef.current ?? '',
|
|
258
|
+
apiSecret: apiSecretRef.current ?? '',
|
|
259
|
+
serviceToken: serviceTokenRef.current,
|
|
260
|
+
getAuthToken: getAuthTokenRef.current,
|
|
245
261
|
audioCtx: audioCtxRef.current,
|
|
246
262
|
signal: abortController.signal,
|
|
247
263
|
onSourceScheduled: (source) => {
|
|
@@ -268,8 +284,10 @@ piiDisplayMode = 'redacted', voiceThresholds, debugVoiceRms = false, sttGlossary
|
|
|
268
284
|
}
|
|
269
285
|
const synth = await synthesizeSpeechToBuffer({
|
|
270
286
|
text,
|
|
271
|
-
apiKey: apiKeyRef.current,
|
|
272
|
-
apiSecret: apiSecretRef.current,
|
|
287
|
+
apiKey: apiKeyRef.current ?? '',
|
|
288
|
+
apiSecret: apiSecretRef.current ?? '',
|
|
289
|
+
serviceToken: serviceTokenRef.current,
|
|
290
|
+
getAuthToken: getAuthTokenRef.current,
|
|
273
291
|
settings: clientTtsVoiceRef.current,
|
|
274
292
|
});
|
|
275
293
|
if (!synth)
|
|
@@ -764,7 +782,7 @@ piiDisplayMode = 'redacted', voiceThresholds, debugVoiceRms = false, sttGlossary
|
|
|
764
782
|
React.useEffect(() => {
|
|
765
783
|
const fetchModels = async () => {
|
|
766
784
|
try {
|
|
767
|
-
const result = await nxtlinqApi.agent.getServiceModels(
|
|
785
|
+
const result = await nxtlinqApi.agent.getServiceModels(authFields());
|
|
768
786
|
if ('availableModels' in result && Array.isArray(result.availableModels)) {
|
|
769
787
|
setModelsFromApi(result.availableModels);
|
|
770
788
|
}
|
|
@@ -775,7 +793,7 @@ piiDisplayMode = 'redacted', voiceThresholds, debugVoiceRms = false, sttGlossary
|
|
|
775
793
|
}
|
|
776
794
|
};
|
|
777
795
|
fetchModels();
|
|
778
|
-
}, [
|
|
796
|
+
}, [authFields, nxtlinqApi]);
|
|
779
797
|
// Validate selectedModelIndex against effectiveAvailableModels
|
|
780
798
|
React.useEffect(() => {
|
|
781
799
|
// Check if selectedModelIndex is out of bounds
|
|
@@ -1364,8 +1382,7 @@ piiDisplayMode = 'redacted', voiceThresholds, debugVoiceRms = false, sttGlossary
|
|
|
1364
1382
|
return false;
|
|
1365
1383
|
}
|
|
1366
1384
|
const checkToolPermissionResult = await nxtlinqApi.agent.checkToolPermission({
|
|
1367
|
-
|
|
1368
|
-
apiSecret,
|
|
1385
|
+
...authFields(),
|
|
1369
1386
|
aitToken: currentToken,
|
|
1370
1387
|
controller: currentHitAddress,
|
|
1371
1388
|
toolName: requiredPermission
|
|
@@ -1447,8 +1464,7 @@ piiDisplayMode = 'redacted', voiceThresholds, debugVoiceRms = false, sttGlossary
|
|
|
1447
1464
|
}, [effectiveAvailableModels, selectedModelIndex]);
|
|
1448
1465
|
const updateSuggestions = React.useCallback(async (pseudoId, externalId) => {
|
|
1449
1466
|
const result = await nxtlinqApi.agent.generateSuggestions({
|
|
1450
|
-
|
|
1451
|
-
apiSecret,
|
|
1467
|
+
...authFields(),
|
|
1452
1468
|
pseudoId,
|
|
1453
1469
|
externalId
|
|
1454
1470
|
});
|
|
@@ -1536,8 +1552,7 @@ piiDisplayMode = 'redacted', voiceThresholds, debugVoiceRms = false, sttGlossary
|
|
|
1536
1552
|
}
|
|
1537
1553
|
const response = await nxtlinqApi.agent.sendMessage({
|
|
1538
1554
|
model: currentModel.value,
|
|
1539
|
-
|
|
1540
|
-
apiSecret,
|
|
1555
|
+
...authFields(),
|
|
1541
1556
|
pseudoId: pseudoId,
|
|
1542
1557
|
externalId: localStorage.getItem('walletAddress') || undefined,
|
|
1543
1558
|
customUserInfo,
|
|
@@ -1902,11 +1917,10 @@ piiDisplayMode = 'redacted', voiceThresholds, debugVoiceRms = false, sttGlossary
|
|
|
1902
1917
|
}
|
|
1903
1918
|
: msg));
|
|
1904
1919
|
// Update message content in database if assistantMessageId is available
|
|
1905
|
-
if (response.assistantMessageId
|
|
1920
|
+
if (response.assistantMessageId) {
|
|
1906
1921
|
try {
|
|
1907
1922
|
await nxtlinqApi.agent.updateMessageContent({
|
|
1908
|
-
|
|
1909
|
-
apiSecret,
|
|
1923
|
+
...authFields(),
|
|
1910
1924
|
messageId: response.assistantMessageId,
|
|
1911
1925
|
content: finalContent,
|
|
1912
1926
|
});
|
|
@@ -1942,11 +1956,10 @@ piiDisplayMode = 'redacted', voiceThresholds, debugVoiceRms = false, sttGlossary
|
|
|
1942
1956
|
mergedContent += `\n\n${replyText}`;
|
|
1943
1957
|
}
|
|
1944
1958
|
// Update message content in database if assistantMessageId is available
|
|
1945
|
-
if (response.assistantMessageId
|
|
1959
|
+
if (response.assistantMessageId) {
|
|
1946
1960
|
try {
|
|
1947
1961
|
await nxtlinqApi.agent.updateMessageContent({
|
|
1948
|
-
|
|
1949
|
-
apiSecret,
|
|
1962
|
+
...authFields(),
|
|
1950
1963
|
messageId: response.assistantMessageId,
|
|
1951
1964
|
content: mergedContent,
|
|
1952
1965
|
});
|
|
@@ -2257,8 +2270,10 @@ piiDisplayMode = 'redacted', voiceThresholds, debugVoiceRms = false, sttGlossary
|
|
|
2257
2270
|
}
|
|
2258
2271
|
}, [textToSpeechEnabled, stopTextToSpeechAndReset]);
|
|
2259
2272
|
const { isVoiceMode, voiceStatus, isVoiceConnecting, isMicMuted, remoteAudioRef, enterVoiceMode, exitVoiceMode, toggleMicMute: toggleVoiceMicMute, interruptVoice, micRms, } = useVoiceMode({
|
|
2260
|
-
apiKey,
|
|
2261
|
-
apiSecret,
|
|
2273
|
+
apiKey: apiKey ?? '',
|
|
2274
|
+
apiSecret: apiSecret ?? '',
|
|
2275
|
+
serviceToken,
|
|
2276
|
+
getAuthToken,
|
|
2262
2277
|
pseudoId,
|
|
2263
2278
|
externalId: hitAddress || undefined,
|
|
2264
2279
|
aitId: ait?.aitId,
|
|
@@ -2362,15 +2377,14 @@ piiDisplayMode = 'redacted', voiceThresholds, debugVoiceRms = false, sttGlossary
|
|
|
2362
2377
|
}, [requiresGesture, textToSpeechEnabled, retryTtsWithGesture]);
|
|
2363
2378
|
const uploadAttachment = React.useCallback(async (file) => {
|
|
2364
2379
|
const result = await nxtlinqApi.agent.uploadAttachment({
|
|
2365
|
-
|
|
2366
|
-
apiSecret,
|
|
2380
|
+
...authFields(),
|
|
2367
2381
|
pseudoId,
|
|
2368
2382
|
file,
|
|
2369
2383
|
});
|
|
2370
2384
|
if ('error' in result)
|
|
2371
2385
|
return result;
|
|
2372
2386
|
return { url: result.url };
|
|
2373
|
-
}, [nxtlinqApi,
|
|
2387
|
+
}, [nxtlinqApi, authFields, pseudoId]);
|
|
2374
2388
|
// Handle preset message
|
|
2375
2389
|
const handlePresetMessage = (message) => {
|
|
2376
2390
|
// If preset is configured as auto-send, avoid duplicate sends when user clicks repeatedly
|
|
@@ -2863,26 +2877,23 @@ piiDisplayMode = 'redacted', voiceThresholds, debugVoiceRms = false, sttGlossary
|
|
|
2863
2877
|
const updateExternalId = async () => {
|
|
2864
2878
|
const externalId = hitAddress;
|
|
2865
2879
|
await nxtlinqApi.agent.updateMessagesExternalIdByPseudoId({
|
|
2866
|
-
|
|
2867
|
-
apiSecret,
|
|
2880
|
+
...authFields(),
|
|
2868
2881
|
pseudoId,
|
|
2869
2882
|
externalId: externalId,
|
|
2870
2883
|
});
|
|
2871
2884
|
await nxtlinqApi.agent.cloneUserProfileByPseudoId({
|
|
2872
|
-
|
|
2873
|
-
apiSecret,
|
|
2885
|
+
...authFields(),
|
|
2874
2886
|
pseudoId,
|
|
2875
2887
|
externalId: externalId,
|
|
2876
2888
|
});
|
|
2877
2889
|
await nxtlinqApi.agent.cloneUserTopicByPseudoId({
|
|
2878
|
-
|
|
2879
|
-
apiSecret,
|
|
2890
|
+
...authFields(),
|
|
2880
2891
|
pseudoId,
|
|
2881
2892
|
externalId: externalId,
|
|
2882
2893
|
});
|
|
2883
2894
|
};
|
|
2884
2895
|
updateExternalId();
|
|
2885
|
-
}, [hitAddress, nxtlinqApi,
|
|
2896
|
+
}, [hitAddress, nxtlinqApi, authFields, pseudoId]);
|
|
2886
2897
|
const contextValue = {
|
|
2887
2898
|
// State
|
|
2888
2899
|
messages,
|
|
@@ -2989,6 +3000,8 @@ piiDisplayMode = 'redacted', voiceThresholds, debugVoiceRms = false, sttGlossary
|
|
|
2989
3000
|
serviceId,
|
|
2990
3001
|
apiKey,
|
|
2991
3002
|
apiSecret,
|
|
3003
|
+
serviceToken,
|
|
3004
|
+
getAuthToken,
|
|
2992
3005
|
onVerifyWallet,
|
|
2993
3006
|
permissionGroup,
|
|
2994
3007
|
onModelChange,
|
|
@@ -44,8 +44,10 @@ export interface ChatBotProps {
|
|
|
44
44
|
maxRetries?: number;
|
|
45
45
|
retryDelay?: number;
|
|
46
46
|
serviceId: string;
|
|
47
|
-
apiKey
|
|
48
|
-
apiSecret
|
|
47
|
+
apiKey?: string;
|
|
48
|
+
apiSecret?: string;
|
|
49
|
+
serviceToken?: string;
|
|
50
|
+
getAuthToken?: () => Promise<string>;
|
|
49
51
|
environment?: 'production' | 'staging';
|
|
50
52
|
onVerifyWallet?: () => Promise<{
|
|
51
53
|
token: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBotTypes.d.ts","sourceRoot":"","sources":["../../src/types/ChatBotTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,8CAA8C,CAAC;AAErI,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,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAGD,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AACD,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,CACV,OAAO,E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CAAC;IAC/E,cAAc,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,aAAa,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,kBAAkB,EAAE,MAAM,IAAI,CAAC;IAC/B,cAAc,EAAE,MAAM,IAAI,CAAC;IAG3B,MAAM,EAAE,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,eAAe,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,KAAK,GAAG,SAAS,CAAC,CAAC;IAC3D,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,sBAAsB,EAAE,OAAO,CAAC;IAChC,cAAc,EAAE,CAAC,MAAM,EAAE,UAAU,GAAG,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IAGzB,KAAK,EAAE,YAAY,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytexbyte/nxtlinq-ai-agent-ui-react-development",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Official React Web UI for nxtlinq AI Agent — drop-in chat widget",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"react-dom": ">=18.0.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@bytexbyte/nxtlinq-ai-agent-core-development": "0.
|
|
42
|
-
"@bytexbyte/nxtlinq-ai-agent-web-development": "0.
|
|
41
|
+
"@bytexbyte/nxtlinq-ai-agent-core-development": "0.5.0",
|
|
42
|
+
"@bytexbyte/nxtlinq-ai-agent-web-development": "0.3.0",
|
|
43
43
|
"@emotion/react": "^11.14.0",
|
|
44
44
|
"@emotion/styled": "^11.14.1",
|
|
45
45
|
"@mui/icons-material": "^7.2.0",
|
|
@@ -56,6 +56,8 @@ export const ChatBotProvider: React.FC<ChatBotProps> = ({
|
|
|
56
56
|
serviceId,
|
|
57
57
|
apiKey,
|
|
58
58
|
apiSecret,
|
|
59
|
+
serviceToken,
|
|
60
|
+
getAuthToken,
|
|
59
61
|
environment = 'production',
|
|
60
62
|
onVerifyWallet,
|
|
61
63
|
permissionGroup,
|
|
@@ -86,15 +88,31 @@ export const ChatBotProvider: React.FC<ChatBotProps> = ({
|
|
|
86
88
|
// Set API hosts immediately based on environment (before any API calls)
|
|
87
89
|
setApiHosts(environment);
|
|
88
90
|
|
|
89
|
-
const nxtlinqApi = React.useMemo(
|
|
91
|
+
const nxtlinqApi = React.useMemo(
|
|
92
|
+
() => (serviceToken || getAuthToken
|
|
93
|
+
? createNxtlinqApi({ apiKey, apiSecret, serviceToken, getAuthToken })
|
|
94
|
+
: createNxtlinqApi(apiKey ?? '', apiSecret ?? '')),
|
|
95
|
+
[apiKey, apiSecret, serviceToken, getAuthToken],
|
|
96
|
+
);
|
|
90
97
|
|
|
91
98
|
const apiKeyRef = React.useRef(apiKey);
|
|
92
99
|
const apiSecretRef = React.useRef(apiSecret);
|
|
100
|
+
const serviceTokenRef = React.useRef(serviceToken);
|
|
101
|
+
const getAuthTokenRef = React.useRef(getAuthToken);
|
|
93
102
|
const clientTtsVoiceRef = React.useRef<ClientTtsVoiceSettings | undefined>(undefined);
|
|
94
103
|
React.useEffect(() => {
|
|
95
104
|
apiKeyRef.current = apiKey;
|
|
96
105
|
apiSecretRef.current = apiSecret;
|
|
97
|
-
|
|
106
|
+
serviceTokenRef.current = serviceToken;
|
|
107
|
+
getAuthTokenRef.current = getAuthToken;
|
|
108
|
+
}, [apiKey, apiSecret, serviceToken, getAuthToken]);
|
|
109
|
+
|
|
110
|
+
const authFields = React.useCallback(() => ({
|
|
111
|
+
apiKey: apiKeyRef.current,
|
|
112
|
+
apiSecret: apiSecretRef.current,
|
|
113
|
+
serviceToken: serviceTokenRef.current,
|
|
114
|
+
getAuthToken: getAuthTokenRef.current,
|
|
115
|
+
}), []);
|
|
98
116
|
|
|
99
117
|
// Custom hook
|
|
100
118
|
const handleSttCorrected = React.useCallback((rawText: string, corrected: string) => {
|
|
@@ -108,8 +126,10 @@ export const ChatBotProvider: React.FC<ChatBotProps> = ({
|
|
|
108
126
|
}, []);
|
|
109
127
|
|
|
110
128
|
const { isMicEnabled, transcript, partialTranscript, isCorrecting, start: startRecording, stop: stopRecording, clear: clearRecording } = useSpeechToTextFromMic({
|
|
111
|
-
apiKey,
|
|
112
|
-
apiSecret,
|
|
129
|
+
apiKey: apiKey ?? '',
|
|
130
|
+
apiSecret: apiSecret ?? '',
|
|
131
|
+
serviceToken,
|
|
132
|
+
getAuthToken,
|
|
113
133
|
phraseHints: sttGlossary,
|
|
114
134
|
onCorrected: handleSttCorrected,
|
|
115
135
|
});
|
|
@@ -315,8 +335,10 @@ export const ChatBotProvider: React.FC<ChatBotProps> = ({
|
|
|
315
335
|
|
|
316
336
|
await streamSpeechToAudioContext({
|
|
317
337
|
text,
|
|
318
|
-
apiKey: apiKeyRef.current,
|
|
319
|
-
apiSecret: apiSecretRef.current,
|
|
338
|
+
apiKey: apiKeyRef.current ?? '',
|
|
339
|
+
apiSecret: apiSecretRef.current ?? '',
|
|
340
|
+
serviceToken: serviceTokenRef.current,
|
|
341
|
+
getAuthToken: getAuthTokenRef.current,
|
|
320
342
|
audioCtx: audioCtxRef.current,
|
|
321
343
|
signal: abortController.signal,
|
|
322
344
|
onSourceScheduled: (source: AudioBufferSourceNode) => {
|
|
@@ -341,8 +363,10 @@ export const ChatBotProvider: React.FC<ChatBotProps> = ({
|
|
|
341
363
|
|
|
342
364
|
const synth = await synthesizeSpeechToBuffer({
|
|
343
365
|
text,
|
|
344
|
-
apiKey: apiKeyRef.current,
|
|
345
|
-
apiSecret: apiSecretRef.current,
|
|
366
|
+
apiKey: apiKeyRef.current ?? '',
|
|
367
|
+
apiSecret: apiSecretRef.current ?? '',
|
|
368
|
+
serviceToken: serviceTokenRef.current,
|
|
369
|
+
getAuthToken: getAuthTokenRef.current,
|
|
346
370
|
settings: clientTtsVoiceRef.current,
|
|
347
371
|
});
|
|
348
372
|
if (!synth) throw new Error('Failed to get audio buffer');
|
|
@@ -885,7 +909,7 @@ export const ChatBotProvider: React.FC<ChatBotProps> = ({
|
|
|
885
909
|
React.useEffect(() => {
|
|
886
910
|
const fetchModels = async () => {
|
|
887
911
|
try {
|
|
888
|
-
const result = await nxtlinqApi.agent.getServiceModels(
|
|
912
|
+
const result = await nxtlinqApi.agent.getServiceModels(authFields());
|
|
889
913
|
|
|
890
914
|
if ('availableModels' in result && Array.isArray(result.availableModels)) {
|
|
891
915
|
setModelsFromApi(result.availableModels);
|
|
@@ -897,7 +921,7 @@ export const ChatBotProvider: React.FC<ChatBotProps> = ({
|
|
|
897
921
|
};
|
|
898
922
|
|
|
899
923
|
fetchModels();
|
|
900
|
-
}, [
|
|
924
|
+
}, [authFields, nxtlinqApi]);
|
|
901
925
|
|
|
902
926
|
// Validate selectedModelIndex against effectiveAvailableModels
|
|
903
927
|
React.useEffect(() => {
|
|
@@ -1531,8 +1555,7 @@ export const ChatBotProvider: React.FC<ChatBotProps> = ({
|
|
|
1531
1555
|
}
|
|
1532
1556
|
|
|
1533
1557
|
const checkToolPermissionResult = await nxtlinqApi.agent.checkToolPermission({
|
|
1534
|
-
|
|
1535
|
-
apiSecret,
|
|
1558
|
+
...authFields(),
|
|
1536
1559
|
aitToken: currentToken!,
|
|
1537
1560
|
controller: currentHitAddress!,
|
|
1538
1561
|
toolName: requiredPermission
|
|
@@ -1627,8 +1650,7 @@ export const ChatBotProvider: React.FC<ChatBotProps> = ({
|
|
|
1627
1650
|
|
|
1628
1651
|
const updateSuggestions = React.useCallback(async (pseudoId: string, externalId?: string) => {
|
|
1629
1652
|
const result = await nxtlinqApi.agent.generateSuggestions({
|
|
1630
|
-
|
|
1631
|
-
apiSecret,
|
|
1653
|
+
...authFields(),
|
|
1632
1654
|
pseudoId,
|
|
1633
1655
|
externalId
|
|
1634
1656
|
});
|
|
@@ -1731,8 +1753,7 @@ export const ChatBotProvider: React.FC<ChatBotProps> = ({
|
|
|
1731
1753
|
|
|
1732
1754
|
const response: AgentResponse = await nxtlinqApi.agent.sendMessage({
|
|
1733
1755
|
model: currentModel.value,
|
|
1734
|
-
|
|
1735
|
-
apiSecret,
|
|
1756
|
+
...authFields(),
|
|
1736
1757
|
pseudoId: pseudoId,
|
|
1737
1758
|
externalId: localStorage.getItem('walletAddress') || undefined,
|
|
1738
1759
|
customUserInfo,
|
|
@@ -2135,11 +2156,10 @@ export const ChatBotProvider: React.FC<ChatBotProps> = ({
|
|
|
2135
2156
|
));
|
|
2136
2157
|
|
|
2137
2158
|
// Update message content in database if assistantMessageId is available
|
|
2138
|
-
if (response.assistantMessageId
|
|
2159
|
+
if (response.assistantMessageId) {
|
|
2139
2160
|
try {
|
|
2140
2161
|
await nxtlinqApi.agent.updateMessageContent({
|
|
2141
|
-
|
|
2142
|
-
apiSecret,
|
|
2162
|
+
...authFields(),
|
|
2143
2163
|
messageId: response.assistantMessageId,
|
|
2144
2164
|
content: finalContent,
|
|
2145
2165
|
});
|
|
@@ -2176,11 +2196,10 @@ export const ChatBotProvider: React.FC<ChatBotProps> = ({
|
|
|
2176
2196
|
}
|
|
2177
2197
|
|
|
2178
2198
|
// Update message content in database if assistantMessageId is available
|
|
2179
|
-
if (response.assistantMessageId
|
|
2199
|
+
if (response.assistantMessageId) {
|
|
2180
2200
|
try {
|
|
2181
2201
|
await nxtlinqApi.agent.updateMessageContent({
|
|
2182
|
-
|
|
2183
|
-
apiSecret,
|
|
2202
|
+
...authFields(),
|
|
2184
2203
|
messageId: response.assistantMessageId,
|
|
2185
2204
|
content: mergedContent,
|
|
2186
2205
|
});
|
|
@@ -2515,8 +2534,10 @@ export const ChatBotProvider: React.FC<ChatBotProps> = ({
|
|
|
2515
2534
|
interruptVoice,
|
|
2516
2535
|
micRms,
|
|
2517
2536
|
} = useVoiceMode({
|
|
2518
|
-
apiKey,
|
|
2519
|
-
apiSecret,
|
|
2537
|
+
apiKey: apiKey ?? '',
|
|
2538
|
+
apiSecret: apiSecret ?? '',
|
|
2539
|
+
serviceToken,
|
|
2540
|
+
getAuthToken,
|
|
2520
2541
|
pseudoId,
|
|
2521
2542
|
externalId: hitAddress || undefined,
|
|
2522
2543
|
aitId: ait?.aitId,
|
|
@@ -2626,14 +2647,13 @@ export const ChatBotProvider: React.FC<ChatBotProps> = ({
|
|
|
2626
2647
|
|
|
2627
2648
|
const uploadAttachment = React.useCallback(async (file: File): Promise<{ url: string } | { error: string }> => {
|
|
2628
2649
|
const result = await nxtlinqApi.agent.uploadAttachment({
|
|
2629
|
-
|
|
2630
|
-
apiSecret,
|
|
2650
|
+
...authFields(),
|
|
2631
2651
|
pseudoId,
|
|
2632
2652
|
file,
|
|
2633
2653
|
});
|
|
2634
2654
|
if ('error' in result) return result;
|
|
2635
2655
|
return { url: result.url };
|
|
2636
|
-
}, [nxtlinqApi,
|
|
2656
|
+
}, [nxtlinqApi, authFields, pseudoId]);
|
|
2637
2657
|
|
|
2638
2658
|
// Handle preset message
|
|
2639
2659
|
const handlePresetMessage = (message: PresetMessage) => {
|
|
@@ -3170,29 +3190,26 @@ export const ChatBotProvider: React.FC<ChatBotProps> = ({
|
|
|
3170
3190
|
const updateExternalId = async () => {
|
|
3171
3191
|
const externalId = hitAddress;
|
|
3172
3192
|
await nxtlinqApi.agent.updateMessagesExternalIdByPseudoId({
|
|
3173
|
-
|
|
3174
|
-
apiSecret,
|
|
3193
|
+
...authFields(),
|
|
3175
3194
|
pseudoId,
|
|
3176
3195
|
externalId: externalId,
|
|
3177
3196
|
})
|
|
3178
3197
|
|
|
3179
3198
|
await nxtlinqApi.agent.cloneUserProfileByPseudoId({
|
|
3180
|
-
|
|
3181
|
-
apiSecret,
|
|
3199
|
+
...authFields(),
|
|
3182
3200
|
pseudoId,
|
|
3183
3201
|
externalId: externalId,
|
|
3184
3202
|
});
|
|
3185
3203
|
|
|
3186
3204
|
await nxtlinqApi.agent.cloneUserTopicByPseudoId({
|
|
3187
|
-
|
|
3188
|
-
apiSecret,
|
|
3205
|
+
...authFields(),
|
|
3189
3206
|
pseudoId,
|
|
3190
3207
|
externalId: externalId,
|
|
3191
3208
|
})
|
|
3192
3209
|
}
|
|
3193
3210
|
|
|
3194
3211
|
updateExternalId()
|
|
3195
|
-
}, [hitAddress, nxtlinqApi,
|
|
3212
|
+
}, [hitAddress, nxtlinqApi, authFields, pseudoId]);
|
|
3196
3213
|
|
|
3197
3214
|
const contextValue: ChatBotContextType = {
|
|
3198
3215
|
// State
|
|
@@ -3304,6 +3321,8 @@ export const ChatBotProvider: React.FC<ChatBotProps> = ({
|
|
|
3304
3321
|
serviceId,
|
|
3305
3322
|
apiKey,
|
|
3306
3323
|
apiSecret,
|
|
3324
|
+
serviceToken,
|
|
3325
|
+
getAuthToken,
|
|
3307
3326
|
onVerifyWallet,
|
|
3308
3327
|
permissionGroup,
|
|
3309
3328
|
onModelChange,
|
|
@@ -3324,4 +3343,4 @@ export const ChatBotProvider: React.FC<ChatBotProps> = ({
|
|
|
3324
3343
|
{children}
|
|
3325
3344
|
</ChatBotContext.Provider>
|
|
3326
3345
|
);
|
|
3327
|
-
};
|
|
3346
|
+
};
|
|
@@ -53,8 +53,10 @@ export interface ChatBotProps {
|
|
|
53
53
|
maxRetries?: number;
|
|
54
54
|
retryDelay?: number;
|
|
55
55
|
serviceId: string;
|
|
56
|
-
apiKey
|
|
57
|
-
apiSecret
|
|
56
|
+
apiKey?: string;
|
|
57
|
+
apiSecret?: string;
|
|
58
|
+
serviceToken?: string;
|
|
59
|
+
getAuthToken?: () => Promise<string>;
|
|
58
60
|
environment?: 'production' | 'staging'; // API environment (default: production)
|
|
59
61
|
onVerifyWallet?: () => Promise<{
|
|
60
62
|
token: string;
|