-
Notifications
You must be signed in to change notification settings - Fork 13.2k
SvelteKit-based WebUI #14839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SvelteKit-based WebUI #14839
Conversation
what is reason to change from react -> svelte? Would it be better just to improve UI with react? |
Introduces the ability to send and display attachments within the chat interface. This includes: - A new `ChatAttachmentsList` component to display attachments in both the `ChatForm` (pending uploads) and `ChatMessage` (stored attachments). - Updates to `ChatForm` to handle file uploads and display previews. - Updates to `ChatMessage` to display stored attachments. - Logic to convert uploaded files to a format suitable for storage and transmission.
Improves code organization and reusability by introducing separate components for displaying image and file attachments in the chat interface. This change simplifies the ChatAttachmentsList component and enhances the maintainability of the codebase.
Adds support for pasting files and converting long text to files. Enhances file upload capabilities to handle pasted files directly from the clipboard. Implements a feature that converts lengthy pasted text into a text file if it exceeds a configurable length. Also enhances file processing to read text file content and prevent binary files from being processed.
Implements file attachment previews in the chat interface, including support for text file previews with truncated display and remove functionality. Improves the display of image attachments. Text file detection is enhanced using filename extensions.
Refactors the chat form to handle file uploads more robustly. - Changes `onSend` to be an async function that returns a boolean to indicate the success of sending the message. This allows for validation before clearing the message and uploaded files. - Adds client-side validation for WebP images to avoid server-side errors. - Moves text file utility functions and constants to dedicated files and utils. - Fixes a bug where chat messages were not being cleared after sending.
Ensures that SVG images are converted to PNG format before being stored in the database and displayed in the chat interface. This improves compatibility with systems that may not fully support SVG rendering and addresses potential security concerns related to SVG files. Handles cases where SVG to PNG conversion fails gracefully, preventing application errors.
Enables displaying PDF files in the chat interface. This commit introduces the `pdfjs-dist` library to process PDFs, extracting text content for display. It also includes functionality to potentially convert PDF pages into images, allowing preview of PDF documents. The changes enhance the chat functionality by allowing add PDF attachments to the chat. Currently only supports converting PDFs to text.
Adds a dialog for previewing attachments, including images, text, PDFs, and audio files. This change enhances the user experience by allowing users to view attachments in a larger, more detailed format before downloading or interacting with them. It introduces a new component, `ChatAttachmentPreviewDialog.svelte`, and updates the `ChatAttachmentsList.svelte` and `ChatAttachmentImagePreview.svelte` components to trigger the dialog.
Enhances the chat interface with several UI improvements: - Adds backdrop blur to the chat form for better visual separation. - Makes the chat header background transparent on larger screens and introduces a blur effect. - Adjusts the maximum width of filenames in attachment previews for better responsiveness. - Fixes sidebar interaction on mobile, ensuring it closes after item selection. - Adjusts input field styling.
Sets the focus to the textarea element when the component mounts and after the loading state changes from true to false. This improves user experience by automatically placing the cursor in the input field, allowing users to start typing immediately.
Updates the timestamp format in chat messages to display hours and minutes in a more user-friendly manner. This improves the readability and clarity of the message timestamps, making it easier for users to quickly understand when a message was sent.
Refactors the directory structure by moving chat-related components to a dedicated "app" directory. This change improves organization and maintainability by grouping components based on their function within the application.
Refactors server properties to align with the new API structure. Changes how context length is accessed. Adds conditional rendering based on model availability.
Implements a check to ensure the message content and history do not exceed the model's context window limits. This prevents errors and improves the user experience by displaying an informative alert dialog when the context length would be exceeded, suggesting ways to shorten the message or start a new conversation. Also adds a method to clear the context error.
Hey! Yes, we will add it in near future 😄 |
I think close to 100. I tried to delete a few of them, but the issue persists. Btw, is there a way to access the data for the conversations using the browser developer console? I looked in |
Okay, I will check that. And you can access data from IndexedDB |
@easyfab this is not possible (yet), but this should be a very straightforward change, I will create a PR with this enhancement and let you know here as well ;) |
@allozaur Forwarding from someone else Regarding the keyboard shortcuts, some are already used by browsers:
https://support.mozilla.org/en-US/kb/keyboard-shortcuts-perform-firefox-tasks-quickly |
Hey @O-J1, thanks for your feedback. Generally, the thing with keyboard shortcuts for web apps is that just few of shortcuts that are intuitive are not taken by somme browser feature... As it goes for the ones that you listed above:
We are not using this one. For new chat we are using
For Firefox it's actually I think that these are relatively rare use cases for Chromium/Gecko browsers and it's okay to override default behaviour for this shortcut as deleting conversations can come handier when working with multiple convos. Otherwise, if you have suggestions for better alternative, I am all ears (and eyes) 😉
Cmd/Ctrl + K is one of the most popular shortcuts to open search in multuple web apps (GitHub included), so i really wouldn't consider changing this one.
This shortcut is used by default for ShadCN sidebar component, I am not sure if it is that crucial to disable it to allow opening/closing bookmarks. If you think there are solid arguments behind it, of course let's then consider removing it. Generally, I think that the best would be to continue this discussion in a separate GH issue, so feel free to open one and let's discuss the shortcuts more in detail over there 😄 |
|
@ggerganov i wasn't able to reproduce this issue so far... can you please create a separate issue and ideally attach a video recording and/or screenshots from the browser console and webui? |
Hello, the thought process is not displayed in the new Web UI. Neither enabling nor disabling "Show thought in progress" works, the chat screen just shows "Processing..." and ticking content tokens until the model starts outputting the result. How do I expand the model thinking window? |
Hi, are u using |
this broke llama-swap upstream chat |
Hey, this is already being handled with: |
This broke being able to serve the chat ui on a non-root path, e.g: http://[server]/[path-to-chat]/ I use this in Mmojo Server (fork of llama.cpp) to serve a completion UI as default and the chat UI as an option. https://github.com/BradHutchings/Mmojo-Server I've tried patching this new UI up, but it's beyond my expertise. It seems like you'd have to design an alternate path in somehow. |
Same issue as @BradHutchings The apache2 config I was using and which is now broken is:
|
@d-a-v If you haven't figured it out, you can roll back the webui as described here: This is what I'm doing now until the issue is fixed. But I bet you have that figured out 🤣. -Brad
|
Can you please create an issue with reproduction steps and screenshots/code snippets? I will be more than happy to address this, but I need more context and some examples to start working on a fix. Edit: Nevermind, just saw the issue. Will let u know with the updates on this. |
@allozaur I really appreciate you taking a look at this. Thank you. |
Overview
This PR introduces a complete rewrite of the llama.cpp web interface, migrating from a React-based implementation to a modern SvelteKit architecture. The new implementation provides significant improvements in user experience, developer tooling, and feature capabilities while maintaining full compatibility with the llama.cpp server API.
🚀 Tech Stack Upgrade
Why Svelte 5 + SvelteKit Over React
Framework Changes
Development Tooling
🏗️ Architecture Modernization
Component Architecture
Components are designed with single responsibilities and clear boundaries, making them highly testable and reusable. The application components handle feature-specific logic while UI components provide consistent design patterns across the entire interface.
src/lib/components/app/
): specialized components focused on specific featuressrc/lib/components/ui/
): ShadCN components providing design primitives like buttons, dialogs, dropdowns, and form elementsSee example
Before (React - Monolithic Component):
After (Svelte - Modular Components):
State Management
Stores act as the application's orchestration layer, coordinating between services and managing reactive state with Svelte 5 runes. They handle complex business logic like conversation branching, streaming responses, and persistent data synchronization.
See example
Before (React Context with boilerplate):
After (Svelte Runes - minimal boilerplate):
Service Layer
Services provide stateless, pure functions for external communication and complex operations, completely separated from UI concerns. They handle HTTP requests, real-time monitoring, and data transformations while remaining easily testable.
See example
Before (React - Mixed concerns in components):
After (Svelte - Clean service separation):
Utilities & Hooks
Utilities contain framework-agnostic helper functions while hooks encapsulate reusable stateful logic patterns. Both are designed to be pure and testable in isolation from the rest of the application.
src/lib/utils/
): fileProcessing.ts, pdfProcessing.ts, thinking.ts, branching.ts - 13 modules for file handling, content processing, and data manipulationsrc/lib/hooks/
): useFileUpload.svelte.ts, useProcessingState.svelte.ts - Composables for file upload state and processing status managementSee example
**Before (React - Inline file processing):** ```typescript const useChatExtraContext = () => { const processFiles = async (files) => { const processedFiles = []; for (const file of files) { if (file.type.startsWith('image/')) { const base64 = await convertToBase64(file); processedFiles.push({ type: 'image', data: base64 }); } else if (file.type === 'application/pdf') { // Inline PDF processing logic... } // More inline processing... } return processedFiles; }; }; ```After (Svelte - Modular utilities and hooks):
Type System
The type system defines clear contracts between all layers and prevents runtime errors through compile-time checking. It enables confident refactoring and provides excellent developer experience with IntelliSense support.
See example
Before (React - Loose typing):
After (Svelte - Comprehensive type system):
Dependency Flow
Components → Stores → Services → API: The unidirectional flow ensures predictable data flow and easier debugging. Stores orchestrate business logic while keeping components focused purely on presentation, and services handle all external communication.
✨ Feature Enhancements
File Handling
Advanced Chat Features
Ctrl+Shift+N
: Start new conversationCtrl+Shift+D
: Delete current conversationCtrl+K
: Focus search conversationsCtrl+V
: Paste files and content to conversationCtrl+B
: Toggle sidebarEnter
: Send messageShift+Enter
: New line in messageServer Integration
reasoning_content
and slots endpoint support🎨 User Experience Improvements
Interface Design
Interaction Patterns
Feedback & Communication
🛠️ Developer Experience Improvements
Code Organization
Development Workflow
Testing Infrastructure
Code Quality
Debugging & Monitoring
📊 Database Schema Updates
Modern Conversation Structure
Enhanced Features
🧪 Testing Infrastructure
Comprehensive Testing Strategy
Development Experience
📈 Performance & Build Improvements
Build Optimization
Runtime Performance
🔄 Migration Benefits
Maintainability
Performance
🚦 Breaking Changes
📝 Migration Notes
The new implementation maintains full API compatibility while providing significant enhancements. The database schema automatically migrates existing conversations to the new branching structure. All existing functionality is preserved while adding extensive new capabilities.