@burtson-labs/bandit-engine 2.0.37 → 2.0.39
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/{aiProviderStore-UJRDUYOF.mjs → aiProviderStore-XN7GCBHJ.mjs} +2 -2
- package/dist/{chat-SZK3EBDO.mjs → chat-5QJNWB7I.mjs} +5 -5
- package/dist/chat-provider.js +29 -3
- package/dist/chat-provider.js.map +1 -1
- package/dist/chat-provider.mjs +4 -4
- package/dist/{chunk-2ZZA2IFL.mjs → chunk-3A2527TE.mjs} +3 -3
- package/dist/{chunk-FJO5ZWYU.mjs → chunk-CDQYBO3Q.mjs} +26 -8
- package/dist/chunk-CDQYBO3Q.mjs.map +1 -0
- package/dist/{chunk-PLNFTIGX.mjs → chunk-ECRNIAG6.mjs} +4 -4
- package/dist/{chunk-S635Q6OQ.mjs → chunk-EOKIE5HZ.mjs} +24 -3
- package/dist/chunk-EOKIE5HZ.mjs.map +1 -0
- package/dist/{chunk-G4OXOTNJ.mjs → chunk-JRCDANLN.mjs} +154 -61
- package/dist/{chunk-G4OXOTNJ.mjs.map → chunk-JRCDANLN.mjs.map} +1 -1
- package/dist/{chunk-ZNNOTDRD.mjs → chunk-QU5S5QQP.mjs} +9 -4
- package/dist/chunk-QU5S5QQP.mjs.map +1 -0
- package/dist/{chunk-ED5NNDKO.mjs → chunk-QYH2T4L5.mjs} +3 -3
- package/dist/{chunk-ZAVV2AT5.mjs → chunk-WO5KFNNW.mjs} +4 -4
- package/dist/cli/cli.js +2 -3
- package/dist/cli/cli.js.map +1 -1
- package/dist/{gateway-Ckf_KusF.d.ts → gateway-B0LJ3-jT.d.mts} +3 -0
- package/dist/{gateway-Ckf_KusF.d.mts → gateway-B0LJ3-jT.d.ts} +3 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +196 -59
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -8
- package/dist/management/management.js +196 -59
- package/dist/management/management.js.map +1 -1
- package/dist/management/management.mjs +6 -6
- package/dist/modals/chat-modal/chat-modal.js +8 -3
- package/dist/modals/chat-modal/chat-modal.js.map +1 -1
- package/dist/modals/chat-modal/chat-modal.mjs +4 -4
- package/dist/public-types.d.mts +1 -1
- package/dist/public-types.d.ts +1 -1
- package/package.json +2 -3
- package/dist/chunk-FJO5ZWYU.mjs.map +0 -1
- package/dist/chunk-S635Q6OQ.mjs.map +0 -1
- package/dist/chunk-ZNNOTDRD.mjs.map +0 -1
- /package/dist/{aiProviderStore-UJRDUYOF.mjs.map → aiProviderStore-XN7GCBHJ.mjs.map} +0 -0
- /package/dist/{chat-SZK3EBDO.mjs.map → chat-5QJNWB7I.mjs.map} +0 -0
- /package/dist/{chunk-2ZZA2IFL.mjs.map → chunk-3A2527TE.mjs.map} +0 -0
- /package/dist/{chunk-PLNFTIGX.mjs.map → chunk-ECRNIAG6.mjs.map} +0 -0
- /package/dist/{chunk-ED5NNDKO.mjs.map → chunk-QYH2T4L5.mjs.map} +0 -0
- /package/dist/{chunk-ZAVV2AT5.mjs.map → chunk-WO5KFNNW.mjs.map} +0 -0
|
@@ -8,14 +8,14 @@ import {
|
|
|
8
8
|
useNotificationService,
|
|
9
9
|
useTTS,
|
|
10
10
|
useVoiceStore
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-QYH2T4L5.mjs";
|
|
12
12
|
import {
|
|
13
13
|
brandingService_default,
|
|
14
14
|
toTitleCase,
|
|
15
15
|
useAIQueryStore,
|
|
16
16
|
useConversationStore,
|
|
17
17
|
useMemoryStore
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-CDQYBO3Q.mjs";
|
|
19
19
|
import {
|
|
20
20
|
indexedDBService_default,
|
|
21
21
|
useModelStore,
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
} from "./chunk-XUBYA5I7.mjs";
|
|
25
25
|
import {
|
|
26
26
|
useAIProviderStore
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-QU5S5QQP.mjs";
|
|
28
28
|
import {
|
|
29
29
|
debugLogger
|
|
30
30
|
} from "./chunk-KCI46M23.mjs";
|
|
@@ -2807,4 +2807,4 @@ export {
|
|
|
2807
2807
|
MAX_WINDOWED_HEIGHT,
|
|
2808
2808
|
chat_modal_default
|
|
2809
2809
|
};
|
|
2810
|
-
//# sourceMappingURL=chunk-
|
|
2810
|
+
//# sourceMappingURL=chunk-ECRNIAG6.mjs.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
authenticationService
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-CDQYBO3Q.mjs";
|
|
4
4
|
import {
|
|
5
5
|
indexedDBService_default,
|
|
6
6
|
usePackageSettingsStore
|
|
7
7
|
} from "./chunk-XUBYA5I7.mjs";
|
|
8
8
|
import {
|
|
9
9
|
useAIProviderStore
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-QU5S5QQP.mjs";
|
|
11
11
|
import {
|
|
12
12
|
debugLogger
|
|
13
13
|
} from "./chunk-KCI46M23.mjs";
|
|
@@ -58,6 +58,9 @@ var AIProviderInitService = class _AIProviderInitService {
|
|
|
58
58
|
debugLogger.info("AI Provider Init: Found saved config in IndexedDB", { type: savedConfig.type });
|
|
59
59
|
const { id: _id, ...configWithoutId } = savedConfig;
|
|
60
60
|
providerConfig = { ...configWithoutId };
|
|
61
|
+
if (providerConfig.type === "anthropic" /* ANTHROPIC */) {
|
|
62
|
+
providerConfig = this.convertAnthropicConfig(providerConfig, settings?.gatewayApiUrl);
|
|
63
|
+
}
|
|
61
64
|
if ((providerConfig.type === "ollama" /* OLLAMA */ || providerConfig.type === "gateway" /* GATEWAY */) && !providerConfig.tokenFactory) {
|
|
62
65
|
providerConfig.tokenFactory = () => {
|
|
63
66
|
let token = authenticationService.getToken();
|
|
@@ -102,6 +105,9 @@ var AIProviderInitService = class _AIProviderInitService {
|
|
|
102
105
|
}
|
|
103
106
|
if (settings.aiProvider) {
|
|
104
107
|
providerConfig = { ...settings.aiProvider };
|
|
108
|
+
if (providerConfig.type === "anthropic" /* ANTHROPIC */) {
|
|
109
|
+
providerConfig = this.convertAnthropicConfig(providerConfig, settings.gatewayApiUrl);
|
|
110
|
+
}
|
|
105
111
|
if (providerConfig.type === "ollama" /* OLLAMA */ && !providerConfig.tokenFactory) {
|
|
106
112
|
providerConfig.tokenFactory = () => {
|
|
107
113
|
let token = authenticationService.getToken();
|
|
@@ -255,10 +261,25 @@ var AIProviderInitService = class _AIProviderInitService {
|
|
|
255
261
|
isProviderInitialized() {
|
|
256
262
|
return useAIProviderStore.getState().provider !== null;
|
|
257
263
|
}
|
|
264
|
+
convertAnthropicConfig(config, gatewayUrl) {
|
|
265
|
+
if (config.type !== "anthropic" /* ANTHROPIC */) {
|
|
266
|
+
return config;
|
|
267
|
+
}
|
|
268
|
+
const defaultModel = typeof config.defaultModel === "string" && config.defaultModel.trim() ? config.defaultModel.trim() : "claude-3-5-sonnet-latest";
|
|
269
|
+
const normalized = {
|
|
270
|
+
type: "gateway" /* GATEWAY */,
|
|
271
|
+
gatewayUrl: gatewayUrl || config.gatewayUrl || "",
|
|
272
|
+
provider: "anthropic",
|
|
273
|
+
defaultModel,
|
|
274
|
+
tokenFactory: config.tokenFactory
|
|
275
|
+
};
|
|
276
|
+
debugLogger.info("AI Provider Init: Converted direct Anthropic provider to gateway configuration");
|
|
277
|
+
return normalized;
|
|
278
|
+
}
|
|
258
279
|
};
|
|
259
280
|
var aiProviderInitService = AIProviderInitService.getInstance();
|
|
260
281
|
|
|
261
282
|
export {
|
|
262
283
|
aiProviderInitService
|
|
263
284
|
};
|
|
264
|
-
//# sourceMappingURL=chunk-
|
|
285
|
+
//# sourceMappingURL=chunk-EOKIE5HZ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/services/ai-provider-init.service.ts"],"sourcesContent":["/*\n © 2025 Burtson Labs — Licensed under Business Source License 1.1\n https://burtson.ai/license\n\n This file is protected intellectual property.\n Do NOT use in commercial software, prompts, AI training data, or derivative works without a valid commercial license.\n\n 🚫 AI NOTICE: This file contains visible and invisible watermarks.\n ⚖️ VIOLATION NOTICE: Removing, modifying, or obscuring these watermarks is a license violation.\n 🔒 LICENSE TERMINATION: Upon license termination, ALL forks, copies, and derivatives must be permanently deleted.\n 📋 AUDIT TRAIL: File usage is logged and monitored for compliance verification.\n*/\n\n// Bandit Engine Watermark: BL-WM-BFD5-C74863\nconst __banditFingerprint_services_aiproviderinitservicets = 'BL-FP-DDF978-53AF';\nconst __auditTrail_services_aiproviderinitservicets = 'BL-AU-MGOIKVVR-WP87';\n// File: ai-provider-init.service.ts | Path: src/services/ai-provider-init.service.ts | Hash: bfd553af\n\nimport { useAIProviderStore } from \"../store/aiProviderStore\";\nimport { usePackageSettingsStore } from \"../store/packageSettingsStore\";\nimport { AIProviderConfig, AIProviderType } from \"./ai-provider/types/common.types\";\nimport { authenticationService } from \"./auth/authenticationService\";\nimport { debugLogger } from \"./logging/debugLogger\";\nimport indexedDBService from \"./indexedDB/indexedDBService\";\n\ntype StoredAIProviderConfig = AIProviderConfig & { id?: string };\n\n/**\n * Service to initialize AI providers based on package settings\n */\nexport class AIProviderInitService {\n private static instance: AIProviderInitService;\n\n private constructor() {}\n\n static getInstance(): AIProviderInitService {\n if (!AIProviderInitService.instance) {\n AIProviderInitService.instance = new AIProviderInitService();\n }\n return AIProviderInitService.instance;\n }\n\n /**\n * Initialize AI provider from package settings\n * Provides backward compatibility with existing Ollama settings\n */\n async initializeFromSettings(): Promise<void> {\n const settings = usePackageSettingsStore.getState().settings;\n if (!settings) {\n debugLogger.warn(\"No package settings found, cannot initialize AI provider\");\n return;\n }\n\n let providerConfig: AIProviderConfig;\n\n debugLogger.info(\"AI Provider Init: Starting initialization\", { \n hasSettings: !!settings,\n hasAiProvider: !!settings.aiProvider,\n ollamaUrl: settings.ollamaUrl\n });\n\n const isPlaygroundEnvironment =\n settings.playgroundMode === true ||\n settings.aiProvider?.type === AIProviderType.PLAYGROUND ||\n (settings.gatewayApiUrl?.toLowerCase()?.startsWith(\"playground://\") ?? false) ||\n (typeof window !== \"undefined\" && window.location.pathname.includes(\"/playground\"));\n\n // First, try to load provider configuration from IndexedDB\n if (isPlaygroundEnvironment) {\n debugLogger.info(\"AI Provider Init: Playground environment detected, bypassing saved provider config\");\n } else {\n try {\n const savedConfig = await indexedDBService.get<StoredAIProviderConfig>(\n 'banditConfig', \n 1, \n 'config', \n 'aiProvider',\n [{ name: 'config', keyPath: 'id' }]\n );\n \n if (savedConfig) {\n debugLogger.info('AI Provider Init: Found saved config in IndexedDB', { type: savedConfig.type });\n \n // Filter out the 'id' property that was added for IndexedDB storage\n const { id: _id, ...configWithoutId } = savedConfig;\n providerConfig = { ...configWithoutId };\n if (providerConfig.type === AIProviderType.ANTHROPIC) {\n providerConfig = this.convertAnthropicConfig(providerConfig, settings?.gatewayApiUrl);\n }\n\n // Ensure tokenFactory is present for providers that need it\n if ((providerConfig.type === AIProviderType.OLLAMA || providerConfig.type === AIProviderType.GATEWAY) && !providerConfig.tokenFactory) {\n providerConfig.tokenFactory = () => {\n // Try multiple sources for the token\n let token = authenticationService.getToken();\n \n // If the bandit-engine's service doesn't have a token, try direct localStorage access\n if (!token) {\n token = localStorage.getItem(\"authToken\");\n }\n \n // Also try the authentication store if available\n if (!token) {\n try {\n const { useAuthenticationStore } = require(\"../../store/authenticationStore\");\n const authStore = useAuthenticationStore.getState();\n token = authStore.token;\n } catch (e) {\n // Store might not be available, that's ok\n }\n }\n \n debugLogger.info(\"AI Provider Init: IndexedDB config token factory\", { \n hasToken: !!token\n });\n return token;\n };\n }\n \n // Initialize the provider with saved config\n try {\n const { createProvider } = useAIProviderStore.getState();\n createProvider(providerConfig);\n \n const provider = useAIProviderStore.getState().provider;\n if (provider) {\n try {\n await provider.validateServiceAvailability({ timeoutMs: 5000 });\n debugLogger.info(`AI Provider initialized and validated from IndexedDB: ${providerConfig.type}`);\n } catch (validationError) {\n debugLogger.warn(`AI Provider created but validation failed`, { error: validationError });\n }\n }\n return; // Successfully initialized from IndexedDB\n } catch (error) {\n debugLogger.error(\"Failed to initialize saved provider config, falling back to package settings\", { error });\n }\n }\n \n debugLogger.info('AI Provider Init: No saved config found, using package settings');\n } catch (error) {\n debugLogger.warn('AI Provider Init: Failed to load from IndexedDB, using package settings', { error });\n }\n }\n\n // Fallback to package settings if no saved config found\n if (settings.aiProvider) {\n providerConfig = { ...settings.aiProvider };\n if (providerConfig.type === AIProviderType.ANTHROPIC) {\n providerConfig = this.convertAnthropicConfig(providerConfig, settings.gatewayApiUrl);\n }\n \n // Ensure tokenFactory is present for Ollama providers\n if (providerConfig.type === AIProviderType.OLLAMA && !providerConfig.tokenFactory) {\n providerConfig.tokenFactory = () => {\n // Try multiple sources for the token\n let token = authenticationService.getToken();\n \n // If the bandit-engine's service doesn't have a token, try direct localStorage access\n if (!token) {\n token = localStorage.getItem(\"authToken\");\n }\n \n // Also try the authentication store if available\n if (!token) {\n try {\n const { useAuthenticationStore } = require(\"../../store/authenticationStore\");\n const authStore = useAuthenticationStore.getState();\n token = authStore.token;\n } catch (e) {\n // Store might not be available, that's ok\n }\n }\n \n debugLogger.info(\"AIProviderInit: Explicit config tokenFactory\", { \n hasToken: !!token,\n localStorage: !!localStorage.getItem(\"authToken\")\n });\n return token;\n };\n }\n \n debugLogger.info(\"Using explicit AI provider config\", providerConfig);\n } else {\n // Fall back to legacy Ollama settings for backward compatibility\n providerConfig = {\n type: AIProviderType.OLLAMA,\n baseUrl: settings.ollamaUrl,\n tokenFactory: () => {\n // Try multiple sources for the token\n let token = authenticationService.getToken();\n \n // If the bandit-engine's service doesn't have a token, try direct localStorage access\n if (!token) {\n token = localStorage.getItem(\"authToken\");\n }\n \n // Also try the authentication store if available\n if (!token) {\n try {\n const { useAuthenticationStore } = require(\"../../store/authenticationStore\");\n const authStore = useAuthenticationStore.getState();\n token = authStore.token;\n } catch (e) {\n // Store might not be available, that's ok\n }\n }\n \n debugLogger.info(\"AIProviderInit: Token factory called\", { \n hasToken: !!token,\n localStorage: !!localStorage.getItem(\"authToken\")\n });\n return token;\n }\n };\n debugLogger.info(\"Using legacy Ollama config\", providerConfig);\n }\n\n try {\n // First validate if the service is available\n const { createProvider } = useAIProviderStore.getState();\n \n // Try to create and validate the provider\n createProvider(providerConfig);\n \n // Test provider availability\n const provider = useAIProviderStore.getState().provider;\n if (provider) {\n try {\n await provider.validateServiceAvailability({ timeoutMs: 5000 });\n debugLogger.info(`AI Provider initialized and validated: ${providerConfig.type}`);\n } catch (validationError) {\n debugLogger.warn(`AI Provider created but validation failed:`, { error: validationError });\n // Provider is created but may not be fully available - this is ok for offline scenarios\n }\n }\n } catch (error) {\n debugLogger.error(\"Failed to initialize AI provider:\", { error });\n \n // Try to fall back to default Ollama if initial provider fails\n if (providerConfig.type !== AIProviderType.OLLAMA) {\n try {\n const fallbackConfig: AIProviderConfig = {\n type: AIProviderType.OLLAMA,\n baseUrl: settings.ollamaUrl || 'http://localhost:11434',\n tokenFactory: () => {\n // Try multiple sources for the token\n let token = authenticationService.getToken();\n \n // If the bandit-engine's service doesn't have a token, try direct localStorage access\n if (!token) {\n token = localStorage.getItem(\"authToken\");\n }\n \n // Also try the authentication store if available\n if (!token) {\n try {\n const { useAuthenticationStore } = require(\"../../store/authenticationStore\");\n const authStore = useAuthenticationStore.getState();\n token = authStore.token;\n } catch (e) {\n // Store might not be available, that's ok\n }\n }\n \n debugLogger.info(\"AIProviderInit: Fallback tokenFactory\", { \n hasToken: !!token,\n localStorage: !!localStorage.getItem(\"authToken\")\n });\n return token;\n }\n };\n const { createProvider } = useAIProviderStore.getState();\n createProvider(fallbackConfig);\n debugLogger.info(\"Fallback to Ollama provider successful\");\n } catch (fallbackError) {\n debugLogger.error(\"Failed to initialize fallback Ollama provider:\", { error: fallbackError });\n }\n } else {\n // If Ollama provider fails, try localhost as ultimate fallback\n try {\n const localFallbackConfig: AIProviderConfig = {\n type: AIProviderType.OLLAMA,\n baseUrl: 'http://localhost:11434',\n tokenFactory: () => {\n // Try multiple sources for the token\n let token = authenticationService.getToken();\n \n // If the bandit-engine's service doesn't have a token, try direct localStorage access\n if (!token) {\n token = localStorage.getItem(\"authToken\");\n }\n \n // Also try the authentication store if available\n if (!token) {\n try {\n const { useAuthenticationStore } = require(\"../../store/authenticationStore\");\n const authStore = useAuthenticationStore.getState();\n token = authStore.token;\n } catch (e) {\n // Store might not be available, that's ok\n }\n }\n \n debugLogger.info(\"AIProviderInit: Local fallback tokenFactory\", { \n hasToken: !!token,\n localStorage: !!localStorage.getItem(\"authToken\")\n });\n return token;\n }\n };\n const { createProvider } = useAIProviderStore.getState();\n createProvider(localFallbackConfig);\n debugLogger.info(\"Fallback to localhost Ollama provider successful\");\n } catch (localFallbackError) {\n debugLogger.error(\"All provider initialization attempts failed:\", { error: localFallbackError });\n }\n }\n }\n }\n\n /**\n * Switch to a different AI provider\n */\n switchProvider(config: AIProviderConfig): void {\n try {\n const { switchProvider } = useAIProviderStore.getState();\n switchProvider(config);\n debugLogger.info(`Switched to AI provider: ${config.type}`);\n } catch (error) {\n debugLogger.error(\"Failed to switch AI provider:\", { error });\n throw error;\n }\n }\n\n /**\n * Get the current provider type\n */\n getCurrentProviderType(): string | null {\n const provider = useAIProviderStore.getState().provider;\n return provider ? provider.getProviderType() : null;\n }\n\n /**\n * Check if a provider is initialized\n */\n isProviderInitialized(): boolean {\n return useAIProviderStore.getState().provider !== null;\n }\n\n private convertAnthropicConfig(config: AIProviderConfig, gatewayUrl?: string | null): AIProviderConfig {\n if (config.type !== AIProviderType.ANTHROPIC) {\n return config;\n }\n\n const defaultModel = typeof config.defaultModel === 'string' && config.defaultModel.trim()\n ? config.defaultModel.trim()\n : 'claude-3-5-sonnet-latest';\n\n const normalized: AIProviderConfig = {\n type: AIProviderType.GATEWAY,\n gatewayUrl: gatewayUrl || config.gatewayUrl || '',\n provider: 'anthropic',\n defaultModel,\n tokenFactory: config.tokenFactory\n };\n\n debugLogger.info('AI Provider Init: Converted direct Anthropic provider to gateway configuration');\n return normalized;\n }\n}\n\nexport const aiProviderInitService = AIProviderInitService.getInstance();\n"],"mappings":";;;;;;;;;;;;;;;;;;AA8BO,IAAM,wBAAN,MAAM,uBAAsB;AAAA,EACjC,OAAe;AAAA,EAEP,cAAc;AAAA,EAAC;AAAA,EAEvB,OAAO,cAAqC;AAC1C,QAAI,CAAC,uBAAsB,UAAU;AACnC,6BAAsB,WAAW,IAAI,uBAAsB;AAAA,IAC7D;AACA,WAAO,uBAAsB;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,yBAAwC;AAC5C,UAAM,WAAW,wBAAwB,SAAS,EAAE;AACpD,QAAI,CAAC,UAAU;AACb,kBAAY,KAAK,0DAA0D;AAC3E;AAAA,IACF;AAEA,QAAI;AAEJ,gBAAY,KAAK,6CAA6C;AAAA,MAC5D,aAAa,CAAC,CAAC;AAAA,MACf,eAAe,CAAC,CAAC,SAAS;AAAA,MAC1B,WAAW,SAAS;AAAA,IACtB,CAAC;AAED,UAAM,0BACJ,SAAS,mBAAmB,QAC5B,SAAS,YAAY,2CACpB,SAAS,eAAe,YAAY,GAAG,WAAW,eAAe,KAAK,UACtE,OAAO,WAAW,eAAe,OAAO,SAAS,SAAS,SAAS,aAAa;AAGnF,QAAI,yBAAyB;AAC3B,kBAAY,KAAK,oFAAoF;AAAA,IACvG,OAAO;AACL,UAAI;AACF,cAAM,cAAc,MAAM,yBAAiB;AAAA,UACzC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,CAAC,EAAE,MAAM,UAAU,SAAS,KAAK,CAAC;AAAA,QACpC;AAEA,YAAI,aAAa;AACf,sBAAY,KAAK,qDAAqD,EAAE,MAAM,YAAY,KAAK,CAAC;AAGhG,gBAAM,EAAE,IAAI,KAAK,GAAG,gBAAgB,IAAI;AACxC,2BAAiB,EAAE,GAAG,gBAAgB;A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YAA8C;AACrG,QAAI,OAAO,sCAAmC;AAC5C,aAAO;AAAA,IACT;AAEA,UAAM,eAAe,OAAO,OAAO,iBAAiB,YAAY,OAAO,aAAa,KAAK,IACrF,OAAO,aAAa,KAAK,IACzB;AAEJ,UAAM,aAA+B;AAAA,MACnC;AAAA,MACA,YAAY,cAAc,OAAO,cAAc;AAAA,MAC/C,UAAU;AAAA,MACV;AAAA,MACA,cAAc,OAAO;AAAA,IACvB;AAEA,gBAAY,KAAK,gFAAgF;AACjG,WAAO;AAAA,EACT;AACF;AAEO,IAAM,wBAAwB,sBAAsB,YAAY;","names":[]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
aiProviderInitService
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-EOKIE5HZ.mjs";
|
|
4
4
|
import {
|
|
5
5
|
useMCPToolsStore
|
|
6
6
|
} from "./chunk-RTQDQ6TC.mjs";
|
|
7
7
|
import {
|
|
8
8
|
chat_modal_default
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ECRNIAG6.mjs";
|
|
10
10
|
import {
|
|
11
11
|
DocumentCard_default,
|
|
12
12
|
banditDarkTheme,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
predefinedThemes,
|
|
15
15
|
useNotificationService,
|
|
16
16
|
useVoiceStore
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-QYH2T4L5.mjs";
|
|
18
18
|
import {
|
|
19
19
|
authenticationService,
|
|
20
20
|
brandingService_default,
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
useFeatures,
|
|
28
28
|
useKnowledgeStore2 as useKnowledgeStore,
|
|
29
29
|
useVectorStore
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-CDQYBO3Q.mjs";
|
|
31
31
|
import {
|
|
32
32
|
indexedDBService_default,
|
|
33
33
|
models,
|
|
@@ -39,13 +39,13 @@ import {
|
|
|
39
39
|
AIProviderFactory,
|
|
40
40
|
GatewayService,
|
|
41
41
|
useAIProviderStore
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-QU5S5QQP.mjs";
|
|
43
43
|
import {
|
|
44
44
|
debugLogger
|
|
45
45
|
} from "./chunk-KCI46M23.mjs";
|
|
46
46
|
|
|
47
47
|
// src/management/management.tsx
|
|
48
|
-
import { useState as useState12, useEffect as useEffect9, useCallback as
|
|
48
|
+
import { useState as useState12, useEffect as useEffect9, useCallback as useCallback7 } from "react";
|
|
49
49
|
import useMediaQuery6 from "@mui/material/useMediaQuery";
|
|
50
50
|
import { alpha as alpha2 } from "@mui/material/styles";
|
|
51
51
|
import {
|
|
@@ -6926,7 +6926,7 @@ var StorageTab = ({ currentTheme }) => {
|
|
|
6926
6926
|
var StorageTab_default = StorageTab;
|
|
6927
6927
|
|
|
6928
6928
|
// src/management/components/ProviderTab.tsx
|
|
6929
|
-
import { useState as useState10, useEffect as useEffect7 } from "react";
|
|
6929
|
+
import { useState as useState10, useEffect as useEffect7, useCallback as useCallback6 } from "react";
|
|
6930
6930
|
import {
|
|
6931
6931
|
Box as Box9,
|
|
6932
6932
|
Typography as Typography9,
|
|
@@ -6946,6 +6946,48 @@ var ProviderTab = () => {
|
|
|
6946
6946
|
const { settings: packageSettings } = usePackageSettingsStore();
|
|
6947
6947
|
const theme = useTheme7();
|
|
6948
6948
|
const isMobile = useMediaQuery5(theme.breakpoints.down("sm"));
|
|
6949
|
+
const getSuggestedModel = useCallback6((type) => {
|
|
6950
|
+
const configuredDefault = packageSettings?.defaultModel?.trim();
|
|
6951
|
+
if (configuredDefault) {
|
|
6952
|
+
return configuredDefault;
|
|
6953
|
+
}
|
|
6954
|
+
switch (type) {
|
|
6955
|
+
case "openai" /* OPENAI */:
|
|
6956
|
+
return "gpt-4o-mini";
|
|
6957
|
+
case "xai" /* XAI */:
|
|
6958
|
+
return "grok-beta";
|
|
6959
|
+
default:
|
|
6960
|
+
return "";
|
|
6961
|
+
}
|
|
6962
|
+
}, [packageSettings?.defaultModel]);
|
|
6963
|
+
const applyDefaultModel = useCallback6((config) => {
|
|
6964
|
+
const normalized = { ...config };
|
|
6965
|
+
const trimmed = typeof normalized.defaultModel === "string" ? normalized.defaultModel.trim() : void 0;
|
|
6966
|
+
const requiresModel = normalized.type === "openai" /* OPENAI */ || normalized.type === "xai" /* XAI */;
|
|
6967
|
+
if (trimmed) {
|
|
6968
|
+
normalized.defaultModel = trimmed;
|
|
6969
|
+
return normalized;
|
|
6970
|
+
}
|
|
6971
|
+
if (!requiresModel) {
|
|
6972
|
+
delete normalized.defaultModel;
|
|
6973
|
+
return normalized;
|
|
6974
|
+
}
|
|
6975
|
+
const suggestion = getSuggestedModel(normalized.type);
|
|
6976
|
+
if (suggestion) {
|
|
6977
|
+
normalized.defaultModel = suggestion;
|
|
6978
|
+
} else {
|
|
6979
|
+
delete normalized.defaultModel;
|
|
6980
|
+
}
|
|
6981
|
+
return normalized;
|
|
6982
|
+
}, [getSuggestedModel]);
|
|
6983
|
+
const sanitizeConfigForSave = useCallback6((config) => {
|
|
6984
|
+
const sanitized = { ...config };
|
|
6985
|
+
if (typeof sanitized.defaultModel === "string") {
|
|
6986
|
+
const trimmed = sanitized.defaultModel.trim();
|
|
6987
|
+
sanitized.defaultModel = trimmed || void 0;
|
|
6988
|
+
}
|
|
6989
|
+
return sanitized;
|
|
6990
|
+
}, []);
|
|
6949
6991
|
const [providerConfig, setProviderConfig] = useState10({
|
|
6950
6992
|
type: "ollama",
|
|
6951
6993
|
baseUrl: "http://localhost:11434"
|
|
@@ -6994,19 +7036,38 @@ var ProviderTab = () => {
|
|
|
6994
7036
|
}
|
|
6995
7037
|
return null;
|
|
6996
7038
|
};
|
|
7039
|
+
const convertAnthropicConfig = useCallback6((config) => {
|
|
7040
|
+
if (!config) return null;
|
|
7041
|
+
if (config.type !== "anthropic" /* ANTHROPIC */) {
|
|
7042
|
+
return config;
|
|
7043
|
+
}
|
|
7044
|
+
const gatewayUrl = config.gatewayUrl || packageSettings?.gatewayApiUrl || "";
|
|
7045
|
+
const defaultModel = typeof config.defaultModel === "string" && config.defaultModel.trim() ? config.defaultModel.trim() : "claude-3-5-sonnet-latest";
|
|
7046
|
+
const converted = {
|
|
7047
|
+
type: "gateway" /* GATEWAY */,
|
|
7048
|
+
gatewayUrl,
|
|
7049
|
+
provider: "anthropic",
|
|
7050
|
+
defaultModel,
|
|
7051
|
+
tokenFactory: config.tokenFactory
|
|
7052
|
+
};
|
|
7053
|
+
return converted;
|
|
7054
|
+
}, [packageSettings?.gatewayApiUrl]);
|
|
6997
7055
|
useEffect7(() => {
|
|
6998
7056
|
const initializeProviderConfig = async () => {
|
|
6999
7057
|
const savedConfig = await loadProviderConfigFromDB();
|
|
7000
7058
|
if (savedConfig) {
|
|
7001
|
-
|
|
7059
|
+
const normalized = convertAnthropicConfig(savedConfig) || savedConfig;
|
|
7060
|
+
setProviderConfig(applyDefaultModel(normalized));
|
|
7002
7061
|
} else if (currentProviderConfig) {
|
|
7003
|
-
|
|
7062
|
+
const normalized = convertAnthropicConfig(currentProviderConfig) || currentProviderConfig;
|
|
7063
|
+
setProviderConfig(applyDefaultModel(normalized));
|
|
7004
7064
|
} else if (packageSettings?.aiProvider) {
|
|
7005
|
-
|
|
7065
|
+
const normalized = convertAnthropicConfig(packageSettings.aiProvider) || packageSettings.aiProvider;
|
|
7066
|
+
setProviderConfig(applyDefaultModel(normalized));
|
|
7006
7067
|
}
|
|
7007
7068
|
};
|
|
7008
7069
|
initializeProviderConfig();
|
|
7009
|
-
}, [currentProviderConfig, packageSettings]);
|
|
7070
|
+
}, [applyDefaultModel, convertAnthropicConfig, currentProviderConfig, packageSettings]);
|
|
7010
7071
|
const showMessage = (message, severity) => {
|
|
7011
7072
|
setSnackbarMessage(message);
|
|
7012
7073
|
setSnackbarSeverity(severity);
|
|
@@ -7016,74 +7077,87 @@ var ProviderTab = () => {
|
|
|
7016
7077
|
const baseConfig = { type };
|
|
7017
7078
|
switch (type) {
|
|
7018
7079
|
case "ollama" /* OLLAMA */:
|
|
7019
|
-
setProviderConfig({
|
|
7080
|
+
setProviderConfig(applyDefaultModel({
|
|
7020
7081
|
...baseConfig,
|
|
7021
7082
|
baseUrl: "http://localhost:11434"
|
|
7022
|
-
});
|
|
7083
|
+
}));
|
|
7023
7084
|
break;
|
|
7024
7085
|
case "openai" /* OPENAI */:
|
|
7025
|
-
setProviderConfig({
|
|
7086
|
+
setProviderConfig(applyDefaultModel({
|
|
7026
7087
|
...baseConfig,
|
|
7027
7088
|
baseUrl: "https://api.openai.com/v1",
|
|
7028
7089
|
apiKey: ""
|
|
7029
|
-
});
|
|
7090
|
+
}));
|
|
7030
7091
|
break;
|
|
7031
7092
|
case "azure-openai" /* AZURE_OPENAI */:
|
|
7032
|
-
setProviderConfig({
|
|
7093
|
+
setProviderConfig(applyDefaultModel({
|
|
7033
7094
|
...baseConfig,
|
|
7034
7095
|
baseUrl: "",
|
|
7035
7096
|
apiKey: "",
|
|
7036
7097
|
apiVersion: "2024-02-01",
|
|
7037
7098
|
deploymentName: ""
|
|
7038
|
-
});
|
|
7099
|
+
}));
|
|
7039
7100
|
break;
|
|
7040
7101
|
case "anthropic" /* ANTHROPIC */:
|
|
7041
|
-
|
|
7042
|
-
|
|
7043
|
-
|
|
7044
|
-
|
|
7045
|
-
|
|
7102
|
+
showMessage("Anthropic is only available via the Gateway provider. Please configure Gateway and choose Anthropic as the backend.", "error");
|
|
7103
|
+
setProviderConfig(applyDefaultModel({
|
|
7104
|
+
type: "gateway" /* GATEWAY */,
|
|
7105
|
+
gatewayUrl: packageSettings?.gatewayApiUrl || "",
|
|
7106
|
+
provider: "anthropic",
|
|
7107
|
+
defaultModel: "claude-3-5-sonnet-latest"
|
|
7108
|
+
}));
|
|
7046
7109
|
break;
|
|
7047
7110
|
case "xai" /* XAI */:
|
|
7048
|
-
setProviderConfig({
|
|
7111
|
+
setProviderConfig(applyDefaultModel({
|
|
7049
7112
|
...baseConfig,
|
|
7050
7113
|
baseUrl: "https://api.x.ai/v1",
|
|
7051
7114
|
apiKey: ""
|
|
7052
|
-
});
|
|
7115
|
+
}));
|
|
7053
7116
|
break;
|
|
7054
7117
|
case "gateway" /* GATEWAY */:
|
|
7055
|
-
setProviderConfig({
|
|
7118
|
+
setProviderConfig(applyDefaultModel({
|
|
7056
7119
|
...baseConfig,
|
|
7057
7120
|
gatewayUrl: packageSettings?.gatewayApiUrl || "",
|
|
7058
7121
|
provider: "openai"
|
|
7059
|
-
});
|
|
7122
|
+
}));
|
|
7060
7123
|
break;
|
|
7061
7124
|
case "playground" /* PLAYGROUND */:
|
|
7062
|
-
setProviderConfig({
|
|
7125
|
+
setProviderConfig(applyDefaultModel({
|
|
7063
7126
|
...baseConfig
|
|
7064
|
-
});
|
|
7127
|
+
}));
|
|
7065
7128
|
break;
|
|
7066
7129
|
}
|
|
7067
7130
|
};
|
|
7068
7131
|
const handleSaveProviderConfig = async () => {
|
|
7069
7132
|
try {
|
|
7070
|
-
const
|
|
7133
|
+
const normalizedConfigIntermediate = sanitizeConfigForSave(providerConfig);
|
|
7134
|
+
const normalizedConfig = convertAnthropicConfig(normalizedConfigIntermediate) || normalizedConfigIntermediate;
|
|
7135
|
+
const requiresModel = normalizedConfig.type === "openai" /* OPENAI */ || normalizedConfig.type === "xai" /* XAI */;
|
|
7136
|
+
if (requiresModel && !normalizedConfig.defaultModel) {
|
|
7137
|
+
showMessage("Please provide a default model ID for the selected provider.", "error");
|
|
7138
|
+
return;
|
|
7139
|
+
}
|
|
7140
|
+
const isValid = AIProviderFactory.validateConfig(normalizedConfig);
|
|
7071
7141
|
if (!isValid) {
|
|
7072
7142
|
showMessage("Invalid provider configuration. Please check all required fields.", "error");
|
|
7073
7143
|
return;
|
|
7074
7144
|
}
|
|
7075
|
-
await saveProviderConfigToDB(
|
|
7076
|
-
await aiProviderInitService.switchProvider(
|
|
7145
|
+
await saveProviderConfigToDB(normalizedConfig);
|
|
7146
|
+
await aiProviderInitService.switchProvider(normalizedConfig);
|
|
7077
7147
|
if (packageSettings) {
|
|
7078
7148
|
const updatedSettings = {
|
|
7079
7149
|
...packageSettings,
|
|
7080
|
-
aiProvider:
|
|
7150
|
+
aiProvider: normalizedConfig
|
|
7081
7151
|
};
|
|
7152
|
+
if (normalizedConfig.defaultModel) {
|
|
7153
|
+
updatedSettings.defaultModel = normalizedConfig.defaultModel;
|
|
7154
|
+
}
|
|
7082
7155
|
usePackageSettingsStore.setState({ settings: updatedSettings });
|
|
7083
7156
|
}
|
|
7157
|
+
setProviderConfig(applyDefaultModel(normalizedConfig));
|
|
7084
7158
|
setIsProviderConfigOpen(false);
|
|
7085
7159
|
showMessage("Provider configuration saved and switched successfully!", "success");
|
|
7086
|
-
debugLogger.info("Provider configuration saved and switched", { type:
|
|
7160
|
+
debugLogger.info("Provider configuration saved and switched", { type: normalizedConfig.type });
|
|
7087
7161
|
} catch (error) {
|
|
7088
7162
|
debugLogger.error("Failed to save provider configuration:", { error });
|
|
7089
7163
|
showMessage(`Failed to save provider configuration: ${error instanceof Error ? error.message : "Unknown error"}`, "error");
|
|
@@ -7091,8 +7165,9 @@ var ProviderTab = () => {
|
|
|
7091
7165
|
};
|
|
7092
7166
|
const handleTestProviderConnection = async () => {
|
|
7093
7167
|
try {
|
|
7094
|
-
const testConfig =
|
|
7095
|
-
const
|
|
7168
|
+
const testConfig = sanitizeConfigForSave(providerConfig);
|
|
7169
|
+
const normalizedTestConfig = convertAnthropicConfig(testConfig) || testConfig;
|
|
7170
|
+
const testProvider = AIProviderFactory.createProvider(normalizedTestConfig);
|
|
7096
7171
|
const result = await testProvider.validateServiceAvailability({ timeoutMs: 1e4 });
|
|
7097
7172
|
if (result.isAvailable) {
|
|
7098
7173
|
showMessage("Connection successful! Provider is available.", "success");
|
|
@@ -7182,7 +7257,6 @@ var ProviderTab = () => {
|
|
|
7182
7257
|
/* @__PURE__ */ jsx9(MenuItem3, { value: "ollama", children: "Ollama" }),
|
|
7183
7258
|
/* @__PURE__ */ jsx9(MenuItem3, { value: "openai", children: "OpenAI" }),
|
|
7184
7259
|
/* @__PURE__ */ jsx9(MenuItem3, { value: "azure-openai", children: "Azure OpenAI" }),
|
|
7185
|
-
/* @__PURE__ */ jsx9(MenuItem3, { value: "anthropic", children: "Anthropic" }),
|
|
7186
7260
|
/* @__PURE__ */ jsx9(MenuItem3, { value: "xai", children: "xAI" }),
|
|
7187
7261
|
/* @__PURE__ */ jsx9(MenuItem3, { value: "playground", children: "Playground (Mock Demo)" })
|
|
7188
7262
|
]
|
|
@@ -7238,7 +7312,10 @@ var ProviderTab = () => {
|
|
|
7238
7312
|
{
|
|
7239
7313
|
label: "API Base URL",
|
|
7240
7314
|
value: providerConfig.baseUrl || "",
|
|
7241
|
-
onChange: (e) => setProviderConfig(
|
|
7315
|
+
onChange: (e) => setProviderConfig((prev) => ({
|
|
7316
|
+
...prev,
|
|
7317
|
+
baseUrl: e.target.value
|
|
7318
|
+
})),
|
|
7242
7319
|
fullWidth: true,
|
|
7243
7320
|
sx: { mb: 2 },
|
|
7244
7321
|
placeholder: "https://api.openai.com/v1"
|
|
@@ -7250,10 +7327,28 @@ var ProviderTab = () => {
|
|
|
7250
7327
|
label: "API Key",
|
|
7251
7328
|
type: "password",
|
|
7252
7329
|
value: providerConfig.apiKey || "",
|
|
7253
|
-
onChange: (e) => setProviderConfig(
|
|
7330
|
+
onChange: (e) => setProviderConfig((prev) => ({
|
|
7331
|
+
...prev,
|
|
7332
|
+
apiKey: e.target.value
|
|
7333
|
+
})),
|
|
7254
7334
|
fullWidth: true,
|
|
7335
|
+
sx: { mb: 2 },
|
|
7255
7336
|
placeholder: "sk-..."
|
|
7256
7337
|
}
|
|
7338
|
+
),
|
|
7339
|
+
/* @__PURE__ */ jsx9(
|
|
7340
|
+
TextField5,
|
|
7341
|
+
{
|
|
7342
|
+
label: "Default Model ID",
|
|
7343
|
+
value: providerConfig.defaultModel || "",
|
|
7344
|
+
onChange: (e) => setProviderConfig((prev) => ({
|
|
7345
|
+
...prev,
|
|
7346
|
+
defaultModel: e.target.value
|
|
7347
|
+
})),
|
|
7348
|
+
fullWidth: true,
|
|
7349
|
+
placeholder: "gpt-4o-mini",
|
|
7350
|
+
helperText: "Example: gpt-4o-mini, gpt-4.1, gpt-3.5-turbo"
|
|
7351
|
+
}
|
|
7257
7352
|
)
|
|
7258
7353
|
] }),
|
|
7259
7354
|
providerConfig.type === "azure-openai" && /* @__PURE__ */ jsxs9(Box9, { children: [
|
|
@@ -7307,7 +7402,10 @@ var ProviderTab = () => {
|
|
|
7307
7402
|
{
|
|
7308
7403
|
label: "API Base URL",
|
|
7309
7404
|
value: providerConfig.baseUrl || "",
|
|
7310
|
-
onChange: (e) => setProviderConfig(
|
|
7405
|
+
onChange: (e) => setProviderConfig((prev) => ({
|
|
7406
|
+
...prev,
|
|
7407
|
+
baseUrl: e.target.value
|
|
7408
|
+
})),
|
|
7311
7409
|
fullWidth: true,
|
|
7312
7410
|
sx: { mb: 2 },
|
|
7313
7411
|
placeholder: "https://api.x.ai/v1"
|
|
@@ -7319,36 +7417,31 @@ var ProviderTab = () => {
|
|
|
7319
7417
|
label: "API Key",
|
|
7320
7418
|
type: "password",
|
|
7321
7419
|
value: providerConfig.apiKey || "",
|
|
7322
|
-
onChange: (e) => setProviderConfig(
|
|
7323
|
-
|
|
7324
|
-
|
|
7325
|
-
|
|
7326
|
-
)
|
|
7327
|
-
] }),
|
|
7328
|
-
providerConfig.type === "anthropic" && /* @__PURE__ */ jsxs9(Box9, { children: [
|
|
7329
|
-
/* @__PURE__ */ jsx9(
|
|
7330
|
-
TextField5,
|
|
7331
|
-
{
|
|
7332
|
-
label: "API Base URL",
|
|
7333
|
-
value: providerConfig.baseUrl || "",
|
|
7334
|
-
onChange: (e) => setProviderConfig({ ...providerConfig, baseUrl: e.target.value }),
|
|
7420
|
+
onChange: (e) => setProviderConfig((prev) => ({
|
|
7421
|
+
...prev,
|
|
7422
|
+
apiKey: e.target.value
|
|
7423
|
+
})),
|
|
7335
7424
|
fullWidth: true,
|
|
7336
7425
|
sx: { mb: 2 },
|
|
7337
|
-
placeholder: "
|
|
7426
|
+
placeholder: "xai-..."
|
|
7338
7427
|
}
|
|
7339
7428
|
),
|
|
7340
7429
|
/* @__PURE__ */ jsx9(
|
|
7341
7430
|
TextField5,
|
|
7342
7431
|
{
|
|
7343
|
-
label: "
|
|
7344
|
-
|
|
7345
|
-
|
|
7346
|
-
|
|
7432
|
+
label: "Default Model ID",
|
|
7433
|
+
value: providerConfig.defaultModel || "",
|
|
7434
|
+
onChange: (e) => setProviderConfig((prev) => ({
|
|
7435
|
+
...prev,
|
|
7436
|
+
defaultModel: e.target.value
|
|
7437
|
+
})),
|
|
7347
7438
|
fullWidth: true,
|
|
7348
|
-
placeholder: "
|
|
7439
|
+
placeholder: "grok-beta",
|
|
7440
|
+
helperText: "Example: grok-beta, grok-2, grok-vision-beta"
|
|
7349
7441
|
}
|
|
7350
7442
|
)
|
|
7351
7443
|
] }),
|
|
7444
|
+
providerConfig.type === "anthropic" && /* @__PURE__ */ jsx9(Alert8, { severity: "warning", sx: { mt: 2 }, children: "Anthropic is only supported through the Bandit Gateway provider. Please switch to Gateway and select Anthropic as the backend service." }),
|
|
7352
7445
|
/* @__PURE__ */ jsxs9(Box9, { sx: { display: "flex", gap: 2, mt: 3 }, children: [
|
|
7353
7446
|
/* @__PURE__ */ jsx9(
|
|
7354
7447
|
Button8,
|
|
@@ -7641,7 +7734,7 @@ var MCPToolsTabV2_default = MCPToolsTabV2;
|
|
|
7641
7734
|
|
|
7642
7735
|
// src/management/management.tsx
|
|
7643
7736
|
import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
7644
|
-
var preloadChatPage = () => import("./chat-
|
|
7737
|
+
var preloadChatPage = () => import("./chat-5QJNWB7I.mjs");
|
|
7645
7738
|
var Management = () => {
|
|
7646
7739
|
const navigate = useNavigate();
|
|
7647
7740
|
const notificationService = useNotificationService();
|
|
@@ -7749,7 +7842,7 @@ var Management = () => {
|
|
|
7749
7842
|
}
|
|
7750
7843
|
}
|
|
7751
7844
|
}, [selectedModel, availableModels]);
|
|
7752
|
-
const loadBrandingConfig =
|
|
7845
|
+
const loadBrandingConfig = useCallback7(async () => {
|
|
7753
7846
|
if (isLoadingBranding || brandingLoaded) {
|
|
7754
7847
|
debugLogger.warn("Branding loading already in progress or completed, skipping");
|
|
7755
7848
|
return;
|
|
@@ -8819,4 +8912,4 @@ export {
|
|
|
8819
8912
|
useGatewayMemory,
|
|
8820
8913
|
management_default
|
|
8821
8914
|
};
|
|
8822
|
-
//# sourceMappingURL=chunk-
|
|
8915
|
+
//# sourceMappingURL=chunk-JRCDANLN.mjs.map
|