mirror of
https://github.com/LibreChat-AI/librechat.ai.git
synced 2026-03-27 10:48:32 +07:00
* feat: enhance accessibility and improve component structure across various files * feat: enhance components with TypeScript typings and improve documentation - Added TypeScript interface for Screenshot component props. - Updated button component documentation for clarity. - Removed unnecessary console log in ContainerScroll component. - Added descriptive comments for FloatingDock and utility functions. - Improved CSP headers in next.config.mjs for security. - Cleaned up package.json by removing unused dependencies. - Refactored _app.tsx to use AppProps for type safety. - Updated meta configuration by removing hidden display property. - Added API documentation comments for GitHub stats and subscription endpoints. - Enhanced error handling in subscription API. - Updated Tailwind CSS configuration with detailed comments. - Cleaned up style.css by organizing and refining styles. - Updated tsconfig.json to include TypeScript files for API routes. - Added comments to Subscriber model and dbConnect utility for clarity. * feat: add aria-labels to HeroLinks for improved accessibility * feat: replace Twitter icon with X and add new X icon component * chore: update code structure for better readability and maintenance * chore: update .gitignore to include additional AI assistant files and Claude Flow generated files * feat: replace sidebar emojis with Lucide icons, fix duplicate titles, and clean up codebase - Add icon resolver (lib/icons.tsx) with 73 Lucide React icons mapped to string IDs - Wire icon resolver into Fumadocs loader for automatic sidebar icon rendering - Update all 19 meta.json files to use icon field instead of emoji prefixes - Add icon frontmatter to all 162 MDX documentation pages - Deduplicate adjacent sidebar icons (e.g. Search/ListFilter, Brain/Bookmark) - Remove duplicate H1 headings from 154 MDX files (DocsTitle renders frontmatter) - Add frontmatter to 33 files that were missing it - Shorten overly long titles (agents, mcp, url_query) - Rewrite /docs/local cards from old Nextra syntax to Fumadocs Card components - Remove all emojis from Get Started and Features index pages - Collapse sidebar folders by default (defaultOpenLevel: 0) - Delete temporary debugging scripts, test specs, and screenshot artifacts - Fix eslint errors in mdx-components, nextra-shims, tailwind config, and error page - Update .gitignore to exclude test/debug artifacts * feat: enhance accessibility and improve UI components - Added aria-hidden attributes to social media icons in FooterMenu for better accessibility. - Updated FooterMenu to use <footer> element for semantic HTML. - Improved Carousel component by adding aria-labels to navigation buttons for better screen reader support. - Modified OptionTable to use a unique key for each row to prevent rendering issues. - Enhanced CredentialsGeneratorBox with aria-labels for input fields and buttons to improve accessibility. - Updated documentation to remove unnecessary links and improve clarity in various sections. - Fixed iframe attributes in documentation for better compatibility and accessibility. - Adjusted CSS variable for muted foreground color to improve contrast. - Updated package.json and pnpm-lock.yaml for dependency management and optimization. * feat: update FileComponent and FolderComponent to include new props for enhanced functionality * Add new AI provider icons and update documentation - Introduced new SVG icons for AI providers: TogetherAI, TrueFoundry, VLLM, Vultr, and XAI. - Updated existing AI endpoint documentation to reflect new icon names and improve clarity. - Replaced generic \Plug\ icons with specific provider icons for Anyscale, APIpie, Cloudflare, Cohere, Databricks, DeepSeek, Fireworks, Groq, Helicone, HuggingFace, LiteLLM, Mistral, MLX, Moonshot, NeuroChain, Ollama, OpenRouter, Perplexity, Portkey, ShuttleAI, and TrueFoundry. - Enhanced the icon resolution logic to include new icons in the icon registry. * feat: add DocsHub and QuickStartHub components for enhanced documentation navigation * feat: implement FeaturesHub component for enhanced feature navigation and update ViewOptions for improved links * feat: add fresh-build script for streamlined project setup and development * fix: update ESLint configuration and improve type handling in components - Added 'next.config.mjs' to ESLint ignore list. - Refactored version assignment in ChangelogPage for better type safety. - Removed unnecessary type casting in Author components for cleaner code. - Simplified BlogHeader component by removing redundant type assertions. - Added eslint-disable comments for unused variables in CardCompat and Nextra shims. * fix: update ViewOptions link for LibreChat to remove unnecessary submit parameter * feat: enhance HomePage layout and improve GitHub star display - Integrated HomeLayout component for better page structure. - Updated HeroSection to improve the presentation of GitHub stars with a new layout and styling. - Adjusted link attributes for better accessibility and user experience. * refactor: simplify title for Model Context Protocol (MCP) documentation - Changed the title from "Model Context Protocol (MCP)" to "MCP" for brevity. - Updated the description to clarify how LibreChat utilizes MCP for integration with external tools and services. * feat: enhance navigation styling and update HomeLayout props - Added a new background style for the navigation bar with a blur effect. - Updated HomeLayout component to include a transparent navigation mode for improved visual integration. * refactor: deprecate plugins in favor of agents and update related documentation - Removed references to plugins across various files, including the FeaturesHub and documentation. - Updated navigation redirects to point to agents instead of plugins. - Deleted the plugins documentation file to streamline content and reduce confusion. * feat: update demo images for improved visual representation --------- Co-authored-by: Danny Avila <danny@librechat.ai>
177 lines
6.9 KiB
Plaintext
177 lines
6.9 KiB
Plaintext
---
|
|
title: Resumable Streams
|
|
icon: Zap
|
|
description: Never lose an AI response—seamless reconnection, multi-tab sync, and horizontal scaling for production deployments
|
|
---
|
|
|
|
LibreChat features a resilient streaming architecture that ensures you never lose AI-generated content. Whether your connection drops, you switch tabs, or you pick up on another device, your responses are always preserved and synchronized.
|
|
|
|
## Why It Matters
|
|
|
|
Traditional chat applications lose all streaming content when your connection drops. With resumable streams, LibreChat:
|
|
|
|
- **Preserves every response** — Network hiccups, browser refreshes, or server restarts won't cause data loss
|
|
- **Keeps multiple tabs in sync** — Open the same conversation in two browser tabs and watch them update together in real-time
|
|
- **Enables seamless device switching** — Start a conversation on your desktop and continue on your phone
|
|
- **Lets you multitask freely** — Start a generation, browse other tabs, and come back to a complete response
|
|
|
|
## How It Works
|
|
|
|
When you send a message to an AI model, LibreChat creates a generation job that tracks all streamed content. The magic happens when something interrupts your connection:
|
|
|
|
1. **Automatic detection** — The client detects the disconnection instantly
|
|
2. **State reconstruction** — Upon reconnecting, the server rebuilds all previously streamed content
|
|
3. **Seamless sync** — Missing content is delivered via a sync event
|
|
4. **Transparent continuation** — Streaming resumes from the current position
|
|
|
|
This all happens automatically—no user action required.
|
|
|
|
### Multi-Tab & Multi-Device Experience
|
|
|
|
One of the most powerful aspects of resumable streams is **real-time synchronization**:
|
|
|
|
- **Same chat, multiple windows** — Open a conversation in two browser tabs and both receive updates simultaneously
|
|
- **Cross-device continuity** — Start a long generation on your laptop, then check the result on your phone
|
|
- **Team collaboration** — In shared conversations, all viewers see content appear in real-time
|
|
|
|
## Deployment Modes
|
|
|
|
LibreChat supports two deployment configurations:
|
|
|
|
### Single-Instance Mode (Default)
|
|
|
|
Uses in-memory storage with Node.js `EventEmitter` for pub/sub. Perfect for:
|
|
- Local development
|
|
- Single-server deployments
|
|
- Docker Compose setups
|
|
|
|
**No configuration required** — Works out of the box.
|
|
|
|
### Redis Mode (Production)
|
|
|
|
Uses Redis Streams and Pub/Sub for cross-instance communication. Essential for:
|
|
- Horizontally scaled deployments
|
|
- Load-balanced production environments
|
|
- High-availability setups
|
|
- Kubernetes clusters
|
|
|
|
With Redis mode, a user can start a generation on one server instance and seamlessly resume on another—perfect for rolling deployments and auto-scaling.
|
|
|
|
**Note:** If you only run a single LibreChat instance, Redis for resumable streams is typically unnecessary—the in-memory mode handles everything. Redis becomes valuable when you have multiple LibreChat instances behind a load balancer. That said, Redis is still useful for other features like caching and session storage even in single-instance deployments.
|
|
|
|
## Configuration
|
|
|
|
### Enabling Redis Streams
|
|
|
|
When Redis is enabled (`USE_REDIS=true`), resumable streams automatically use Redis. You can also explicitly enable it:
|
|
|
|
```bash filename=".env"
|
|
USE_REDIS=true
|
|
REDIS_URI=redis://localhost:6379
|
|
# Resumable streams will use Redis automatically when USE_REDIS=true
|
|
# To explicitly control it:
|
|
USE_REDIS_STREAMS=true
|
|
```
|
|
|
|
### Redis Cluster Support
|
|
|
|
For Redis Cluster deployments:
|
|
|
|
```bash filename=".env"
|
|
USE_REDIS_STREAMS=true
|
|
USE_REDIS_CLUSTER=true
|
|
REDIS_URI=redis://node1:7001,redis://node2:7002,redis://node3:7003
|
|
```
|
|
|
|
LibreChat automatically uses hash-tagged keys to ensure multi-key operations stay within the same cluster slot.
|
|
|
|
## Use Cases
|
|
|
|
### Unstable Networks
|
|
On spotty WiFi or cellular connections, responses automatically resume when connectivity returns. No need to re-send your prompt.
|
|
|
|
### Mobile Users
|
|
Switch from WiFi to cellular (or vice versa) without losing your response. The stream picks up exactly where it left off.
|
|
|
|
### Long-Running Generations
|
|
For complex prompts that generate lengthy responses, feel free to check other tabs or apps. Your response will be waiting when you return.
|
|
|
|
### Multi-Device Workflows
|
|
Start a conversation on your work computer, commute home, and check the result on your phone—the full response is there.
|
|
|
|
### Production Deployments
|
|
Scale horizontally across multiple server instances while maintaining stream continuity. Rolling deployments won't interrupt active generations.
|
|
|
|
## Technical Details
|
|
|
|
### Content Reconstruction
|
|
|
|
The system aggregates all streamed delta events to rebuild:
|
|
- Message content (text, tool calls, citations)
|
|
- Agent run steps and intermediate reasoning
|
|
- Metadata and state information
|
|
|
|
### Performance Optimizations
|
|
|
|
**Memory-first approach**: When reconnecting to the same server instance, LibreChat uses local cache for zero-latency content recovery, avoiding unnecessary Redis round trips.
|
|
|
|
**Automatic cleanup**: Stale job entries are removed during queries to prevent memory leaks. Completed streams expire automatically.
|
|
|
|
**Efficient storage**: In-memory mode uses `WeakRef` for graph storage, enabling automatic garbage collection when conversations end.
|
|
|
|
### Data Flow
|
|
|
|
| Component | Storage Mechanism |
|
|
|-----------|-------------------|
|
|
| Chunks | Redis Streams (`XADD`/`XRANGE`) |
|
|
| Job metadata | Redis Hash structures |
|
|
| Real-time events | Redis Pub/Sub channels |
|
|
| Expiration | Automatic TTL after stream completion |
|
|
|
|
## Testing Resumable Streams
|
|
|
|
You can verify the feature is working:
|
|
|
|
1. Start a streaming conversation with any AI model
|
|
2. **Tab test**: Open the same chat in a new browser tab—both should sync
|
|
3. **Disconnect test**: Turn off your network briefly, then reconnect
|
|
4. **Navigation test**: Navigate away mid-stream, then return
|
|
|
|
In all cases, you should see the complete response with no data loss.
|
|
|
|
## Troubleshooting
|
|
|
|
### Streams not resuming?
|
|
|
|
**Check Redis connectivity:**
|
|
```bash
|
|
docker exec -it librechat-redis redis-cli ping
|
|
# Should return: PONG
|
|
```
|
|
|
|
**Verify environment variables:**
|
|
```bash
|
|
# Ensure USE_REDIS_STREAMS is set
|
|
echo $USE_REDIS_STREAMS
|
|
```
|
|
|
|
### Content appears duplicated?
|
|
|
|
This typically indicates a client version mismatch. Ensure you're running the latest version of LibreChat.
|
|
|
|
### High memory usage in single-instance mode?
|
|
|
|
Completed streams are automatically garbage collected. If you're seeing high memory usage, check for:
|
|
- Very long-running streams that haven't completed
|
|
- Streams that errored without proper cleanup
|
|
|
|
## Related Documentation
|
|
|
|
- [Redis Configuration](/docs/configuration/redis) — Setting up Redis for caching and horizontal scaling
|
|
- [Agents](/docs/features/agents) — AI agents with tool use capabilities
|
|
- [Docker Deployment](/docs/local/docker) — Container-based deployment guide
|
|
|
|
---
|
|
|
|
For implementation details, see [PR #10926](https://github.com/danny-avila/LibreChat/pull/10926).
|