### Install Bun Dependencies Source: https://github.com/danny-avila/librechat/blob/main/config/translations/README.md Run this command from the project root to install all necessary dependencies using Bun. ```bash bun install ``` -------------------------------- ### Install @librechat/client Source: https://github.com/danny-avila/librechat/blob/main/packages/client/src/theme/README.md Install the required component library via npm. ```bash npm install @librechat/client ``` -------------------------------- ### Install Redis Server Source: https://github.com/danny-avila/librechat/blob/main/redis-config/README.md Install Redis server on different operating systems. Ensure Redis CLI is available. ```bash # macOS brew install redis ``` ```bash # Ubuntu/Debian sudo apt-get install redis-server ``` ```bash # CentOS/RHEL sudo yum install redis ``` -------------------------------- ### Start Redis Cluster Source: https://github.com/danny-avila/librechat/blob/main/redis-config/README.md Navigate to the redis-config directory and start the 3-node Redis cluster using the provided script. ```bash # Navigate to the redis-config directory cd redis-config # Start and initialize the cluster ./start-cluster.sh ``` -------------------------------- ### Start LibreChat Backend Source: https://github.com/danny-avila/librechat/blob/main/redis-config/README.md Launch the backend service and monitor logs for successful Redis connection indicators. ```bash # Start LibreChat backend npm run backend # Look for these success indicators in logs: # ✅ "No changes needed for 'USER' role permissions" # ✅ "No changes needed for 'ADMIN' role permissions" # ✅ "Server listening at http://localhost:3080" # ✅ No "IoRedis connection error" messages ``` -------------------------------- ### Install hnswlib-node Temporarily Source: https://github.com/danny-avila/librechat/blob/main/config/translations/README.md Install the hnswlib-node package as a development dependency. This is a temporary step and the package is not intended to be part of the final project. ```bash npm install --save-dev hnswlib-node ``` -------------------------------- ### Start Standard Redis Server Source: https://github.com/danny-avila/librechat/blob/main/redis-config/README.md Start a standard Redis instance on the default port 6379. This is suitable for local development without encryption. ```bash # Use system Redis on default port 6379 redis-server ``` -------------------------------- ### Start Cluster Script Source: https://github.com/danny-avila/librechat/blob/main/redis-config/README.md Execute the cluster start script. This command assumes the script is executable and located in the current directory. ```bash ./start-cluster.sh ``` -------------------------------- ### Start Redis with TLS Encryption Source: https://github.com/danny-avila/librechat/blob/main/redis-config/README.md Start a single Redis instance with TLS encryption on port 6380 using the provided script. ```bash # Start Redis with TLS encryption on port 6380 ./start-redis-tls.sh ``` -------------------------------- ### Start Redis with TLS Source: https://github.com/danny-avila/librechat/blob/main/redis-config/README.md Initiate the Redis server with TLS support enabled on port 6380. ```bash # Start Redis with TLS on port 6380 ./start-redis-tls.sh ``` -------------------------------- ### Install LibreChat with Inline DNS Settings Source: https://github.com/danny-avila/librechat/blob/main/helm/librechat/DNS_CONFIGURATION.md Installs the LibreChat Helm chart with DNS policy and nameserver settings provided directly as command-line arguments. This is useful for quick testing or specific overrides. ```bash helm install librechat ./helm/librechat \ --set dnsPolicy="None" \ --set dnsConfig.nameservers[0]="10.0.0.10" ``` -------------------------------- ### Start LibreChat with Langfuse Fanout Source: https://github.com/danny-avila/librechat/blob/main/otel/langfuse-fanout/README.md Use these Docker Compose commands to start LibreChat with the Langfuse fanout override. The override builds the fanout gateway image, enables it, and configures LibreChat to use the fanout collector. ```sh docker compose -f docker-compose.yml -f docker-compose.langfuse-fanout.yml up -d ``` ```sh docker compose -f deploy-compose.yml -f deploy-compose.langfuse-fanout.yml up -d ``` -------------------------------- ### Toggle Theme using useTheme Hook Source: https://github.com/danny-avila/librechat/blob/main/packages/client/src/theme/README.md Demonstrates how to use the useTheme hook to get the current theme and toggle between 'dark' and 'light' modes. ```tsx import { useTheme } from '@librechat/client'; function ThemeToggle() { const { theme, setTheme } = useTheme(); return ( ); } ``` -------------------------------- ### Dynamic DNS Configuration with Helm Templating Source: https://github.com/danny-avila/librechat/blob/main/helm/librechat/DNS_CONFIGURATION.md Uses Helm's templating capabilities to dynamically set DNS configuration based on the environment value. This example applies different DNS policies and nameservers for 'production' versus other environments. ```yaml {{- if eq .Values.environment "production" }} dnsPolicy: "None" dnsConfig: nameservers: - "10.0.0.10" # Production DNS {{- else }} dnsPolicy: "ClusterFirst" # Use default in dev {{- end }} ``` -------------------------------- ### Enable Langfuse Fanout Gateway and Configure Redis Source: https://github.com/danny-avila/librechat/blob/main/otel/langfuse-fanout/README.md Configure the Helm chart to enable the Langfuse fanout gateway and specify Redis settings. This example shows enabling the bundled Redis chart. For external Redis, set `langfuseFanout.redis.uri`. ```yaml redis: enabled: true langfuseFanout: enabled: true central: baseUrl: https://cloud.langfuse.com authHeaderSecret: name: langfuse-central key: LANGFUSE_FANOUT_CENTRAL_AUTH_HEADER metrics: secret: name: librechat-metrics key: METRICS_SECRET tenant: destinations: eu: baseUrl: https://cloud.langfuse.com us: baseUrl: https://us.cloud.langfuse.com jp: baseUrl: https://jp.cloud.langfuse.com upstreamTimeout: 30s publicUrl: "" otelCollector: receiverEndpoint: 127.0.0.1:4319 redis: uri: "" username: "" passwordSecret: name: "" key: REDIS_PASSWORD keyPrefix: langfuse-fanout memoryLimitMiB: 256 memorySpikeLimitMiB: 64 batchTimeout: 1s batchSendSize: 128 metadataCardinalityLimit: 1000 ``` -------------------------------- ### Deploy LibreChat with Custom Values Source: https://github.com/danny-avila/librechat/blob/main/helm/librechat/DNS_CONFIGURATION.md Upgrades or installs the LibreChat Helm chart using a custom values.yaml file. Ensure the values.yaml file contains the desired DNS configuration. ```bash helm upgrade --install librechat ./helm/librechat -f values.yaml ``` -------------------------------- ### Record End-to-End Tests Source: https://github.com/danny-avila/librechat/blob/main/e2e/README.md Use this command to start Playwright codegen for recording exploratory browser sessions into draft tests. It builds the app, starts the test server with a fake LLM, and opens codegen. ```sh npm run e2e:record ``` -------------------------------- ### Test Redis Cluster Connection Source: https://github.com/danny-avila/librechat/blob/main/redis-config/README.md Connect to the Redis cluster on port 7001 using redis-cli with the -c flag for cluster mode. Test basic SET and GET operations. ```bash # Connect to the cluster redis-cli -c -p 7001 # Test basic operations SET test_key "Hello World" GET test_key ``` -------------------------------- ### Wrap Application with ThemeProvider Source: https://github.com/danny-avila/librechat/blob/main/packages/client/src/theme/README.md Initialize the theme system by wrapping the root application component with the ThemeProvider. ```tsx import { ThemeProvider } from '@librechat/client'; function App() { return ( ); } ``` -------------------------------- ### Troubleshoot Backend Connection Issues Source: https://github.com/danny-avila/librechat/blob/main/redis-config/README.md Verify the CA certificate path and test the backend connection to identify configuration errors. ```bash # Verify CA certificate path in .env ls -la /path/to/LibreChat/redis-config/certs/ca-cert.pem # Test LibreChat Redis configuration cd /path/to/LibreChat npm run backend # Look for Redis connection errors in output ``` -------------------------------- ### Implement Multi-Theme Selector Source: https://github.com/danny-avila/librechat/blob/main/packages/client/src/theme/README.md Demonstrates how to map custom theme objects to the ThemeProvider to allow users to select from multiple predefined color schemes. ```tsx const themes = { default: undefined, // Use CSS defaults ocean: { 'rgb-brand-purple': '0 119 190', 'rgb-surface-primary': '240 248 255', // ... ocean theme colors }, forest: { 'rgb-brand-purple': '34 139 34', 'rgb-surface-primary': '245 255 250', // ... forest theme colors }, }; function App() { const [selectedTheme, setSelectedTheme] = useState('default'); return ( ); } ``` -------------------------------- ### Verify values.yaml Indentation for DNS Configuration Source: https://github.com/danny-avila/librechat/blob/main/helm/librechat/DNS_CONFIGURATION.md Illustrates the correct indentation for top-level DNS configuration in the values.yaml file. Incorrect indentation can lead to the configuration not being applied. ```yaml dnsPolicy: "None" # Top level, not under any section dnsConfig: # Top level, not under any section nameservers: - "10.0.0.10" ``` -------------------------------- ### Redirect AI Services to Proxy Source: https://github.com/danny-avila/librechat/blob/main/helm/librechat/DNS_CONFIGURATION.md Configures DNS to redirect AI service traffic to a proxy. This setup uses a specific nameserver and search domains, with an option to set the 'ndots' resolver option. Ensure the specified nameserver is configured to handle the redirection. ```yaml # values.yaml dnsPolicy: "None" dnsConfig: nameservers: - "10.96.0.100" # DNS server that redirects AI domains to proxy searches: - "svc.cluster.local" options: - name: ndots value: "2" ``` -------------------------------- ### Create New Language Translation Directory Source: https://github.com/danny-avila/librechat/blob/main/client/src/locales/README.md Create a new directory for the language code under `client/src/locales/` using `mkdir -p`. ```bash mkdir -p client/src/locales/[language-code] ``` -------------------------------- ### Configure LibreChat for TLS Source: https://github.com/danny-avila/librechat/blob/main/redis-config/README.md Update the .env file to point to the secure Redis URI and provide the CA certificate path. ```bash # .env file - TLS Redis with CA certificate validation USE_REDIS=true REDIS_URI=rediss://127.0.0.1:6380 REDIS_CA=/path/to/LibreChat/redis-config/certs/ca-cert.pem ``` -------------------------------- ### Run Mocked End-to-End Test Source: https://github.com/danny-avila/librechat/blob/main/e2e/README.md After capturing a workflow and moving recordings to the committed spec, run the finished spec using the mock profile. Replace `` with the actual spec file name. ```sh npm run e2e:mock -- ``` -------------------------------- ### Apply Environment Theme with ThemeProvider Source: https://github.com/danny-avila/librechat/blob/main/packages/client/src/theme/README.md Use ThemeProvider with a function that loads theme colors from environment variables. Supports initial theme setting. ```tsx ``` -------------------------------- ### Configure LibreChat for Redis Cluster Source: https://github.com/danny-avila/librechat/blob/main/redis-config/README.md Set environment variables in your .env file to use a 3-node Redis cluster. Ensure USE_REDIS is true and provide the URIs for all cluster nodes. ```bash USE_REDIS=true REDIS_URI=redis://127.0.0.1:7001,redis://127.0.0.1:7002,redis://127.0.0.1:7003 ``` -------------------------------- ### Direct Options for Recording Tests Source: https://github.com/danny-avila/librechat/blob/main/e2e/README.md These direct node commands offer granular control over the recording process, allowing specification of the URL, profile, output, and authentication. ```sh node e2e/setup/record.js --url=http://localhost:3080/c/new ``` ```sh node e2e/setup/record.js --profile=local --no-output ``` ```sh node e2e/setup/record.js --auth-only ``` ```sh node e2e/setup/record.js --output=e2e/recordings/settings-draft.spec.ts ``` -------------------------------- ### Implement Dynamic Theme Switching Source: https://github.com/danny-avila/librechat/blob/main/packages/client/src/theme/README.md Uses the ThemeProvider to toggle between light and dark themes based on component state. ```tsx import { ThemeProvider, defaultTheme, darkTheme } from '@librechat/client'; import { useState } from 'react'; function App() { const [isDark, setIsDark] = useState(false); return ( ); } ``` -------------------------------- ### Verify Nameserver Reachability Source: https://github.com/danny-avila/librechat/blob/main/helm/librechat/DNS_CONFIGURATION.md Executes a 'ping' command from within a pod to a specified nameserver IP address. This is a troubleshooting step to ensure the pod can reach the configured DNS servers. ```bash kubectl exec -- ping ``` -------------------------------- ### Record Local End-to-End Tests Source: https://github.com/danny-avila/librechat/blob/main/e2e/README.md Use this command to record tests using a real local LibreChat configuration instead of the mock profile. ```sh npm run e2e:record:local ``` -------------------------------- ### Configure Langfuse Environment Variables Source: https://github.com/danny-avila/librechat/blob/main/otel/langfuse-fanout/README.md Set these environment variables in your .env file to configure the central Langfuse destination and fanout gateway settings. Ensure LANGFUSE_BASE_URL and LANGFUSE_FANOUT_CENTRAL_BASE_URL are set to the same non-EU region when applicable. ```dotenv LANGFUSE_BASE_URL=https://cloud.langfuse.com LANGFUSE_FANOUT_CENTRAL_BASE_URL=https://cloud.langfuse.com LANGFUSE_FANOUT_CENTRAL_AUTH_HEADER=Basic LANGFUSE_FANOUT_TENANT_DESTINATIONS=eu=https://cloud.langfuse.com,us=https://us.cloud.langfuse.com,jp=https://jp.cloud.langfuse.com LANGFUSE_FANOUT_TRACE_DESTINATION_KEYS=eu,us,jp LANGFUSE_FANOUT_TENANT_EU_BASE_URL=https://cloud.langfuse.com LANGFUSE_FANOUT_TENANT_US_BASE_URL=https://us.cloud.langfuse.com LANGFUSE_FANOUT_TENANT_JP_BASE_URL=https://jp.cloud.langfuse.com LANGFUSE_FANOUT_TENANT_EXPORT_DISABLED=false LANGFUSE_FANOUT_UPSTREAM_TIMEOUT=30s LANGFUSE_FANOUT_PUBLIC_URL=http://langfuse-fanout-collector:4318 LANGFUSE_FANOUT_REDIS_URI=redis://langfuse-fanout-redis:6379 LANGFUSE_FANOUT_REDIS_USERNAME= LANGFUSE_FANOUT_REDIS_PASSWORD= LANGFUSE_FANOUT_REDIS_KEY_PREFIX=langfuse-fanout LANGFUSE_FANOUT_OTEL_RECEIVER_ENDPOINT=0.0.0.0:4319 LANGFUSE_FANOUT_METRICS_SECRET= LANGFUSE_FANOUT_MEMORY_LIMIT_MIB=256 LANGFUSE_FANOUT_MEMORY_SPIKE_LIMIT_MIB=64 LANGFUSE_FANOUT_BATCH_TIMEOUT=1s LANGFUSE_FANOUT_BATCH_SEND_SIZE=128 LANGFUSE_FANOUT_METADATA_CARDINALITY_LIMIT=1000 ``` -------------------------------- ### Optional Redis Configuration for LibreChat Source: https://github.com/danny-avila/librechat/blob/main/redis-config/README.md Configure optional Redis settings for LibreChat, including key prefixing, connection limits, ping intervals, and reconnection behavior. ```bash # Use environment variable for dynamic key prefixing REDIS_KEY_PREFIX_VAR=K_REVISION # Or set static prefix REDIS_KEY_PREFIX=librechat # Connection limits REDIS_MAX_LISTENERS=40 # Ping interval to keep connection alive (seconds, 0 to disable) REDIS_PING_INTERVAL=0 # Reconnection configuration REDIS_RETRY_MAX_DELAY=3000 # Max delay between reconnection attempts (ms) REDIS_RETRY_MAX_ATTEMPTS=10 # Max reconnection attempts (0 = infinite) REDIS_CONNECT_TIMEOUT=10000 # Connection timeout (ms) REDIS_ENABLE_OFFLINE_QUEUE=true # Queue commands when disconnected ``` -------------------------------- ### Enable Langfuse Fanout Gateway Source: https://github.com/danny-avila/librechat/blob/main/helm/librechat/readme.md Configure environment variables for the Langfuse fanout gateway. This enables media fanout and OpenTelemetry trace proxying. ```yaml librechat: configEnv: LANGFUSE_FANOUT_ENABLED: "true" LANGFUSE_FANOUT_COLLECTOR_URL: "http://localhost:4319/v1/traces" LANGFUSE_FANOUT_TENANT_EXPORT_DISABLED: "true" ``` -------------------------------- ### Apply Custom Theme with ThemeProvider Source: https://github.com/danny-avila/librechat/blob/main/packages/client/src/theme/README.md Wrap your application with ThemeProvider and pass your custom theme object and name. ```tsx import { ThemeProvider } from '@librechat/client'; import { customTheme } from './themes/custom'; function App() { return ( ); } ``` -------------------------------- ### Combine Host Aliases with DNS Configuration Source: https://github.com/danny-avila/librechat/blob/main/helm/librechat/DNS_CONFIGURATION.md Demonstrates how to use hostAliases in a Kubernetes deployment spec alongside DNS configuration. This allows for direct IP-to-hostname mappings for specific services, complementing the general DNS settings. ```yaml # In deployment spec (not directly in values.yaml) spec: dnsPolicy: "None" dnsConfig: nameservers: - "10.0.0.10" hostAliases: - ip: "10.100.50.200" hostnames: - "api.openai.com" ``` -------------------------------- ### Existing Components with ThemeContext (Migration) Source: https://github.com/danny-avila/librechat/blob/main/packages/client/src/theme/README.md Confirms that components using ThemeContext will continue to work without modifications after migration. ```tsx // This still works! const { theme, setTheme } = useContext(ThemeContext); ``` -------------------------------- ### Update ThemeProvider Usage (Migration) Source: https://github.com/danny-avila/librechat/blob/main/packages/client/src/theme/README.md Illustrates the updated usage of ThemeProvider, highlighting the addition of the optional themeRGB prop for custom colors. ```tsx ``` -------------------------------- ### Test DNS Resolution with nslookup Source: https://github.com/danny-avila/librechat/blob/main/helm/librechat/DNS_CONFIGURATION.md Executes the 'nslookup' command within a pod to test DNS resolution for a given domain. Replace '' with the actual name of your LibreChat pod. ```bash kubectl exec -- nslookup example.com ``` -------------------------------- ### Configure LibreChat for Standard Redis Source: https://github.com/danny-avila/librechat/blob/main/redis-config/README.md Configure LibreChat to use a standard Redis instance on the default port. Set USE_REDIS to true and provide the redis URI. ```bash USE_REDIS=true REDIS_URI=redis://127.0.0.1:6379 ``` -------------------------------- ### Scan and Generate Translations Source: https://github.com/danny-avila/librechat/blob/main/config/translations/README.md Execute the main translation scanning script using Bun. This script generates translation files for all supported languages. ```bash bun config/translations/scan.ts ``` -------------------------------- ### Check Pod DNS Configuration Source: https://github.com/danny-avila/librechat/blob/main/helm/librechat/DNS_CONFIGURATION.md Executes a command inside a running pod to display its DNS configuration file. This helps verify that the DNS settings applied via Helm are correctly reflected in the pod's resolv.conf. ```bash kubectl exec -- cat /etc/resolv.conf ``` -------------------------------- ### Create Empty Translation File Source: https://github.com/danny-avila/librechat/blob/main/client/src/locales/README.md Create an empty `translation.json` file within the newly created language directory. This file will be populated later. ```json { } ``` -------------------------------- ### Load Theme Colors from Environment Variables Source: https://github.com/danny-avila/librechat/blob/main/packages/client/src/theme/README.md A function to dynamically load theme colors from environment variables. Returns undefined if no theme variables are set, allowing default themes to be used. ```tsx function getThemeFromEnv(): IThemeRGB | undefined { // Check if any theme environment variables are set const hasThemeEnvVars = Object.keys(process.env).some(key => key.startsWith('REACT_APP_THEME_') ); if (!hasThemeEnvVars) { return undefined; // Use default themes } return { 'rgb-text-primary': process.env.REACT_APP_THEME_TEXT_PRIMARY || '33 33 33', 'rgb-brand-purple': process.env.REACT_APP_THEME_BRAND_PURPLE || '171 104 255', // ... other colors }; } ``` -------------------------------- ### Troubleshoot TLS Certificate Validation Source: https://github.com/danny-avila/librechat/blob/main/redis-config/README.md Inspect the server certificate to ensure Subject Alternative Names match the expected host. ```bash # If you see "Hostname/IP does not match certificate's altnames" # Check certificate SAN entries: openssl x509 -in certs/server-cert.pem -text -noout | grep -A3 "Subject Alternative Name" # Should show: DNS:localhost, IP Address:127.0.0.1 ``` -------------------------------- ### Test Standard Redis Connection Source: https://github.com/danny-avila/librechat/blob/main/redis-config/README.md Connect to the standard Redis instance on the default port 6379 and send a PING command to verify connectivity. ```bash # Connect to default Redis redis-cli ping ``` -------------------------------- ### Test TLS Connection Source: https://github.com/danny-avila/librechat/blob/main/redis-config/README.md Verify the TLS connection and basic operations using the redis-cli tool. ```bash # Test Redis TLS connection with CA certificate redis-cli --tls --cacert certs/ca-cert.pem -p 6380 ping # Should return: PONG # Test basic operations redis-cli --tls --cacert certs/ca-cert.pem -p 6380 set test_tls "TLS Working" redis-cli --tls --cacert certs/ca-cert.pem -p 6380 get test_tls ``` -------------------------------- ### Define Base CSS Variables Source: https://github.com/danny-avila/librechat/blob/main/packages/client/src/theme/README.md Set up CSS custom properties in your stylesheet to serve as fallbacks for light and dark modes. ```css /* style.css */ :root { --white: #fff; --gray-800: #212121; --gray-100: #ececec; /* ... other color definitions */ } html { --text-primary: var(--gray-800); --surface-primary: var(--white); /* ... other theme variables */ } .dark { --text-primary: var(--gray-100); --surface-primary: var(--gray-900); /* ... other dark theme variables */ } ``` -------------------------------- ### Configure Langfuse Fanout Service Annotations Source: https://github.com/danny-avila/librechat/blob/main/helm/librechat/readme.md Add annotations to the Langfuse fanout gateway service for cluster-internal discovery mechanisms, such as Prometheus scrape configurations. ```yaml langfuseFanout: service: annotations: prometheus.io/scrape: "true" prometheus.io/port: "9090" ``` -------------------------------- ### Backup Redis Cluster Nodes Source: https://github.com/danny-avila/librechat/blob/main/redis-config/README.md Trigger a background save on all nodes and copy the resulting RDB files to a backup directory. ```bash # Backup all nodes mkdir -p backup redis-cli -p 7001 BGSAVE redis-cli -p 7002 BGSAVE redis-cli -p 7003 BGSAVE # Copy backup files cp data/7001/dump.rdb backup/dump-7001.rdb cp data/7002/dump.rdb backup/dump-7002.rdb cp data/7003/dump.rdb backup/dump-7003.rdb ``` -------------------------------- ### Basic DNS Configuration Source: https://github.com/danny-avila/librechat/blob/main/helm/librechat/DNS_CONFIGURATION.md Sets the DNS policy to 'None' and specifies a custom DNS server IP. Ensure the DNS server is correctly configured for your network. ```yaml # values.yaml dnsPolicy: "None" dnsConfig: nameservers: - "10.0.0.10" # Custom DNS server ``` -------------------------------- ### Integrate ThemeProvider with Persistence Source: https://github.com/danny-avila/librechat/blob/main/packages/client/src/theme/README.md Configures the ThemeProvider to respect localStorage while allowing environment-based overrides. Note that passing props to ThemeProvider will override user-saved preferences on initial mount. ```tsx import { ThemeProvider } from '@librechat/client'; import { getThemeFromEnv } from './utils'; function App() { const envTheme = getThemeFromEnv(); return ( {/* Your app content */} ); } ``` -------------------------------- ### Configure LibreChat for TLS Redis Source: https://github.com/danny-avila/librechat/blob/main/redis-config/README.md Configure LibreChat to use a TLS-enabled Redis instance. Set USE_REDIS to true, specify the rediss URI, and provide the path to the CA certificate. ```bash USE_REDIS=true REDIS_URI=rediss://127.0.0.1:6380 REDIS_CA=/path/to/LibreChat/redis-config/certs/ca-cert.pem ``` -------------------------------- ### Troubleshoot TLS Connection Refused Source: https://github.com/danny-avila/librechat/blob/main/redis-config/README.md Check if the Redis TLS server is running and listening on the correct port. ```bash # Check if Redis TLS is running lsof -i :6380 # Check Redis TLS server logs ps aux | grep redis-server ``` -------------------------------- ### Dynamic Loading Screen Styling Source: https://github.com/danny-avila/librechat/blob/main/client/index.html Sets the background color of the loading container based on the user's selected theme (dark, light, or system). This ensures a consistent visual experience during initial page load. ```javascript html, body { margin: 0; padding: 0; height: 100%; } const theme = localStorage.getItem('color-theme'); const loadingContainerStyle = document.createElement('style'); let backgroundColor; if (theme === 'dark') { backgroundColor = '#0d0d0d'; } else if (theme === 'light') { backgroundColor = '#ffffff'; } else if (theme === 'system') { const prefersDarkScheme = window.matchMedia('(prefers-color-scheme: dark)').matches; backgroundColor = prefersDarkScheme ? '#0d0d0d' : '#ffffff'; } else { backgroundColor = '#ffffff'; } loadingContainerStyle.innerHTML = ` #loading-container { display: flex; align-items: center; justify-content: center; height: 100vh; background-color: ${backgroundColor}; } `; document.head.appendChild(loadingContainerStyle); ``` -------------------------------- ### Configure Langfuse Fanout Redis URI Source: https://github.com/danny-avila/librechat/blob/main/helm/librechat/readme.md Specify the Redis URI for the Langfuse fanout gateway to manage media upload plans. Alternatively, enable the bundled Redis chart. ```yaml langfuseFanout: redis: uri: "redis://localhost:6379" ``` -------------------------------- ### Retrieve LibreChat Application URL Source: https://github.com/danny-avila/librechat/blob/main/helm/librechat/templates/NOTES.txt Use these Helm template commands to identify the correct access URL for your specific Kubernetes service type. ```yaml {{- if .Values.ingress.enabled }} {{- range $host := .Values.ingress.hosts }} {{- range .paths }} http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} {{- end }} {{- end }} {{- else if contains "NodePort" .Values.service.type }} export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "librechat.fullname" . }}) export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") echo http://$NODE_IP:$NODE_PORT {{- else if contains "LoadBalancer" .Values.service.type }} NOTE: It may take a few minutes for the LoadBalancer IP to be available. You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "librechat.fullname" . }}' export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "librechat.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") echo http://$SERVICE_IP:{{ .Values.service.port }} {{- else if contains "ClusterIP" .Values.service.type }} export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "librechat.fullname" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") echo "Visit http://127.0.0.1:8080 to use your application" kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT {{- end }} ``` -------------------------------- ### Create New Entity Schema Source: https://github.com/danny-avila/librechat/blob/main/packages/data-schemas/README.md Template for creating a new entity schema definition. ```typescript import { Schema } from 'mongoose'; import type { IEntityName } from '~/types'; const entityNameSchema = new Schema( { fieldName: { type: String, required: true }, // ... other fields }, { timestamps: true } ); export default entityNameSchema; ``` -------------------------------- ### Update ThemeProvider Imports (Migration) Source: https://github.com/danny-avila/librechat/blob/main/packages/client/src/theme/README.md Shows the change in import path for ThemeProvider when migrating from an older version. ```tsx // Before: // import { ThemeContext, ThemeProvider } from '~/hooks/ThemeContext'; // After: import { ThemeContext, ThemeProvider } from '@librechat/client'; ``` -------------------------------- ### Create Database Methods Source: https://github.com/danny-avila/librechat/blob/main/packages/data-schemas/README.md Define entity-specific database operations using Mongoose models. ```typescript import type { Model, Types } from 'mongoose'; import type { IEntityName } from '~/types'; export function createEntityNameMethods(mongoose: typeof import('mongoose')) { async function findEntityById(id: string | Types.ObjectId): Promise { const EntityName = mongoose.models.EntityName as Model; return await EntityName.findById(id).lean(); } // ... other methods return { findEntityById, // ... other methods }; } export type EntityNameMethods = ReturnType; ``` -------------------------------- ### Define Environment Variables for Theme Colors Source: https://github.com/danny-avila/librechat/blob/main/packages/client/src/theme/README.md Set theme colors using environment variables prefixed with REACT_APP_THEME_. ```env # .env.local REACT_APP_THEME_BRAND_PURPLE=171 104 255 REACT_APP_THEME_TEXT_PRIMARY=33 33 33 REACT_APP_THEME_TEXT_SECONDARY=66 66 66 REACT_APP_THEME_SURFACE_PRIMARY=255 255 255 REACT_APP_THEME_SURFACE_SUBMIT=4 120 87 ``` -------------------------------- ### Configure Admin Panel SSO URL Source: https://github.com/danny-avila/librechat/blob/main/helm/librechat/readme.md Set the base URL for the admin panel to enable OAuth/SSO redirects. This URL should not end with a trailing slash as LibreChat appends callback paths. ```yaml librechat: adminPanelUrl: https://admin.example.com/admin ``` -------------------------------- ### Configure Tailwind CSS Source: https://github.com/danny-avila/librechat/blob/main/packages/client/src/theme/README.md Map CSS variables to Tailwind utility classes within the tailwind.config.js file. ```js module.exports = { content: [ './src/**/*.{js,jsx,ts,tsx}', // Include component library files './node_modules/@librechat/client/dist/**/*.js', ], darkMode: ['class'], theme: { extend: { colors: { // Map CSS variables to Tailwind colors 'text-primary': 'var(--text-primary)', 'surface-primary': 'var(--surface-primary)', 'brand-purple': 'var(--brand-purple)', // ... other colors }, }, }, }; ``` -------------------------------- ### Register Methods in Index Source: https://github.com/danny-avila/librechat/blob/main/packages/data-schemas/README.md Import methods and update the methods index and AllMethods type definition. ```typescript import { createEntityNameMethods, type EntityNameMethods } from './entityName'; ``` ```typescript ...createEntityNameMethods(mongoose), ``` ```typescript export type AllMethods = UserMethods & // ... other methods EntityNameMethods; ``` -------------------------------- ### Restore Redis Backup Files Source: https://github.com/danny-avila/librechat/blob/main/redis-config/README.md Copy backup dump files to their designated data directories. Ensure the backup files and target directories exist. ```bash cp backup/dump-7001.rdb data/7001/dump.rdb cp backup/dump-7002.rdb data/7002/dump.rdb cp backup/dump-7003.rdb data/7003/dump.rdb ``` -------------------------------- ### Implement Database Methods Source: https://github.com/danny-avila/librechat/blob/main/packages/data-schemas/README.md Encapsulates CRUD operations and entity-specific queries within a factory function. ```typescript import type { Model } from 'mongoose'; import type { IUser } from '~/types'; export function createUserMethods(mongoose: typeof import('mongoose')) { async function findUserById(userId: string): Promise { const User = mongoose.models.User as Model; return await User.findById(userId).lean(); } async function createUser(userData: Partial): Promise { const User = mongoose.models.User as Model; return await User.create(userData); } return { findUserById, createUser, // ... other methods }; } export type UserMethods = ReturnType; ``` -------------------------------- ### Import IThemeRGB Interface for TypeScript Source: https://github.com/danny-avila/librechat/blob/main/packages/client/src/theme/README.md Shows how to import the IThemeRGB interface for correct TypeScript type definitions when defining themes. ```tsx import { IThemeRGB } from '@librechat/client'; ``` -------------------------------- ### Export New Entity Type Source: https://github.com/danny-avila/librechat/blob/main/packages/data-schemas/README.md Add the new entity type to the types index file. ```typescript export * from './entityName'; ``` -------------------------------- ### Import and Add New Translation File to i18n Configuration Source: https://github.com/danny-avila/librechat/blob/main/client/src/locales/README.md Update `client/src/locales/i18n.ts` by importing the new translation file and adding it to the `resources` object. Ensure the language code matches the file path. ```typescript import translationLanguageCode from './language-code/translation.json'; ``` ```typescript export const resources = { // ... existing languages 'language-code': { translation: translationLanguageCode }, } as const; ``` ```typescript import translationBo from './bo/translation.json'; import translationUk from './uk/translation.json'; export const resources = { // ... existing languages bo: { translation: translationBo }, uk: { translation: translationUk }, } as const; ``` -------------------------------- ### Admin OAuth/OpenID Callback URL Source: https://github.com/danny-avila/librechat/blob/main/helm/librechat/readme.md Register this URL with your identity provider for OpenID SSO. It serves as the callback endpoint for authentication. ```text https:///api/admin/oauth/openid/callback ``` -------------------------------- ### Create New Model Factory Source: https://github.com/danny-avila/librechat/blob/main/packages/data-schemas/README.md Template for creating a new model factory function. ```typescript import entityNameSchema from '~/schema/entityName'; import type * as t from '~/types'; export function createEntityNameModel(mongoose: typeof import('mongoose')) { return ( mongoose.models.EntityName || mongoose.model('EntityName', entityNameSchema) ); } ``` -------------------------------- ### Configure Compound Indexes Source: https://github.com/danny-avila/librechat/blob/main/packages/data-schemas/README.md Define indexes on the schema for query performance optimization. ```typescript schema.index({ field1: 1, field2: 1 }); schema.index( { uniqueField: 1 }, { unique: true, partialFilterExpression: { uniqueField: { $exists: true } } } ); ``` -------------------------------- ### Create Model Factory Function Source: https://github.com/danny-avila/librechat/blob/main/packages/data-schemas/README.md Implements a singleton pattern to create or retrieve a Mongoose model. ```typescript import userSchema from '~/schema/user'; import type * as t from '~/types'; export function createUserModel(mongoose: typeof import('mongoose')) { return mongoose.models.User || mongoose.model('User', userSchema); } ``` -------------------------------- ### Register Model in Index Source: https://github.com/danny-avila/librechat/blob/main/packages/data-schemas/README.md Import the factory function and add the model to the createModels return object. ```typescript import { createEntityNameModel } from './entityName'; ``` ```typescript EntityName: createEntityNameModel(mongoose), ``` -------------------------------- ### Check Pod DNS Policy Source: https://github.com/danny-avila/librechat/blob/main/helm/librechat/DNS_CONFIGURATION.md Retrieves the YAML definition of a pod and filters for the 'dnsPolicy' field. This command helps in troubleshooting to confirm the DNS policy applied to a specific pod. ```bash kubectl get pod -o yaml | grep -A5 dnsPolicy ```