2026-03-09 21:42:17 +08:00
# 🚀 Local Deployment Scripts Guide
2026-03-09 20:31:25 +08:00
2026-03-09 21:42:17 +08:00
## Overview
2026-03-09 20:31:25 +08:00
2026-03-09 21:42:17 +08:00
This directory contains automated scripts for deploying plugins in development to a local OpenWebUI instance. They enable quick code pushes without restarting OpenWebUI.
2026-03-09 20:31:25 +08:00
2026-03-09 21:42:17 +08:00
## Prerequisites
2026-03-09 20:31:25 +08:00
2026-03-09 21:42:17 +08:00
1. **OpenWebUI Running ** : Make sure OpenWebUI is running locally (default `http://localhost:3000` )
2. **API Key ** : You need a valid OpenWebUI API key
3. **Environment File ** : Create a `.env` file in this directory containing your API key:
2026-03-11 23:32:00 +08:00
2026-03-09 20:31:25 +08:00
```
api_key=sk-xxxxxxxxxxxxx
```
2026-03-09 21:42:17 +08:00
## Quick Start
2026-03-09 20:31:25 +08:00
2026-03-09 21:42:17 +08:00
### Deploy a Pipe Plugin
2026-03-09 20:31:25 +08:00
```bash
2026-03-09 21:42:17 +08:00
# Deploy GitHub Copilot SDK Pipe
2026-03-09 20:31:25 +08:00
python deploy_pipe.py
```
2026-03-09 21:42:17 +08:00
### Deploy a Filter Plugin
2026-03-09 20:31:25 +08:00
```bash
2026-03-09 21:42:17 +08:00
# Deploy async_context_compression Filter (default)
2026-03-09 20:31:25 +08:00
python deploy_filter.py
2026-03-09 21:42:17 +08:00
# Deploy a specific Filter plugin
2026-03-09 20:31:25 +08:00
python deploy_filter.py my-filter-name
2026-03-09 21:42:17 +08:00
# List all available Filters
2026-03-09 20:31:25 +08:00
python deploy_filter.py --list
```
2026-03-09 21:42:17 +08:00
## Script Documentation
2026-03-09 20:31:25 +08:00
2026-03-09 21:42:17 +08:00
### `deploy_filter.py` — Filter Plugin Deployment Tool
2026-03-09 20:31:25 +08:00
2026-03-09 21:42:17 +08:00
Used to deploy Filter-type plugins (such as message filtering, context compression, etc.).
2026-03-09 20:31:25 +08:00
2026-03-09 21:42:17 +08:00
**Key Features**:
2026-03-11 23:32:00 +08:00
2026-03-09 21:42:17 +08:00
- ✅ Auto-extracts metadata from Python files (version, author, description, etc.)
- ✅ Attempts to update existing plugins, creates if not found
- ✅ Supports multiple Filter plugin management
- ✅ Detailed error messages and connection diagnostics
2026-03-09 20:31:25 +08:00
2026-03-09 21:42:17 +08:00
**Usage**:
2026-03-11 23:32:00 +08:00
2026-03-09 20:31:25 +08:00
```bash
2026-03-09 21:42:17 +08:00
# Deploy async_context_compression (default)
2026-03-09 20:31:25 +08:00
python deploy_filter.py
2026-03-09 21:42:17 +08:00
# Deploy other Filters
2026-03-09 20:31:25 +08:00
python deploy_filter.py async-context-compression
python deploy_filter.py workflow-guide
2026-03-09 21:42:17 +08:00
# List all available Filters
2026-03-09 20:31:25 +08:00
python deploy_filter.py --list
python deploy_filter.py -l
```
2026-03-09 21:42:17 +08:00
**Workflow**:
2026-03-11 23:32:00 +08:00
2026-03-09 21:42:17 +08:00
1. Load API key from `.env`
2. Find target Filter plugin directory
3. Read Python source file
4. Extract metadata from docstring (title, version, author, description, etc.)
5. Build API request payload
6. Send update request to OpenWebUI
7. If update fails, auto-attempt to create new plugin
8. Display results and diagnostic info
2026-03-09 20:31:25 +08:00
2026-03-09 21:42:17 +08:00
### `deploy_pipe.py` — Pipe Plugin Deployment Tool
2026-03-09 20:31:25 +08:00
2026-03-09 21:42:17 +08:00
Used to deploy Pipe-type plugins (such as GitHub Copilot SDK).
2026-03-09 20:31:25 +08:00
2026-03-09 21:42:17 +08:00
**Usage**:
2026-03-11 23:32:00 +08:00
2026-03-09 20:31:25 +08:00
```bash
python deploy_pipe.py
```
2026-03-09 21:42:17 +08:00
## Get an API Key
2026-03-09 20:31:25 +08:00
2026-03-09 21:42:17 +08:00
### Method 1: Use Existing User Token (Recommended)
2026-03-09 20:31:25 +08:00
2026-03-09 21:42:17 +08:00
1. Open OpenWebUI interface
2. Click user avatar → Settings
3. Find the API Keys section
4. Copy your API key (starts with sk-)
5. Paste into `.env` file
2026-03-09 20:31:25 +08:00
2026-03-09 21:42:17 +08:00
### Method 2: Create a Long-term API Key
2026-03-09 20:31:25 +08:00
2026-03-09 21:42:17 +08:00
Create a dedicated long-term API key in OpenWebUI Settings for deployment purposes.
2026-03-09 20:31:25 +08:00
2026-03-09 21:42:17 +08:00
## Troubleshooting
2026-03-09 20:31:25 +08:00
2026-03-09 21:42:17 +08:00
### "Connection error: Could not reach OpenWebUI at localhost:3000"
2026-03-09 20:31:25 +08:00
2026-03-09 21:42:17 +08:00
**Cause**: OpenWebUI is not running or port is different
2026-03-09 20:31:25 +08:00
2026-03-09 21:42:17 +08:00
**Solution**:
2026-03-11 23:32:00 +08:00
2026-03-09 21:42:17 +08:00
- Make sure OpenWebUI is running
- Check which port OpenWebUI is actually listening on (usually 3000)
- Edit the URL in the script if needed
2026-03-09 20:31:25 +08:00
### ".env file not found"
2026-03-09 21:42:17 +08:00
**Cause**: `.env` file was not created
2026-03-09 20:31:25 +08:00
2026-03-09 21:42:17 +08:00
**Solution**:
2026-03-11 23:32:00 +08:00
2026-03-09 20:31:25 +08:00
```bash
echo "api_key=sk-your-api-key-here" > .env
```
### "Filter 'xxx' not found"
2026-03-09 21:42:17 +08:00
**Cause**: Filter directory name is incorrect
2026-03-09 20:31:25 +08:00
2026-03-09 21:42:17 +08:00
**Solution**:
2026-03-11 23:32:00 +08:00
2026-03-09 20:31:25 +08:00
```bash
2026-03-09 21:42:17 +08:00
# List all available Filters
2026-03-09 20:31:25 +08:00
python deploy_filter.py --list
```
### "Failed to update or create. Status: 401"
2026-03-09 21:42:17 +08:00
**Cause**: API key is invalid or expired
2026-03-09 20:31:25 +08:00
2026-03-09 21:42:17 +08:00
**Solution**:
2026-03-11 23:32:00 +08:00
2026-03-09 21:42:17 +08:00
1. Verify your API key is valid
2. Generate a new API key
3. Update the `.env` file
2026-03-09 20:31:25 +08:00
2026-03-09 21:42:17 +08:00
## Workflow Examples
2026-03-09 20:31:25 +08:00
2026-03-09 21:42:17 +08:00
### Develop and Deploy a New Filter
2026-03-09 20:31:25 +08:00
```bash
2026-03-09 21:42:17 +08:00
# 1. Create new Filter directory in plugins/filters/
2026-03-09 20:31:25 +08:00
mkdir plugins/filters/my-new-filter
2026-03-09 21:42:17 +08:00
# 2. Create my_new_filter.py with required metadata:
2026-03-09 20:31:25 +08:00
# """
# title: My New Filter
# author: Your Name
# version: 1.0.0
# description: Filter description
# """
2026-03-09 21:42:17 +08:00
# 3. Deploy to local OpenWebUI
2026-03-09 20:31:25 +08:00
cd scripts
python deploy_filter.py my-new-filter
2026-03-09 21:42:17 +08:00
# 4. Test the plugin in OpenWebUI UI
2026-03-09 20:31:25 +08:00
2026-03-09 21:42:17 +08:00
# 5. Continue development
# ... modify code ...
2026-03-09 20:31:25 +08:00
2026-03-09 21:42:17 +08:00
# 6. Re-deploy (auto-overwrites)
2026-03-09 20:31:25 +08:00
python deploy_filter.py my-new-filter
```
2026-03-09 21:42:17 +08:00
### Fix a Bug and Deploy Quickly
2026-03-09 20:31:25 +08:00
```bash
2026-03-09 21:42:17 +08:00
# 1. Modify the source code
2026-03-09 20:31:25 +08:00
# vim ../plugins/filters/async-context-compression/async_context_compression.py
2026-03-09 21:42:17 +08:00
# 2. Deploy immediately to local
2026-03-09 20:31:25 +08:00
python deploy_filter.py async-context-compression
2026-03-09 21:42:17 +08:00
# 3. Test the fix in OpenWebUI
# (No need to restart OpenWebUI)
2026-03-09 20:31:25 +08:00
```
2026-03-09 21:42:17 +08:00
## Security Considerations
2026-03-09 20:31:25 +08:00
2026-03-11 23:32:00 +08:00
⚠️ **Important ** :
2026-03-09 21:42:17 +08:00
- ✅ Add `.env` file to `.gitignore` (avoid committing sensitive info)
- ✅ Never commit API keys to version control
- ✅ Use only on trusted networks
- ✅ Rotate API keys periodically
2026-03-09 20:31:25 +08:00
2026-03-09 21:42:17 +08:00
## File Structure
2026-03-09 20:31:25 +08:00
```
scripts/
2026-03-09 21:42:17 +08:00
├── deploy_filter.py # Filter plugin deployment tool
├── deploy_pipe.py # Pipe plugin deployment tool
├── .env # API key (local, not committed)
├── README.md # This file
2026-03-09 20:31:25 +08:00
└── ...
```
2026-03-09 21:42:17 +08:00
## Reference Resources
2026-03-09 20:31:25 +08:00
2026-03-09 21:42:17 +08:00
- [OpenWebUI Documentation ](https://docs.openwebui.com/ )
- [Plugin Development Guide ](../docs/development/plugin-guide.md )
- [Filter Plugin Examples ](../plugins/filters/ )
2026-03-09 20:31:25 +08:00
---
2026-03-09 21:42:17 +08:00
**Last Updated**: 2026-03-09
**Author**: Fu-Jie