@bytexbyte/nxtlinq-ai-agent-sdk 1.6.14 → 1.6.16
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 +1 -0
- package/dist/api/nxtlinq-api.d.ts.map +1 -1
- package/dist/api/nxtlinq-api.js +32 -2
- package/dist/components/context/ChatBotContext.d.ts.map +1 -1
- package/dist/components/context/ChatBotContext.js +56 -37
- package/dist/components/types/ChatBotTypes.d.ts +1 -7
- package/dist/components/types/ChatBotTypes.d.ts.map +1 -1
- package/dist/components/types/ChatBotTypes.js +1 -41
- package/dist/components/ui/MessageList.d.ts.map +1 -1
- package/dist/components/ui/MessageList.js +6 -3
- package/dist/components/ui/ModelSelector.d.ts.map +1 -1
- package/dist/components/ui/ModelSelector.js +16 -2
- package/dist/core/utils/urlUtils.d.ts +2 -0
- package/dist/core/utils/urlUtils.d.ts.map +1 -1
- package/dist/core/utils/urlUtils.js +78 -16
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/types/ait-api.d.ts +14 -0
- package/dist/types/ait-api.d.ts.map +1 -1
- package/dist/umd-entry.d.ts.map +1 -1
- package/dist/umd-entry.js +1 -23
- package/package.json +1 -1
- package/umd/nxtlinq-ai-agent.umd.js +131 -131
|
@@ -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;AAM1C,eAAO,MAAM,WAAW,GAAI,aAAa,YAAY,GAAG,SAAS,SAQhE,CAAC;AA2YF,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,EAAE,WAAW,MAAM,KAAG,MAUpE,CAAC"}
|
package/dist/api/nxtlinq-api.js
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// Will be set by setApiHosts based on environment
|
|
2
|
+
let AI_AGENT_API_HOST = '';
|
|
3
|
+
let AIT_SERVICE_API_HOST = '';
|
|
4
|
+
export const setApiHosts = (environment) => {
|
|
5
|
+
if (environment === 'production') {
|
|
6
|
+
AI_AGENT_API_HOST = 'https://ai-agent.nxtlinq.ai';
|
|
7
|
+
AIT_SERVICE_API_HOST = 'https://ait-service.nxtlinq.ai';
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
AI_AGENT_API_HOST = 'https://ai-agent-staging.nxtlinq.ai';
|
|
11
|
+
AIT_SERVICE_API_HOST = 'https://staging-ait-service.nxtlinq.ai';
|
|
12
|
+
}
|
|
13
|
+
};
|
|
3
14
|
// Helper function to get auth header
|
|
4
15
|
const getAuthHeader = () => {
|
|
5
16
|
const token = localStorage.getItem('nxtlinqAITServiceAccessToken');
|
|
@@ -234,6 +245,25 @@ const createAgentApi = () => ({
|
|
|
234
245
|
console.error('Failed to clone user topic:', error);
|
|
235
246
|
return { error: error instanceof Error ? error.message : 'Failed to clone user topic' };
|
|
236
247
|
}
|
|
248
|
+
},
|
|
249
|
+
getServiceModels: async (params) => {
|
|
250
|
+
try {
|
|
251
|
+
const response = await fetch(`${AI_AGENT_API_HOST}/api/service-models`, {
|
|
252
|
+
method: 'GET',
|
|
253
|
+
headers: {
|
|
254
|
+
'x-api-key': params.apiKey,
|
|
255
|
+
'x-api-secret': params.apiSecret,
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
if (!response.ok) {
|
|
259
|
+
throw new Error('Failed to fetch service models');
|
|
260
|
+
}
|
|
261
|
+
return await response.json();
|
|
262
|
+
}
|
|
263
|
+
catch (error) {
|
|
264
|
+
console.error('Failed to fetch service models:', error);
|
|
265
|
+
return { error: error instanceof Error ? error.message : 'Failed to fetch service models' };
|
|
266
|
+
}
|
|
237
267
|
}
|
|
238
268
|
});
|
|
239
269
|
// Permissions API module
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBotContext.d.ts","sourceRoot":"","sources":["../../../src/components/context/ChatBotContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAS/B,OAAO,
|
|
1
|
+
{"version":3,"file":"ChatBotContext.d.ts","sourceRoot":"","sources":["../../../src/components/context/ChatBotContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAS/B,OAAO,EAEL,kBAAkB,EAClB,YAAY,EAEb,MAAM,uBAAuB,CAAC;AAI/B,eAAO,MAAM,UAAU,0BAMtB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAohElD,CAAC"}
|
|
@@ -3,13 +3,12 @@ import { ethers } from 'ethers';
|
|
|
3
3
|
import stringify from 'fast-json-stable-stringify';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { v4 as uuidv4 } from 'uuid';
|
|
6
|
-
import { createNxtlinqApi } from '../../api/nxtlinq-api';
|
|
6
|
+
import { createNxtlinqApi, setApiHosts } from '../../api/nxtlinq-api';
|
|
7
7
|
import useLocalStorage from '../../core/lib/useLocalStorage';
|
|
8
8
|
import useSessionStorage from '../../core/lib/useSessionStorage';
|
|
9
9
|
import { useSpeechToTextFromMic } from '../../core/lib/useSpeechToTextFromMic';
|
|
10
10
|
import metakeepClient from '../../core/metakeepClient';
|
|
11
11
|
import { sleep } from '../../core/utils';
|
|
12
|
-
import { DEFAULT_AI_MODELS } from '../types/ChatBotTypes';
|
|
13
12
|
const ChatBotContext = React.createContext(undefined);
|
|
14
13
|
export const useChatBot = () => {
|
|
15
14
|
const context = React.useContext(ChatBotContext);
|
|
@@ -18,9 +17,9 @@ export const useChatBot = () => {
|
|
|
18
17
|
}
|
|
19
18
|
return context;
|
|
20
19
|
};
|
|
21
|
-
export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages = [], placeholder = 'Type a message...', className = '', maxRetries = 3, retryDelay = 2000, serviceId, apiKey, apiSecret, onVerifyWallet, permissionGroup, children,
|
|
20
|
+
export const ChatBotProvider = ({ onMessage, onError, onToolUse, presetMessages = [], placeholder = 'Type a message...', className = '', maxRetries = 3, retryDelay = 2000, serviceId, apiKey, apiSecret, environment = 'production', onVerifyWallet, permissionGroup, children,
|
|
22
21
|
// AI Model related attributes
|
|
23
|
-
|
|
22
|
+
onModelChange,
|
|
24
23
|
// Storage mode configuration
|
|
25
24
|
useSessionStorage: useSessionStorageMode = false,
|
|
26
25
|
// Wallet verification configuration
|
|
@@ -33,6 +32,8 @@ customUsername,
|
|
|
33
32
|
idvBannerDismissSeconds = 86400,
|
|
34
33
|
// 24 hours in seconds
|
|
35
34
|
isStopRecordingOnSend = false, }) => {
|
|
35
|
+
// Set API hosts immediately based on environment (before any API calls)
|
|
36
|
+
setApiHosts(environment);
|
|
36
37
|
const nxtlinqApi = React.useMemo(() => createNxtlinqApi(apiKey, apiSecret), [apiKey, apiSecret]);
|
|
37
38
|
// Custom hook
|
|
38
39
|
const { isRecording, transcript, partialTranscript, start: startRecording, stop: stopRecording, clear: clearRecording } = useSpeechToTextFromMic({
|
|
@@ -178,26 +179,48 @@ isStopRecordingOnSend = false, }) => {
|
|
|
178
179
|
duration: 5000
|
|
179
180
|
});
|
|
180
181
|
// AI Model related state
|
|
181
|
-
const [
|
|
182
|
-
const [
|
|
183
|
-
//
|
|
182
|
+
const [modelsFromApi, setModelsFromApi] = React.useState([]);
|
|
183
|
+
const [selectedModelIndex, setSelectedModelIndex] = useLocalStorage('selectedAIModelIndex', 0);
|
|
184
|
+
// Use models from API only (no default fallback)
|
|
185
|
+
// This ensures SDK always uses Dashboard-configured models
|
|
186
|
+
const effectiveAvailableModels = React.useMemo(() => {
|
|
187
|
+
return modelsFromApi;
|
|
188
|
+
}, [modelsFromApi]);
|
|
189
|
+
// Auto determine if selector should be shown based on number of models
|
|
190
|
+
// Show selector only when there are 2 or more models
|
|
191
|
+
const showModelSelector = React.useMemo(() => {
|
|
192
|
+
return effectiveAvailableModels.length >= 2;
|
|
193
|
+
}, [effectiveAvailableModels]);
|
|
194
|
+
// Fetch available models from API on mount
|
|
195
|
+
React.useEffect(() => {
|
|
196
|
+
const fetchModels = async () => {
|
|
197
|
+
try {
|
|
198
|
+
const result = await nxtlinqApi.agent.getServiceModels({ apiKey, apiSecret });
|
|
199
|
+
if ('availableModels' in result && Array.isArray(result.availableModels)) {
|
|
200
|
+
setModelsFromApi(result.availableModels);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
console.error('Failed to fetch available models from API:', error);
|
|
205
|
+
// Silently fail and use default models
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
fetchModels();
|
|
209
|
+
}, [apiKey, apiSecret, nxtlinqApi]);
|
|
210
|
+
// Validate selectedModelIndex against effectiveAvailableModels
|
|
184
211
|
React.useEffect(() => {
|
|
185
212
|
// Check if selectedModelIndex is out of bounds
|
|
186
|
-
if (selectedModelIndex >=
|
|
187
|
-
setSelectedModelIndex(
|
|
213
|
+
if (selectedModelIndex >= effectiveAvailableModels.length) {
|
|
214
|
+
setSelectedModelIndex(0);
|
|
188
215
|
return;
|
|
189
216
|
}
|
|
190
|
-
// Check if the selected model still exists in
|
|
191
|
-
const selectedModel =
|
|
217
|
+
// Check if the selected model still exists in effectiveAvailableModels
|
|
218
|
+
const selectedModel = effectiveAvailableModels[selectedModelIndex];
|
|
192
219
|
if (!selectedModel) {
|
|
193
|
-
setSelectedModelIndex(defaultModelIndex);
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
// If defaultModelIndex is also out of bounds or invalid, use 0
|
|
197
|
-
if (defaultModelIndex >= availableModels.length || !availableModels[defaultModelIndex]) {
|
|
198
220
|
setSelectedModelIndex(0);
|
|
221
|
+
return;
|
|
199
222
|
}
|
|
200
|
-
}, [
|
|
223
|
+
}, [effectiveAvailableModels, selectedModelIndex, setSelectedModelIndex]);
|
|
201
224
|
// Notification functions
|
|
202
225
|
const showNotification = (type, message, duration = 5000) => {
|
|
203
226
|
setNotification({
|
|
@@ -888,25 +911,21 @@ isStopRecordingOnSend = false, }) => {
|
|
|
888
911
|
// AI Model related functions
|
|
889
912
|
const handleModelChange = React.useCallback((modelIndex) => {
|
|
890
913
|
setSelectedModelIndex(modelIndex);
|
|
891
|
-
const selectedModel =
|
|
914
|
+
const selectedModel = effectiveAvailableModels[modelIndex];
|
|
892
915
|
onModelChange?.(selectedModel);
|
|
893
|
-
}, [
|
|
916
|
+
}, [effectiveAvailableModels, onModelChange, setSelectedModelIndex]);
|
|
894
917
|
const getCurrentModel = React.useCallback(() => {
|
|
895
918
|
// Safety check: ensure selectedModelIndex is within bounds
|
|
896
919
|
let safeIndex = selectedModelIndex;
|
|
897
|
-
if (selectedModelIndex >=
|
|
898
|
-
safeIndex = defaultModelIndex;
|
|
899
|
-
}
|
|
900
|
-
// If defaultModelIndex is also out of bounds, use 0
|
|
901
|
-
if (safeIndex >= availableModels.length) {
|
|
920
|
+
if (selectedModelIndex >= effectiveAvailableModels.length) {
|
|
902
921
|
safeIndex = 0;
|
|
903
922
|
}
|
|
904
923
|
// If no models available, return a default model
|
|
905
|
-
if (
|
|
924
|
+
if (effectiveAvailableModels.length === 0) {
|
|
906
925
|
return { label: 'Unknown', value: 'unknown' };
|
|
907
926
|
}
|
|
908
|
-
return
|
|
909
|
-
}, [
|
|
927
|
+
return effectiveAvailableModels[safeIndex];
|
|
928
|
+
}, [effectiveAvailableModels, selectedModelIndex]);
|
|
910
929
|
const updateSuggestions = React.useCallback(async (pseudoId, externalId) => {
|
|
911
930
|
const result = await nxtlinqApi.agent.generateSuggestions({
|
|
912
931
|
apiKey,
|
|
@@ -929,6 +948,8 @@ isStopRecordingOnSend = false, }) => {
|
|
|
929
948
|
if (!content.trim() || isLoading)
|
|
930
949
|
return;
|
|
931
950
|
const currentModel = getCurrentModel();
|
|
951
|
+
// Initialize with current model, will be updated with actual model from backend response
|
|
952
|
+
let actualModelUsed = currentModel.value;
|
|
932
953
|
// Only add user message on first attempt, not on retries
|
|
933
954
|
// Also check if this is not a preset message (preset messages are added separately)
|
|
934
955
|
if (retryCount === 0 && !isPresetMessage) {
|
|
@@ -957,6 +978,8 @@ isStopRecordingOnSend = false, }) => {
|
|
|
957
978
|
customUserInfo,
|
|
958
979
|
message: content,
|
|
959
980
|
});
|
|
981
|
+
// Get the actual model used from response (may differ due to fallback)
|
|
982
|
+
actualModelUsed = response.model || currentModel.value;
|
|
960
983
|
if ('error' in response || response.result === 'error') {
|
|
961
984
|
// Check if it's an AIT-related error
|
|
962
985
|
const errorResponse = response;
|
|
@@ -1161,7 +1184,7 @@ isStopRecordingOnSend = false, }) => {
|
|
|
1161
1184
|
role: 'assistant',
|
|
1162
1185
|
timestamp: new Date().toISOString(),
|
|
1163
1186
|
metadata: {
|
|
1164
|
-
model:
|
|
1187
|
+
model: actualModelUsed,
|
|
1165
1188
|
permissions: permissions,
|
|
1166
1189
|
issuedBy: hitAddress || '',
|
|
1167
1190
|
toolUse: toolUse
|
|
@@ -1182,7 +1205,7 @@ isStopRecordingOnSend = false, }) => {
|
|
|
1182
1205
|
role: 'assistant',
|
|
1183
1206
|
timestamp: new Date().toISOString(),
|
|
1184
1207
|
metadata: {
|
|
1185
|
-
model:
|
|
1208
|
+
model: actualModelUsed,
|
|
1186
1209
|
permissions: permissions,
|
|
1187
1210
|
issuedBy: hitAddress || ''
|
|
1188
1211
|
}
|
|
@@ -1198,7 +1221,7 @@ isStopRecordingOnSend = false, }) => {
|
|
|
1198
1221
|
role: 'assistant',
|
|
1199
1222
|
timestamp: new Date().toISOString(),
|
|
1200
1223
|
metadata: {
|
|
1201
|
-
model:
|
|
1224
|
+
model: actualModelUsed,
|
|
1202
1225
|
permissions: permissions,
|
|
1203
1226
|
issuedBy: hitAddress || ''
|
|
1204
1227
|
}
|
|
@@ -1223,7 +1246,7 @@ isStopRecordingOnSend = false, }) => {
|
|
|
1223
1246
|
role: 'assistant',
|
|
1224
1247
|
timestamp: new Date().toISOString(),
|
|
1225
1248
|
metadata: {
|
|
1226
|
-
model:
|
|
1249
|
+
model: actualModelUsed,
|
|
1227
1250
|
permissions: permissions,
|
|
1228
1251
|
issuedBy: hitAddress || '',
|
|
1229
1252
|
isRetry: true
|
|
@@ -1797,9 +1820,9 @@ isStopRecordingOnSend = false, }) => {
|
|
|
1797
1820
|
transcript,
|
|
1798
1821
|
textInputRef,
|
|
1799
1822
|
// AI Model related state
|
|
1800
|
-
availableModels,
|
|
1823
|
+
availableModels: effectiveAvailableModels,
|
|
1801
1824
|
selectedModelIndex,
|
|
1802
|
-
showModelSelector
|
|
1825
|
+
showModelSelector,
|
|
1803
1826
|
suggestions,
|
|
1804
1827
|
isAITEnabling,
|
|
1805
1828
|
// Actions
|
|
@@ -1813,7 +1836,6 @@ isStopRecordingOnSend = false, }) => {
|
|
|
1813
1836
|
setNotification,
|
|
1814
1837
|
// AI Model related actions
|
|
1815
1838
|
setSelectedModelIndex,
|
|
1816
|
-
setShowModelSelector: setShowModelSelectorState,
|
|
1817
1839
|
setSuggestions,
|
|
1818
1840
|
// Functions
|
|
1819
1841
|
connectWallet,
|
|
@@ -1858,9 +1880,6 @@ isStopRecordingOnSend = false, }) => {
|
|
|
1858
1880
|
apiSecret,
|
|
1859
1881
|
onVerifyWallet,
|
|
1860
1882
|
permissionGroup,
|
|
1861
|
-
availableModels,
|
|
1862
|
-
defaultModelIndex,
|
|
1863
|
-
showModelSelector,
|
|
1864
1883
|
onModelChange,
|
|
1865
1884
|
useSessionStorage: useSessionStorageMode,
|
|
1866
1885
|
requireWalletIDVVerification,
|
|
@@ -29,9 +29,6 @@ export interface AIModel {
|
|
|
29
29
|
label: string;
|
|
30
30
|
value: string;
|
|
31
31
|
}
|
|
32
|
-
export declare const DEFAULT_AI_MODELS: AIModel[];
|
|
33
|
-
export declare const ALL_AVAILABLE_MODELS: AIModel[];
|
|
34
|
-
export declare const AI_MODEL_MAP: Record<string, string>;
|
|
35
32
|
export interface ChatBotProps {
|
|
36
33
|
onMessage?: (message: Message) => void;
|
|
37
34
|
onError?: (error: Error) => void;
|
|
@@ -44,14 +41,12 @@ export interface ChatBotProps {
|
|
|
44
41
|
serviceId: string;
|
|
45
42
|
apiKey: string;
|
|
46
43
|
apiSecret: string;
|
|
44
|
+
environment?: 'production' | 'staging';
|
|
47
45
|
onVerifyWallet?: () => Promise<{
|
|
48
46
|
token: string;
|
|
49
47
|
} | undefined>;
|
|
50
48
|
permissionGroup?: string;
|
|
51
49
|
children?: React.ReactNode;
|
|
52
|
-
availableModels?: AIModel[];
|
|
53
|
-
defaultModelIndex?: number;
|
|
54
|
-
showModelSelector?: boolean;
|
|
55
50
|
onModelChange?: (model: AIModel) => void;
|
|
56
51
|
useSessionStorage?: boolean;
|
|
57
52
|
requireWalletIDVVerification?: boolean;
|
|
@@ -102,7 +97,6 @@ export interface ChatBotContextType {
|
|
|
102
97
|
setIsWalletLoading: (loading: boolean) => void;
|
|
103
98
|
setNotification: (notification: any) => void;
|
|
104
99
|
setSelectedModelIndex: (index: number) => void;
|
|
105
|
-
setShowModelSelector: (show: boolean) => void;
|
|
106
100
|
setSuggestions: (suggestions: PresetMessage[]) => void;
|
|
107
101
|
connectWallet: (autoShowSignInMessage?: boolean) => Promise<string | false | undefined>;
|
|
108
102
|
signInWallet: (autoShowSuccessMessage?: boolean) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
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;AAE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,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IAGzB,KAAK,EAAE,YAAY,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -1,41 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
{ label: 'Claude', value: 'claude' },
|
|
3
|
-
{ label: 'ChatGPT', value: 'open-ai' },
|
|
4
|
-
{ label: 'Llama', value: 'llama' },
|
|
5
|
-
{ label: 'Gemini', value: 'gemini' },
|
|
6
|
-
];
|
|
7
|
-
// All available models for reference
|
|
8
|
-
export const ALL_AVAILABLE_MODELS = [
|
|
9
|
-
{ label: 'Claude', value: 'claude' },
|
|
10
|
-
{ label: 'ChatGPT', value: 'open-ai' },
|
|
11
|
-
{ label: 'Llama', value: 'llama' },
|
|
12
|
-
{ label: 'Gemini', value: 'gemini' },
|
|
13
|
-
{ label: 'Nova', value: 'nova' },
|
|
14
|
-
{ label: "Claude-v2", value: "v2/claude" },
|
|
15
|
-
{ label: "ChatGPT-v2", value: "v2/open-ai" },
|
|
16
|
-
{ label: "Llama-v2", value: "v2/llama" },
|
|
17
|
-
{ label: "Gemini-v2", value: "v2/gemini" },
|
|
18
|
-
{ label: "Nova-v2", value: "v2/nova" },
|
|
19
|
-
{ label: "Claude-v2.1", value: "v2.1/claude" },
|
|
20
|
-
{ label: "ChatGPT-v2.1", value: "v2.1/open-ai" },
|
|
21
|
-
{ label: "Llama-v2.1", value: "v2.1/llama" },
|
|
22
|
-
{ label: "Gemini-v2.1", value: "v2.1/gemini" },
|
|
23
|
-
{ label: "Nova-v2.1", value: "v2.1/nova" },
|
|
24
|
-
];
|
|
25
|
-
export const AI_MODEL_MAP = {
|
|
26
|
-
claude: 'Claude',
|
|
27
|
-
'open-ai': 'ChatGPT',
|
|
28
|
-
llama: 'Llama',
|
|
29
|
-
gemini: 'Gemini',
|
|
30
|
-
nova: 'Nova',
|
|
31
|
-
'v2/claude': 'Claude-v2',
|
|
32
|
-
'v2/open-ai': 'ChatGPT-v2',
|
|
33
|
-
'v2/llama': 'Llama-v2',
|
|
34
|
-
'v2/gemini': 'Gemini-v2',
|
|
35
|
-
'v2/nova': 'Nova-v2',
|
|
36
|
-
'v2.1/claude': 'Claude-v2.1',
|
|
37
|
-
'v2.1/open-ai': 'ChatGPT-v2.1',
|
|
38
|
-
'v2.1/llama': 'Llama-v2.1',
|
|
39
|
-
'v2.1/gemini': 'Gemini-v2.1',
|
|
40
|
-
'v2.1/nova': 'Nova-v2.1',
|
|
41
|
-
};
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageList.d.ts","sourceRoot":"","sources":["../../../src/components/ui/MessageList.tsx"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"MessageList.d.ts","sourceRoot":"","sources":["../../../src/components/ui/MessageList.tsx"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAoB/B,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAsI/B,CAAC"}
|
|
@@ -4,10 +4,9 @@ import * as React from 'react';
|
|
|
4
4
|
import { css } from '@emotion/react';
|
|
5
5
|
import { convertUrlsToLinks } from '../../core/utils/urlUtils';
|
|
6
6
|
import { useChatBot } from '../context/ChatBotContext';
|
|
7
|
-
import { AI_MODEL_MAP } from '../types/ChatBotTypes';
|
|
8
7
|
import { messageListContainer, messageBubble, userMessage, messageContent, userMessageContent, retryMessageContent, chatbotButton, connectedButton, loadingIndicator, modelIndicator, modelBadge, modelDot } from './styles/isolatedStyles';
|
|
9
8
|
export const MessageList = () => {
|
|
10
|
-
const { messages, isLoading, connectWallet, signInWallet, hitAddress, isAutoConnecting, isNeedSignInWithWallet, enableAIT, isAITLoading, isAITEnabling, sendMessage, permissions } = useChatBot();
|
|
9
|
+
const { messages, isLoading, connectWallet, signInWallet, hitAddress, isAutoConnecting, isNeedSignInWithWallet, enableAIT, isAITLoading, isAITEnabling, sendMessage, permissions, availableModels } = useChatBot();
|
|
11
10
|
const messagesEndRef = React.useRef(null);
|
|
12
11
|
const scrollToBottom = () => {
|
|
13
12
|
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
|
|
@@ -44,10 +43,14 @@ export const MessageList = () => {
|
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
45
|
};
|
|
46
|
+
// Get model display name from API-provided model list
|
|
47
47
|
const getModelDisplayName = (modelValue) => {
|
|
48
48
|
if (!modelValue)
|
|
49
49
|
return '';
|
|
50
|
-
|
|
50
|
+
// Find model in the list returned by API
|
|
51
|
+
const model = availableModels.find(m => m.value === modelValue);
|
|
52
|
+
// Use label from API or fallback to value
|
|
53
|
+
return model?.label || modelValue;
|
|
51
54
|
};
|
|
52
55
|
return (_jsxs("div", { css: messageListContainer, children: [messages.map((message) => (_jsxs("div", { css: message.role === 'user' ? userMessage : messageBubble, children: [_jsxs("div", { css: message.role === 'user'
|
|
53
56
|
? userMessageContent
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelSelector.d.ts","sourceRoot":"","sources":["../../../src/components/ui/ModelSelector.tsx"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ModelSelector.d.ts","sourceRoot":"","sources":["../../../src/components/ui/ModelSelector.tsx"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAwIjC,CAAC"}
|
|
@@ -4,7 +4,7 @@ import * as React from 'react';
|
|
|
4
4
|
import { css } from '@emotion/react';
|
|
5
5
|
import { useChatBot } from '../context/ChatBotContext';
|
|
6
6
|
export const ModelSelector = () => {
|
|
7
|
-
const { availableModels, selectedModelIndex,
|
|
7
|
+
const { availableModels, selectedModelIndex, handleModelChange } = useChatBot();
|
|
8
8
|
// Safety check: ensure selectedModelIndex is within bounds
|
|
9
9
|
const safeSelectedModelIndex = selectedModelIndex >= availableModels.length ? 0 : selectedModelIndex;
|
|
10
10
|
// Get fallback model label (first available model or 'Unknown')
|
|
@@ -21,9 +21,23 @@ export const ModelSelector = () => {
|
|
|
21
21
|
const handleClose = () => {
|
|
22
22
|
setAnchorEl(null);
|
|
23
23
|
};
|
|
24
|
-
if
|
|
24
|
+
// Don't show anything if no models available
|
|
25
|
+
if (availableModels.length === 0) {
|
|
25
26
|
return null;
|
|
26
27
|
}
|
|
28
|
+
// If only 1 model, show name only (no selector dropdown)
|
|
29
|
+
if (availableModels.length === 1) {
|
|
30
|
+
return (_jsx("div", { css: css `
|
|
31
|
+
display: flex !important;
|
|
32
|
+
align-items: center !important;
|
|
33
|
+
padding: 4px 8px !important;
|
|
34
|
+
border-radius: 4px !important;
|
|
35
|
+
background-color: rgba(255, 255, 255, 0.1) !important;
|
|
36
|
+
font-size: 12px !important;
|
|
37
|
+
font-weight: 500 !important;
|
|
38
|
+
`, children: _jsx("span", { children: availableModels[0].label }) }));
|
|
39
|
+
}
|
|
40
|
+
// If 2+ models, show full selector with dropdown
|
|
27
41
|
return (_jsxs("div", { css: css `
|
|
28
42
|
display: flex !important;
|
|
29
43
|
align-items: center !important;
|
|
@@ -10,6 +10,8 @@ import * as React from 'react';
|
|
|
10
10
|
export declare const containsUrls: (text: string) => boolean;
|
|
11
11
|
/**
|
|
12
12
|
* Convert text with URLs to JSX elements with clickable links
|
|
13
|
+
* Supports both Markdown format [text](url) and plain URLs
|
|
14
|
+
* Also handles line breaks (\n)
|
|
13
15
|
* @param text - The text containing URLs
|
|
14
16
|
* @returns Array of JSX elements and strings
|
|
15
17
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urlUtils.d.ts","sourceRoot":"","sources":["../../../src/core/utils/urlUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"urlUtils.d.ts","sourceRoot":"","sources":["../../../src/core/utils/urlUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAc/B;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,KAAG,OAE3C,CAAC;AAwBF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,KAAG,CAAC,MAAM,GAAG,KAAK,CAAC,YAAY,CAAC,EA2F9E,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,KAAG,MAKhD,CAAC"}
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
* URL utility functions for detecting and converting URLs to clickable links
|
|
3
3
|
*/
|
|
4
4
|
import * as React from 'react';
|
|
5
|
+
/**
|
|
6
|
+
* Regular expression to match Markdown-style links
|
|
7
|
+
* Matches [text](url) format
|
|
8
|
+
*/
|
|
9
|
+
const MARKDOWN_LINK_REGEX = /\[([^\]]+)\]\(([^)]+)\)/g;
|
|
5
10
|
/**
|
|
6
11
|
* Regular expression to match URLs
|
|
7
12
|
* Supports http, https, ftp, and www protocols
|
|
@@ -15,28 +20,83 @@ const URL_REGEX = /(https?:\/\/[^\s]+|www\.[^\s]+|[a-zA-Z0-9-]+\.[a-zA-Z]{2,}(?:
|
|
|
15
20
|
export const containsUrls = (text) => {
|
|
16
21
|
return URL_REGEX.test(text);
|
|
17
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* Convert text with line breaks to JSX elements with <br/> tags
|
|
25
|
+
* @param text - The text containing line breaks
|
|
26
|
+
* @param keyPrefix - Prefix for React keys
|
|
27
|
+
* @returns Array of JSX elements and strings
|
|
28
|
+
*/
|
|
29
|
+
const convertLineBreaks = (text, keyPrefix = '') => {
|
|
30
|
+
const parts = [];
|
|
31
|
+
const lines = text.split('\n');
|
|
32
|
+
lines.forEach((line, index) => {
|
|
33
|
+
if (index > 0) {
|
|
34
|
+
parts.push(React.createElement('br', { key: `${keyPrefix}-br-${index}` }));
|
|
35
|
+
}
|
|
36
|
+
if (line) {
|
|
37
|
+
parts.push(line);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
return parts;
|
|
41
|
+
};
|
|
18
42
|
/**
|
|
19
43
|
* Convert text with URLs to JSX elements with clickable links
|
|
44
|
+
* Supports both Markdown format [text](url) and plain URLs
|
|
45
|
+
* Also handles line breaks (\n)
|
|
20
46
|
* @param text - The text containing URLs
|
|
21
47
|
* @returns Array of JSX elements and strings
|
|
22
48
|
*/
|
|
23
49
|
export const convertUrlsToLinks = (text) => {
|
|
24
50
|
const parts = [];
|
|
25
51
|
let lastIndex = 0;
|
|
26
|
-
let
|
|
27
|
-
//
|
|
52
|
+
let keyCounter = 0;
|
|
53
|
+
// First, find all markdown links and plain URLs
|
|
54
|
+
const items = [];
|
|
55
|
+
// Find markdown links
|
|
56
|
+
let markdownMatch;
|
|
57
|
+
MARKDOWN_LINK_REGEX.lastIndex = 0;
|
|
58
|
+
while ((markdownMatch = MARKDOWN_LINK_REGEX.exec(text)) !== null) {
|
|
59
|
+
items.push({
|
|
60
|
+
type: 'markdown',
|
|
61
|
+
start: markdownMatch.index,
|
|
62
|
+
end: markdownMatch.index + markdownMatch[0].length,
|
|
63
|
+
text: markdownMatch[1],
|
|
64
|
+
url: markdownMatch[2]
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
// Find plain URLs (but exclude those already matched as markdown links)
|
|
68
|
+
let urlMatch;
|
|
28
69
|
URL_REGEX.lastIndex = 0;
|
|
29
|
-
while ((
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
|
|
70
|
+
while ((urlMatch = URL_REGEX.exec(text)) !== null) {
|
|
71
|
+
const start = urlMatch.index;
|
|
72
|
+
const end = start + urlMatch[0].length;
|
|
73
|
+
// Check if this URL is already part of a markdown link
|
|
74
|
+
const isPartOfMarkdown = items.some(item => item.type === 'markdown' && start >= item.start && end <= item.end);
|
|
75
|
+
if (!isPartOfMarkdown) {
|
|
76
|
+
items.push({
|
|
77
|
+
type: 'url',
|
|
78
|
+
start,
|
|
79
|
+
end,
|
|
80
|
+
url: urlMatch[0]
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// Sort items by start position
|
|
85
|
+
items.sort((a, b) => a.start - b.start);
|
|
86
|
+
// Build the result
|
|
87
|
+
items.forEach(item => {
|
|
88
|
+
// Add text before this item (with line breaks)
|
|
89
|
+
if (item.start > lastIndex) {
|
|
90
|
+
const textBefore = text.slice(lastIndex, item.start);
|
|
91
|
+
const textBeforeParts = convertLineBreaks(textBefore, `text-${keyCounter}`);
|
|
92
|
+
parts.push(...textBeforeParts);
|
|
93
|
+
keyCounter++;
|
|
35
94
|
}
|
|
36
95
|
// Create clickable link
|
|
37
|
-
const href = url.startsWith('http') ? url : `https://${url}`;
|
|
96
|
+
const href = item.url.startsWith('http') ? item.url : `https://${item.url}`;
|
|
97
|
+
const displayText = item.type === 'markdown' ? item.text : item.url;
|
|
38
98
|
parts.push(React.createElement('a', {
|
|
39
|
-
key:
|
|
99
|
+
key: `link-${keyCounter++}`,
|
|
40
100
|
href: href,
|
|
41
101
|
target: '_blank',
|
|
42
102
|
rel: 'noopener noreferrer',
|
|
@@ -51,14 +111,16 @@ export const convertUrlsToLinks = (text) => {
|
|
|
51
111
|
e.stopPropagation();
|
|
52
112
|
window.open(href, '_blank', 'noopener,noreferrer');
|
|
53
113
|
}
|
|
54
|
-
},
|
|
55
|
-
lastIndex =
|
|
56
|
-
}
|
|
57
|
-
// Add remaining text after the last
|
|
114
|
+
}, displayText));
|
|
115
|
+
lastIndex = item.end;
|
|
116
|
+
});
|
|
117
|
+
// Add remaining text after the last link (with line breaks)
|
|
58
118
|
if (lastIndex < text.length) {
|
|
59
|
-
|
|
119
|
+
const textAfter = text.slice(lastIndex);
|
|
120
|
+
const textAfterParts = convertLineBreaks(textAfter, `text-${keyCounter}`);
|
|
121
|
+
parts.push(...textAfterParts);
|
|
60
122
|
}
|
|
61
|
-
return parts.length > 0 ? parts :
|
|
123
|
+
return parts.length > 0 ? parts : convertLineBreaks(text, 'default');
|
|
62
124
|
};
|
|
63
125
|
/**
|
|
64
126
|
* Simple function to wrap URLs in anchor tags for basic HTML rendering
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ export { PermissionForm } from './components/ui/PermissionForm';
|
|
|
9
9
|
export { PresetMessages } from './components/ui/PresetMessages';
|
|
10
10
|
export { BerifyMeModal } from './components/ui/BerifyMeModal';
|
|
11
11
|
export type { AIModel, AITMetadata, ChatBotContextType, ChatBotProps, NovaError, NovaResponse, PresetMessage, ToolCall, ToolUse } from './components/types/ChatBotTypes';
|
|
12
|
-
export { AI_MODEL_MAP, ALL_AVAILABLE_MODELS, DEFAULT_AI_MODELS } from './components/types/ChatBotTypes';
|
|
13
12
|
export { connectWallet, disconnectWallet, validateToken } from './core/utils/walletUtils';
|
|
14
13
|
export { createAITMetadata, generateAITId, prepareAITCreation } from './core/utils/aitUtils';
|
|
15
14
|
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,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,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AAa,EACb,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGrD,YAAY,EACV,GAAG,EACH,MAAM,EACN,OAAO,EACP,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,8BAA8B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -11,8 +11,6 @@ export { NotificationModal } from './components/ui/NotificationModal';
|
|
|
11
11
|
export { PermissionForm } from './components/ui/PermissionForm';
|
|
12
12
|
export { PresetMessages } from './components/ui/PresetMessages';
|
|
13
13
|
export { BerifyMeModal } from './components/ui/BerifyMeModal';
|
|
14
|
-
// AI Model constants
|
|
15
|
-
export { AI_MODEL_MAP, ALL_AVAILABLE_MODELS, DEFAULT_AI_MODELS } from './components/types/ChatBotTypes';
|
|
16
14
|
// Utility functions
|
|
17
15
|
export { connectWallet, disconnectWallet, validateToken } from './core/utils/walletUtils';
|
|
18
16
|
export { createAITMetadata, generateAITId, prepareAITCreation } from './core/utils/aitUtils';
|
package/dist/types/ait-api.d.ts
CHANGED
|
@@ -227,6 +227,20 @@ export interface AITApi {
|
|
|
227
227
|
error: string;
|
|
228
228
|
requiredPermission: string;
|
|
229
229
|
}>;
|
|
230
|
+
getServiceModels: (params: {
|
|
231
|
+
apiKey: string;
|
|
232
|
+
apiSecret: string;
|
|
233
|
+
}) => Promise<{
|
|
234
|
+
serviceId: string;
|
|
235
|
+
serviceName: string;
|
|
236
|
+
availableModels: Array<{
|
|
237
|
+
id: string;
|
|
238
|
+
label: string;
|
|
239
|
+
value: string;
|
|
240
|
+
}>;
|
|
241
|
+
} | {
|
|
242
|
+
error: string;
|
|
243
|
+
}>;
|
|
230
244
|
};
|
|
231
245
|
permissions: {
|
|
232
246
|
getServicePermissions: (params: {
|