UNPKG

@spectrumsense/spectrum-chat-dev

Version:

Embeddable AI Widget - Add trusted, evidence-based answers directly to your website. Simple installation, enterprise-grade security.

93 lines (81 loc) 2.45 kB
/** * Spectrum Chat Configuration * * This file contains environment-specific configuration for the Spectrum Chat widget. * Configuration is set during build time based on environment variables. */ // Environment Configuration const SPECTRUM_CONFIG = { // API Configuration API_ROOT: 'https://api.spectrumsense.co', // Set during build time // Environment Detection ENVIRONMENT: 'prod', // Set during build time // Default Configuration DEFAULT_CONFIG: { tenantId: 'brightspectrum-tenant-123', title: 'Bright Spectrum AI Assistant', introText: 'I am Bright Spectrum AI Assistant. I can answer questions about our programs, costs, and services.', primaryColor: 'hsl(145 73% 35%)', userColor: 'hsl(195 82% 45%)', aiColor: 'hsl(145 73% 35%)', position: 'bottom-right', width: '320px', height: '350px', showIntro: true, enableCitations: false, debug: true } }; // Environment-specific configurations const ENVIRONMENT_CONFIGS = { local: { API_ROOT: 'http://localhost:8000', debug: true }, develop: { API_ROOT: 'https://dev-api.spectrumsense.co', debug: true }, prod: { API_ROOT: 'https://api.spectrumsense.co', debug: false } }; // Auto-detect environment based on hostname function detectEnvironment() { const hostname = window.location.hostname; if (hostname === 'localhost' || hostname === '127.0.0.1') { return 'local'; } else if (hostname.includes('dev') || hostname.includes('develop')) { return 'develop'; } else { return 'prod'; } } // Get current environment configuration function getCurrentConfig() { const environment = detectEnvironment(); const envConfig = ENVIRONMENT_CONFIGS[environment] || ENVIRONMENT_CONFIGS.local; return { ...SPECTRUM_CONFIG.DEFAULT_CONFIG, ...envConfig, apiUrl: `${envConfig.API_ROOT}/api/v1/conversations` }; } // Export for use in other scripts window.SpectrumConfig = { getConfig: getCurrentConfig, getApiRoot: () => getCurrentConfig().API_ROOT, getApiUrl: () => getCurrentConfig().apiUrl, getEnvironment: detectEnvironment, // Manual override for testing overrideConfig: (newConfig) => { Object.assign(SPECTRUM_CONFIG, newConfig); } }; // Log current configuration console.log('Spectrum Chat Configuration:', { environment: detectEnvironment(), apiRoot: getCurrentConfig().API_ROOT, apiUrl: getCurrentConfig().apiUrl });