Update package.json

This commit is contained in:
karl 2025-06-22 12:04:21 +08:00
parent 8a15949b84
commit b19dda393b
13 changed files with 897 additions and 216 deletions

Binary file not shown.

View File

@ -0,0 +1,68 @@
# Code Structure and Organization
## Backend Structure (`backend/open_webui/`)
- **`main.py`**: Main FastAPI application entry point
- **`config.py`**: Configuration management and environment variables
- **`env.py`**: Environment setup and constants
- **`constants.py`**: Application constants and message templates
- **`functions.py`**: Function execution and management
- **`tasks.py`**: Background task management
## Router Organization (`backend/open_webui/routers/`)
Each router handles a specific domain:
- **`auths.py`**: Authentication and authorization
- **`users.py`**: User management
- **`chats.py`**: Chat conversations
- **`models.py`**: AI model management
- **`prompts.py`**: Prompt templates
- **`tools.py`**: Tool management
- **`functions.py`**: Function management
- **`files.py`**: File upload/management
- **`images.py`**: Image generation
- **`audio.py`**: Speech-to-text and text-to-speech
- **`retrieval.py`**: RAG and document processing
- **`memories.py`**: Memory management
- **`knowledge.py`**: Knowledge base management
- **`ollama.py`**: Ollama integration
- **`openai.py`**: OpenAI API integration
- **`pipelines.py`**: Pipeline management
- **`configs.py`**: Configuration management
## Database Models (`backend/open_webui/models/`)
- **`users.py`**: User model and settings
- **`chats.py`**: Chat conversations
- **`models.py`**: AI model definitions
- **`files.py`**: File metadata
- **`auths.py`**: Authentication data
- **`prompts.py`**: Prompt templates
- **`tools.py`**: Tool definitions
- **`functions.py`**: Function definitions
- **`memories.py`**: Memory storage
- **`knowledge.py`**: Knowledge base
- **`channels.py`**: Communication channels
- **`folders.py`**: Organization folders
- **`feedbacks.py`**: User feedback
## Frontend Structure (`src/`)
- **`app.html`**: Main HTML template
- **`app.css`**: Global styles
- **`lib/`**: Reusable components and utilities
- **`routes/`**: SvelteKit page routes
## Utilities (`backend/open_webui/utils/`)
- **`auth.py`**: Authentication utilities
- **`misc.py`**: General utilities
- **`models.py`**: Model utilities
- **`chat.py`**: Chat processing
- **`middleware.py`**: Request/response processing
- **`tools.py`**: Tool execution
- **`embeddings.py`**: Embedding generation
- **`code_interpreter.py`**: Code execution
- **`filter.py`**: Content filtering
- **`plugin.py`**: Plugin management

View File

@ -0,0 +1,66 @@
# Code Style and Conventions
## Python Backend Style
- **Formatter**: Black with default settings
- **Linter**: Pylint
- **Type Hints**: Strongly encouraged, especially for function signatures
- **Docstrings**: Use for public APIs and complex functions
- **Import Organization**: Follow PEP 8 standards
- **Variable Naming**: snake_case for variables and functions, PascalCase for classes
- **Constants**: UPPER_CASE for module-level constants
## Code Quality Standards
- **Line Length**: Black default (88 characters)
- **String Quotes**: Black will standardize (double quotes preferred)
- **Trailing Commas**: Black handles automatically
- **Function Organization**: Keep functions focused and single-purpose
- **Error Handling**: Use proper exception handling with specific exception types
## API Design Patterns
- **FastAPI Routers**: Organize endpoints by domain (users, chats, models, etc.)
- **Pydantic Models**: Use for request/response validation
- **Response Models**: Consistent JSON structure with proper HTTP status codes
- **Authentication**: JWT-based with dependency injection
- **Database Models**: SQLAlchemy ORM with proper relationships
## Frontend Style
- **Framework**: SvelteKit with TypeScript
- **Styling**: Tailwind CSS utility classes
- **Component Organization**: Modular components in `src/lib/`
- **State Management**: Svelte stores for global state
- **Type Safety**: TypeScript throughout the frontend
## Configuration Management
- **Environment Variables**: Extensive use of env vars for configuration
- **Default Values**: Sensible defaults in `config.py`
- **Validation**: Pydantic for configuration validation
- **Documentation**: Document all configuration options
## Database Design
- **Migrations**: Alembic for database schema changes
- **Relationships**: Proper foreign keys and relationships
- **Indexes**: Strategic indexing for performance
- **Naming**: Descriptive table and column names
## Security Practices
- **Authentication**: JWT tokens with proper expiration
- **Authorization**: Role-based access control
- **Input Validation**: Pydantic models for all inputs
- **SQL Injection**: SQLAlchemy ORM prevents direct SQL
- **CORS**: Proper CORS configuration
- **Environment Secrets**: Never commit secrets to version control
## Testing Conventions
- **Backend Tests**: Pytest with fixtures
- **Frontend Tests**: Vitest for unit tests
- **E2E Tests**: Cypress for integration testing
- **Test Organization**: Mirror source code structure
- **Mocking**: Mock external dependencies in tests

View File

@ -0,0 +1,124 @@
# macOS Development Environment Setup
## System Requirements
- **Operating System**: macOS
- **Python**: 3.11+ (required for backend)
- **Node.js**: 18.13.0+ (required for frontend)
- **Package Managers**: npm 6.0.0+, optionally uv for Python
## macOS Specific Commands
### System Information
```bash
# Check macOS version
sw_vers
# Check available memory
vm_stat | head -5
# Check disk space
df -h
# Check CPU information
sysctl -n machdep.cpu.brand_string
# Check running processes
ps aux | grep open-webui
```
### Package Management
```bash
# Install Homebrew (if not installed)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install Python with Homebrew
brew install python@3.11
# Install Node.js with Homebrew
brew install node
# Install Docker Desktop for Mac
brew install --cask docker
# Install uv (modern Python package manager)
brew install uv
```
### File System Operations
```bash
# Navigate to project directory
cd /path/to/open-webui-next
# Find files
find . -name "*.py" -type f # Find Python files
find . -name "*.svelte" -type f # Find Svelte files
# Search in files
grep -r "search_term" backend/ # Search in backend
grep -r "search_term" src/ # Search in frontend
# File permissions
chmod +x backend/start.sh # Make script executable
```
### Network and Ports
```bash
# Check if port is in use
lsof -i :8080 # Check port 8080
lsof -i :3000 # Check port 3000 (frontend dev)
# Kill process on port
kill -9 $(lsof -ti:8080) # Kill process on port 8080
```
### Environment Management
```bash
# Python virtual environment
python3 -m venv venv
source venv/bin/activate
deactivate
# Environment variables
export OPENAI_API_KEY="your-key"
echo $OPENAI_API_KEY
printenv | grep WEBUI
```
### Troubleshooting Commands
```bash
# Check Python installation
which python3
python3 --version
# Check Node.js installation
which node
node --version
npm --version
# Check Docker
docker --version
docker ps
docker images
# Clear npm cache
npm cache clean --force
# Clear Python cache
find . -type d -name "__pycache__" -delete
find . -name "*.pyc" -delete
```
## Development Workflow on macOS
1. Use Terminal or iTerm2 for command line operations
2. Consider using VS Code or PyCharm for development
3. Use Docker Desktop for containerized development
4. Monitor system resources with Activity Monitor
5. Use Homebrew for package management

View File

@ -0,0 +1,46 @@
# Open WebUI Project Overview
## Purpose
Open WebUI is an extensible, feature-rich, and user-friendly self-hosted AI platform designed to operate entirely offline. It supports various LLM runners like Ollama and OpenAI-compatible APIs, with built-in inference engine for RAG, making it a powerful AI deployment solution.
## Key Features
- Effortless setup with Docker or Kubernetes
- Ollama/OpenAI API integration
- Granular permissions and user groups
- Responsive design with PWA support
- Full Markdown and LaTeX support
- Voice/video call functionality
- Model builder for custom models
- Native Python function calling
- Local RAG integration
- Web search capabilities
- Image generation integration
- Multi-model conversations
- Role-based access control (RBAC)
- Multilingual support
- Plugin framework with Pipelines
## Tech Stack
- **Backend**: Python 3.11+ with FastAPI
- **Frontend**: SvelteKit with TypeScript
- **Database**: SQLAlchemy with support for PostgreSQL, MySQL, SQLite
- **Vector Database**: Chroma, Milvus, Qdrant, OpenSearch, Elasticsearch, PGVector, Pinecone
- **Deployment**: Docker, Kubernetes
- **Build Tools**: Vite, Node.js
- **Styling**: Tailwind CSS
- **Testing**: Pytest (backend), Vitest (frontend), Cypress (e2e)
## Architecture
The project follows a modern full-stack architecture:
- **Backend**: Python FastAPI application serving REST APIs and WebSocket connections
- **Frontend**: SvelteKit SPA that communicates with the backend APIs
- **Database Layer**: SQLAlchemy ORM with Alembic migrations
- **Vector Storage**: Pluggable vector database support for RAG functionality
- **Authentication**: JWT-based authentication with OAuth support
- **Real-time**: WebSocket support for live features
- **File Storage**: Configurable storage providers (Local, S3, GCS, Azure)

View File

@ -0,0 +1,111 @@
# Development Commands and Scripts
## Essential Commands for Development
### Backend Development
```bash
# Install dependencies
pip install -r backend/requirements.txt
# Run backend in development mode
cd backend && python -m uvicorn open_webui.main:app --host 0.0.0.0 --port 8080 --reload
# Run with uv (modern Python package manager)
cd backend && uv run uvicorn open_webui.main:app --host 0.0.0.0 --port 8080 --reload
# Database migrations
alembic upgrade head
alembic revision --autogenerate -m "description"
# Run tests
pytest backend/
# Code formatting
black . --exclude ".venv/|/venv/"
# Linting
pylint backend/
```
### Frontend Development
```bash
# Install dependencies
npm install
# Development server
npm run dev
npm run dev:5050 # Run on port 5050
# Build for production
npm run build
# Build with watch mode
npm run build:watch
# Preview production build
npm run preview
# Type checking
npm run check
npm run check:watch
# Linting
npm run lint:frontend
# Formatting
npm run format
# Prepare Pyodide
npm run pyodide:fetch
# Internationalization
npm run i18n:parse
```
### Full Stack Commands
```bash
# Format both frontend and backend
npm run format && npm run format:backend
# Lint everything
npm run lint # Runs lint:frontend, lint:types, lint:backend
# Testing
npm run test:frontend
pytest backend/ # Backend tests
# End-to-end testing
npm run cy:open
```
### Docker Development
```bash
# Using Makefile
make install # docker-compose up -d
make start # docker-compose start
make stop # docker-compose stop
make startAndBuild # docker-compose up -d --build
make update # Update and rebuild
# Direct docker-compose
docker-compose up -d
docker-compose up -d --build
docker-compose logs -f
```
### Database Commands
```bash
# Reset database
rm backend/data/webui.db # For SQLite
# Run migrations
cd backend && alembic upgrade head
# Create new migration
cd backend && alembic revision --autogenerate -m "migration description"
```

View File

@ -0,0 +1,106 @@
# Task Completion Workflow
## When a Development Task is Completed
### 1. Code Quality Checks
```bash
# Format code
npm run format # Frontend formatting
npm run format:backend # Backend formatting (Black)
# Lint code
npm run lint # Full linting (frontend + backend)
pylint backend/ # Backend specific linting
# Type checking
npm run check # TypeScript type checking
```
### 2. Testing
```bash
# Run unit tests
npm run test:frontend # Frontend tests with Vitest
pytest backend/ # Backend tests with Pytest
# Run integration tests (if applicable)
npm run cy:open # Cypress e2e tests
```
### 3. Build Verification
```bash
# Test production build
npm run build # Build frontend
npm run preview # Preview production build
# Test backend startup
cd backend && python -m uvicorn open_webui.main:app --host 0.0.0.0 --port 8080
```
### 4. Database Migrations (if schema changed)
```bash
# Generate migration if database models were modified
cd backend && alembic revision --autogenerate -m "description of changes"
# Apply migrations
cd backend && alembic upgrade head
```
### 5. Documentation Updates
- Update README.md if new features added
- Update API documentation if endpoints changed
- Update configuration documentation if new env vars added
- Update CHANGELOG.md following semantic versioning
### 6. Git Workflow
```bash
# Stage changes
git add .
# Commit with descriptive message
git commit -m "feat: add new feature description"
# or
git commit -m "fix: resolve bug description"
# or
git commit -m "docs: update documentation"
# Push changes
git push origin feature-branch
```
### 7. System Verification Commands (macOS)
```bash
# Check system resources
ps aux | grep open-webui # Check if processes are running
lsof -i :8080 # Check if port is in use
df -h # Check disk space
free -m # Check memory usage (if available)
# Docker verification (if using Docker)
docker ps # Check running containers
docker logs open-webui # Check container logs
```
### 8. Performance Verification
- Check application startup time
- Verify API response times
- Test memory usage under load
- Verify frontend bundle sizes are reasonable
### 9. Pre-deployment Checklist
- [ ] All tests passing
- [ ] Code properly formatted and linted
- [ ] Documentation updated
- [ ] Environment variables documented
- [ ] Database migrations tested
- [ ] No secrets in code
- [ ] Performance is acceptable
- [ ] Security considerations addressed

66
.serena/project.yml Normal file
View File

@ -0,0 +1,66 @@
# language of the project (csharp, python, rust, java, typescript, javascript, go, cpp, or ruby)
# Special requirements:
# * csharp: Requires the presence of a .sln file in the project folder.
language: python
# whether to use the project's gitignore file to ignore files
# Added on 2025-04-07
ignore_all_files_in_gitignore: true
# list of additional paths to ignore
# same syntax as gitignore, so you can use * and **
# Was previously called `ignored_dirs`, please update your config if you are using that.
# Added (renamed)on 2025-04-07
ignored_paths: []
# whether the project is in read-only mode
# If set to true, all editing tools will be disabled and attempts to use them will result in an error
# Added on 2025-04-18
read_only: false
# list of tool names to exclude. We recommend not excluding any tools, see the readme for more details.
# Below is the complete list of tools for convenience.
# To make sure you have the latest list of tools, and to view their descriptions,
# execute `uv run scripts/print_tool_overview.py`.
#
# * `activate_project`: Activates a project by name.
# * `check_onboarding_performed`: Checks whether project onboarding was already performed.
# * `create_text_file`: Creates/overwrites a file in the project directory.
# * `delete_lines`: Deletes a range of lines within a file.
# * `delete_memory`: Deletes a memory from Serena's project-specific memory store.
# * `execute_shell_command`: Executes a shell command.
# * `find_referencing_code_snippets`: Finds code snippets in which the symbol at the given location is referenced.
# * `find_referencing_symbols`: Finds symbols that reference the symbol at the given location (optionally filtered by type).
# * `find_symbol`: Performs a global (or local) search for symbols with/containing a given name/substring (optionally filtered by type).
# * `get_current_config`: Prints the current configuration of the agent, including the active and available projects, tools, contexts, and modes.
# * `get_symbols_overview`: Gets an overview of the top-level symbols defined in a given file or directory.
# * `initial_instructions`: Gets the initial instructions for the current project.
# Should only be used in settings where the system prompt cannot be set,
# e.g. in clients you have no control over, like Claude Desktop.
# * `insert_after_symbol`: Inserts content after the end of the definition of a given symbol.
# * `insert_at_line`: Inserts content at a given line in a file.
# * `insert_before_symbol`: Inserts content before the beginning of the definition of a given symbol.
# * `list_dir`: Lists files and directories in the given directory (optionally with recursion).
# * `list_memories`: Lists memories in Serena's project-specific memory store.
# * `onboarding`: Performs onboarding (identifying the project structure and essential tasks, e.g. for testing or building).
# * `prepare_for_new_conversation`: Provides instructions for preparing for a new conversation (in order to continue with the necessary context).
# * `read_file`: Reads a file within the project directory.
# * `read_memory`: Reads the memory with the given name from Serena's project-specific memory store.
# * `remove_project`: Removes a project from the Serena configuration.
# * `replace_lines`: Replaces a range of lines within a file with new content.
# * `replace_symbol_body`: Replaces the full definition of a symbol.
# * `restart_language_server`: Restarts the language server, may be necessary when edits not through Serena happen.
# * `search_for_pattern`: Performs a search for a pattern in the project.
# * `summarize_changes`: Provides instructions for summarizing the changes made to the codebase.
# * `switch_modes`: Activates modes by providing a list of their names
# * `think_about_collected_information`: Thinking tool for pondering the completeness of collected information.
# * `think_about_task_adherence`: Thinking tool for determining whether the agent is still on track with the current task.
# * `think_about_whether_you_are_done`: Thinking tool for determining whether the task is truly completed.
# * `write_memory`: Writes a named memory (for future reference) to Serena's project-specific memory store.
excluded_tools: []
# initial prompt for the project. It will always be given to the LLM upon activating the project
# (contrary to the memories, which are loaded on demand).
initial_prompt: ""
project_name: "open-webui-next"

View File

@ -63,7 +63,7 @@ async def execute_code(
else None
),
request.app.state.config.CODE_EXECUTION_JUPYTER_TIMEOUT,
form_data.chat_id # Pass chat_id to the enhanced function
form_data.chat_id, # Pass chat_id to the enhanced function
)
return output

File diff suppressed because it is too large Load Diff

View File

@ -81,7 +81,10 @@ from open_webui.utils.filter import (
get_sorted_filter_ids,
process_filter_functions,
)
from open_webui.utils.code_interpreter import execute_code_jupyter, generate_dynamic_code_interpreter_prompt
from open_webui.utils.code_interpreter import (
execute_code_jupyter,
generate_dynamic_code_interpreter_prompt,
)
from open_webui.tasks import create_task
@ -846,17 +849,17 @@ async def process_chat_payload(request, form_data, user, metadata, model):
if request.app.state.config.CODE_INTERPRETER_PROMPT_TEMPLATE != ""
else DEFAULT_CODE_INTERPRETER_PROMPT
)
# Get attached files from metadata
attached_files = metadata.get("files", [])
# Generate enhanced prompt with file information
enhanced_prompt = generate_dynamic_code_interpreter_prompt(
base_prompt=base_prompt,
attached_files=attached_files,
chat_id=metadata.get("chat_id", "")
chat_id=metadata.get("chat_id", ""),
)
form_data["messages"] = add_or_update_user_message(
enhanced_prompt,
form_data["messages"],
@ -2278,7 +2281,7 @@ async def process_chat_response(
),
request.app.state.config.CODE_INTERPRETER_JUPYTER_TIMEOUT,
chat_id=metadata.get("chat_id", ""),
data_dir="data"
data_dir="data",
)
else:
output = {

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "open-webui",
"version": "0.6.15",
"version": "0.6.15c",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "open-webui",
"version": "0.6.15",
"version": "0.6.15c",
"dependencies": {
"@azure/msal-browser": "^4.5.0",
"@codemirror/lang-javascript": "^6.2.2",

View File

@ -1,6 +1,6 @@
{
"name": "open-webui",
"version": "0.6.15",
"version": "0.6.15c",
"private": true,
"scripts": {
"dev": "npm run pyodide:fetch && vite dev --host",