From ba44dfab269dcf4e35dc2850cb84277e81245722 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 30 Dec 2025 01:22:29 +0000 Subject: [PATCH] docs: add full zh translations for site Co-authored-by: Fu-Jie <33599649+Fu-Jie@users.noreply.github.com> --- docs/contributing.zh.md | 186 ++++++++++ docs/development/documentation-guide.zh.md | 328 +++++++++++++++++ docs/development/index.zh.md | 168 +++++++++ docs/development/plugin-guide.zh.md | 234 ++++++++++++ docs/enhancements/guide.zh.md | 178 +++++++++ docs/enhancements/index.zh.md | 59 +++ docs/plugins/actions/export-to-excel.zh.md | 67 ++++ docs/plugins/actions/index.zh.md | 151 ++++++++ docs/plugins/actions/knowledge-card.zh.md | 88 +++++ docs/plugins/actions/smart-infographic.zh.md | 107 ++++++ docs/plugins/actions/smart-mind-map.zh.md | 91 +++++ docs/plugins/actions/summary.zh.md | 82 +++++ .../filters/async-context-compression.zh.md | 122 +++++++ .../plugins/filters/context-enhancement.zh.md | 51 +++ .../filters/gemini-manifold-companion.zh.md | 54 +++ docs/plugins/filters/index.zh.md | 155 ++++++++ docs/plugins/index.zh.md | 93 +++++ docs/plugins/pipelines/index.zh.md | 63 ++++ .../pipelines/moe-prompt-refiner.zh.md | 109 ++++++ docs/plugins/pipes/gemini-manifold.zh.md | 106 ++++++ docs/plugins/pipes/index.zh.md | 133 +++++++ docs/prompts/index.zh.md | 102 ++++++ docs/prompts/library.zh.md | 344 ++++++++++++++++++ 23 files changed, 3071 insertions(+) create mode 100644 docs/contributing.zh.md create mode 100644 docs/development/documentation-guide.zh.md create mode 100644 docs/development/index.zh.md create mode 100644 docs/development/plugin-guide.zh.md create mode 100644 docs/enhancements/guide.zh.md create mode 100644 docs/enhancements/index.zh.md create mode 100644 docs/plugins/actions/export-to-excel.zh.md create mode 100644 docs/plugins/actions/index.zh.md create mode 100644 docs/plugins/actions/knowledge-card.zh.md create mode 100644 docs/plugins/actions/smart-infographic.zh.md create mode 100644 docs/plugins/actions/smart-mind-map.zh.md create mode 100644 docs/plugins/actions/summary.zh.md create mode 100644 docs/plugins/filters/async-context-compression.zh.md create mode 100644 docs/plugins/filters/context-enhancement.zh.md create mode 100644 docs/plugins/filters/gemini-manifold-companion.zh.md create mode 100644 docs/plugins/filters/index.zh.md create mode 100644 docs/plugins/index.zh.md create mode 100644 docs/plugins/pipelines/index.zh.md create mode 100644 docs/plugins/pipelines/moe-prompt-refiner.zh.md create mode 100644 docs/plugins/pipes/gemini-manifold.zh.md create mode 100644 docs/plugins/pipes/index.zh.md create mode 100644 docs/prompts/index.zh.md create mode 100644 docs/prompts/library.zh.md diff --git a/docs/contributing.zh.md b/docs/contributing.zh.md new file mode 100644 index 0000000..2ec2f04 --- /dev/null +++ b/docs/contributing.zh.md @@ -0,0 +1,186 @@ +# 贡献指南 + +感谢你对 **OpenWebUI Extras** 的兴趣!我们欢迎各种形式的贡献,包括插件、提示词、文档等。 + +--- + +## 🤝 如何贡献 + +### 1. 分享提示词 + +如果你有实用的提示词想要分享: + +1. 浏览 `prompts/` 目录并找到合适的分类 +2. 如果没有合适的分类,可以新建一个文件夹 +3. 创建一个新的 `.md` 文件来编写你的提示词 +4. 提交 Pull Request + +#### 提示词格式 + +```markdown +# 提示词名称 + +简短描述这个提示词的功能。 + +## 使用场景 + +说明何时使用这个提示词。 + +## 提示词内容 + +\```text +你的提示词内容... +\``` + +## 使用技巧 + +使用这个提示词的一些建议和技巧。 +``` + +--- + +### 2. 开发插件 + +如果你开发了一个 OpenWebUI 插件: + +#### 插件元数据 + +确保你的插件包含完整的元数据: + +```python +""" +title: 插件名称 +author: 你的名字 +version: 0.1.0 +description: 简短描述插件的功能 +""" +``` + +#### 目录结构 + +将插件放在合适的目录下: + +- `plugins/actions/` - Action 插件(消息下方的按钮) +- `plugins/filters/` - Filter 插件(消息处理) +- `plugins/pipes/` - Pipe 插件(自定义模型) +- `plugins/pipelines/` - Pipeline 插件(复杂工作流) + +#### 文档 + +请为你的插件提供文档: + +- `README.md` - 英文文档 +- `README_CN.md` - 中文文档(可选但推荐) + +文档应包含: + +- 功能描述 +- 安装步骤 +- 配置选项 +- 使用示例 +- 故障排除指南 + +--- + +### 3. 改进文档 + +发现错误或想要改进文档? + +1. Fork 仓库 +2. 在 `docs/` 目录下进行修改 +3. 提交 Pull Request + +--- + +## 🛠️ 开发规范 + +### 代码风格 + +- **Python**:遵循 [PEP 8](https://peps.python.org/pep-0008/) 规范 +- **注释**:为复杂逻辑添加注释 +- **命名**:使用清晰、描述性的名称 + +### 测试 + +提交前请确保: + +1. 在本地 OpenWebUI 环境中测试插件 +2. 验证所有功能按文档所述正常工作 +3. 检查边界情况和错误处理 + +### 提交信息 + +使用清晰、描述性的提交信息: + +``` +Add: 智能思维导图 action 插件 +Fix: 上下文压缩 token 计数问题 +Update: 插件开发指南添加新示例 +``` + +--- + +## 📝 提交 Pull Request + +### 详细步骤 + +1. **Fork** 本仓库 +2. **克隆**你的 fork 到本地 +3. **创建**新分支: + ```bash + git checkout -b feature/amazing-feature + ``` +4. **进行**修改 +5. **提交**你的修改: + ```bash + git commit -m 'Add: Amazing feature' + ``` +6. **推送**到你的分支: + ```bash + git push origin feature/amazing-feature + ``` +7. **创建** Pull Request + +### PR 检查清单 + +- [ ] 代码遵循项目风格指南 +- [ ] 包含/更新了文档 +- [ ] 插件已在本地测试通过 +- [ ] 提交信息清晰 +- [ ] PR 描述说明了所做的更改 + +--- + +## 🐛 报告问题 + +发现了 bug?请创建 issue 并包含以下信息: + +1. **描述**:清晰描述问题 +2. **复现步骤**:如何触发这个问题 +3. **预期行为**:应该发生什么 +4. **实际行为**:实际发生了什么 +5. **环境信息**:OpenWebUI 版本、浏览器、操作系统 + +--- + +## 💡 功能请求 + +有新想法?我们很乐意听取! + +1. 先检查是否已有类似的 issue +2. 创建新 issue 并添加 "enhancement" 标签 +3. 描述你的想法和使用场景 + +--- + +## 📄 许可证 + +通过贡献,你同意你的贡献将使用与项目相同的许可证。 + +--- + +## 🙏 感谢 + +每一份贡献,无论大小,都有助于让 OpenWebUI Extras 变得更好。感谢你成为我们社区的一员! + +[:fontawesome-brands-github: 在 GitHub 上查看](https://github.com/Fu-Jie/awesome-openwebui){ .md-button .md-button--primary } diff --git a/docs/development/documentation-guide.zh.md b/docs/development/documentation-guide.zh.md new file mode 100644 index 0000000..0f83b87 --- /dev/null +++ b/docs/development/documentation-guide.zh.md @@ -0,0 +1,328 @@ +# 文档编写指南 + +本文介绍如何为 OpenWebUI Extras 编写与贡献文档。 + +--- + +## 概览 + +文档基于 [MkDocs](https://www.mkdocs.org/) 与 [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) 主题构建。了解 Markdown 与 MkDocs 的基础有助于高效贡献。 + +--- + +## 开始之前 + +### 前置条件 + +1. Python 3.8 及以上 +2. Git + +### 本地环境搭建 + +```bash +# 克隆仓库 +git clone https://github.com/Fu-Jie/awesome-openwebui.git +cd awesome-openwebui + +# 安装依赖 +pip install -r requirements.txt + +# 启动开发服务器 +mkdocs serve +``` + +访问 `http://localhost:8000` 预览文档。 + +--- + +## 文档结构 + +``` +docs/ +├── index.md # 首页 +├── contributing.md # 贡献指南 +├── plugins/ # 插件文档 +│ ├── index.md # 插件中心概览 +│ ├── actions/ # Action 插件 +│ ├── filters/ # Filter 插件 +│ ├── pipes/ # Pipe 插件 +│ └── pipelines/ # Pipeline 插件 +├── prompts/ # 提示词库 +├── enhancements/ # 增强指南 +├── development/ # 开发指南 +└── stylesheets/ # 自定义 CSS +``` + +--- + +## 编写插件文档 + +### 模板 + +新建插件文档可参考以下模板: + +```markdown +# Plugin Name + +Action +v1.0.0 + +Brief description of what the plugin does. + +--- + +## Overview + +Detailed explanation of the plugin's purpose and functionality. + +## Features + +- :material-icon-name: **Feature 1**: Description +- :material-icon-name: **Feature 2**: Description + +--- + +## Installation + +1. Download the plugin file +2. Upload to OpenWebUI +3. Configure settings +4. Enable the plugin + +--- + +## Usage + +Step-by-step usage instructions. + +--- + +## Configuration + +| Option | Type | Default | Description | +|--------|------|---------|-------------| +| `option_name` | type | `default` | Description | + +--- + +## Requirements + +!!! note "Prerequisites" + - OpenWebUI v0.3.0 or later + - Any additional requirements + +--- + +## Troubleshooting + +??? question "Common issue?" + Solution to the issue. + +--- + +## Source Code + +[:fontawesome-brands-github: View on GitHub](https://github.com/Fu-Jie/awesome-openwebui/tree/main/plugins/...){ .md-button } +``` + +--- + +## Markdown 扩展 + +### 提示块(Admonitions) + +用来突出重要信息: + +```markdown +!!! note "Title" + This is a note. + +!!! warning "Caution" + This is a warning. + +!!! tip "Pro Tip" + This is a helpful tip. + +!!! danger "Warning" + This is a critical warning. +``` + +### 可折叠区域 + +```markdown +??? question "Frequently asked question?" + This is the answer. + +???+ note "Open by default" + This section is expanded by default. +``` + +### 代码块 + +````markdown +```python title="example.py" linenums="1" +def hello(): + print("Hello, World!") +``` +```` + +### Tabs + +```markdown +=== "Python" + + ```python + print("Hello") + ``` + +=== "JavaScript" + + ```javascript + console.log("Hello"); + ``` +``` + +--- + +## 图标 + +使用 `:material-icon-name:` 语法调用 Material Design Icons: + +- `:material-brain:` :material-brain: +- `:material-puzzle:` :material-puzzle: +- `:material-download:` :material-download: +- `:material-github:` :material-github: + +更多图标见 [Material Design Icons](https://pictogrammers.com/library/mdi/)。 + +### 图标尺寸 + +```markdown +:material-brain:{ .lg .middle } Large icon +``` + +--- + +## 分类徽章 + +为不同插件类型添加徽章: + +```markdown +Action +Filter +Pipe +Pipeline +``` + +--- + +## 表格 + +```markdown +| Column 1 | Column 2 | Column 3 | +|----------|----------|----------| +| Value 1 | Value 2 | Value 3 | +``` + +更好的对齐方式: + +```markdown +| Left | Center | Right | +|:-----|:------:|------:| +| L | C | R | +``` + +--- + +## 网格卡片 + +创建卡片式导航: + +```markdown +
+ +- :material-icon:{ .lg .middle } **Card Title** + + --- + + Card description goes here. + + [:octicons-arrow-right-24: Link Text](link.md) + +
+``` + +--- + +## 链接 + +### 内部链接 + +```markdown +[Link Text](../path/to/page.md) +``` + +### 外部链接 + +```markdown +[Link Text](https://example.com){ target="_blank" } +``` + +### 按钮样式链接 + +```markdown +[Button Text](link.md){ .md-button } +[Primary Button](link.md){ .md-button .md-button--primary } +``` + +--- + +## 图片 + +```markdown +![Alt text](path/to/image.png) + + +![Alt text](path/to/image.png){ width="300" } +``` + +--- + +## 最佳实践 + +### 写作风格 + +1. **简洁**:快速切入主题 +2. **示例驱动**:展示而不只是说明 +3. **一致性**:遵循现有模式 +4. **面向新手**:假设读者基础有限 + +### 格式 + +1. 使用正确的标题层级(H1 → H2 → H3) +2. 主要段落间添加水平分割线(`---`) +3. 使用列表呈现步骤与特性 +4. 需要时提供代码示例 + +### SEO + +1. 使用描述性页面标题 +2. 自然融入相关关键词 +3. 需要时在前置区添加 meta 描述 + +--- + +## 提交修改 + +1. 创建功能分支 +2. 完成文档修改 +3. 通过 `mkdocs serve` 本地验证 +4. 提交 Pull Request + +--- + +## 其他资源 + +- [MkDocs Documentation](https://www.mkdocs.org/) +- [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) +- [Markdown Guide](https://www.markdownguide.org/) diff --git a/docs/development/index.zh.md b/docs/development/index.zh.md new file mode 100644 index 0000000..2c4c931 --- /dev/null +++ b/docs/development/index.zh.md @@ -0,0 +1,168 @@ +# 开发指南 + +了解如何开发插件并为 OpenWebUI Extras 做出贡献。 + +--- + +## 快速开始 + +
+ +- :material-book-open-page-variant:{ .lg .middle } **插件开发指南** + + --- + + 从入门到高级模式、最佳实践的完整指南。 + + [:octicons-arrow-right-24: 阅读指南](plugin-guide.md) + +- :material-file-document-edit:{ .lg .middle } **文档编写指南** + + --- + + 学习如何使用 MkDocs 与 Material 主题编写和贡献文档。 + + [:octicons-arrow-right-24: 阅读指南](documentation-guide.md) + +- :material-github:{ .lg .middle } **贡献指南** + + --- + + 了解如何贡献插件、提示词与文档。 + + [:octicons-arrow-right-24: 贡献说明](../contributing.md) + +
+ +--- + +## 插件类型概览 + +OpenWebUI 支持三种主要插件类型: + +| 类型 | 目的 | 入口方法 | +|------|---------|--------------| +| **Action** | 为消息添加按钮 | `action()` | +| **Filter** | 处理消息 | `inlet()` / `outlet()` | +| **Pipe** | 自定义模型集成 | `pipe()` | + +--- + +## 快速开始模板 + +### Action 插件 + +```python +""" +title: My Action +author: Your Name +version: 1.0.0 +""" + +class Action: + async def action(self, body: dict, __event_emitter__=None): + await __event_emitter__({"type": "notification", "data": {"content": "Hello!"}}) + return body +``` + +### Filter 插件 + +```python +""" +title: My Filter +author: Your Name +version: 1.0.0 +""" + +class Filter: + async def inlet(self, body: dict, __metadata__: dict) -> dict: + # 发送到 LLM 之前处理 + return body + + async def outlet(self, body: dict, __metadata__: dict) -> dict: + # LLM 返回后处理 + return body +``` + +### Pipe 插件 + +```python +""" +title: My Pipe +author: Your Name +version: 1.0.0 +""" + +class Pipe: + def pipes(self): + return [{"id": "my-model", "name": "My Model"}] + + def pipe(self, body: dict): + return "Response from custom pipe" +``` + +--- + +## 核心概念 + +### Valves 配置 + +Valves 允许用户在界面中配置插件: + +```python +from pydantic import BaseModel, Field + +class Action: + class Valves(BaseModel): + api_key: str = Field(default="", description="API Key") + enabled: bool = Field(default=True, description="Enable plugin") + + def __init__(self): + self.valves = self.Valves() +``` + +### 事件发送器 + +发送通知与状态更新: + +```python +# Notification +await __event_emitter__({ + "type": "notification", + "data": {"type": "success", "content": "Done!"} +}) + +# Status update +await __event_emitter__({ + "type": "status", + "data": {"description": "Processing...", "done": False} +}) +``` + +### 用户上下文 + +获取用户信息: + +```python +user_name = __user__.get("name", "User") +user_id = __user__.get("id") +user_language = __user__.get("language", "en-US") +``` + +--- + +## 最佳实践 + +1. **异步操作**:I/O 请使用 `async/await` +2. **错误处理**:捕获异常并通知用户 +3. **状态反馈**:长耗时操作提供进度提示 +4. **配置化**:使用 Valves 暴露可调参数 +5. **文档**:提供清晰的 docstring 与 README + +--- + +## 资源 + +- [完整开发指南](plugin-guide.md) +- [插件示例](https://github.com/Fu-Jie/awesome-openwebui/tree/main/plugins) +- [OpenWebUI 文档](https://docs.openwebui.com/) diff --git a/docs/development/plugin-guide.zh.md b/docs/development/plugin-guide.zh.md new file mode 100644 index 0000000..74570fd --- /dev/null +++ b/docs/development/plugin-guide.zh.md @@ -0,0 +1,234 @@ +# OpenWebUI 插件开发权威指南 + +> 本指南整合了官方文档、SDK 详解及最佳实践,旨在为开发者提供一份从入门到精通的系统化教程。 + +## 📚 目录 + +1. [插件开发快速入门](#1-插件开发快速入门) +2. [核心概念与 SDK 详解](#2-核心概念与-sdk-详解) +3. [插件类型深度解析](#3-插件类型深度解析) + * [Action (动作)](#31-action-动作) + * [Filter (过滤器)](#32-filter-过滤器) + * [Pipe (管道)](#33-pipe-管道) +4. [高级开发模式](#4-高级开发模式) +5. [最佳实践与设计原则](#5-最佳实践与设计原则) +6. [故障排查](#6-故障排查) + +--- + +## 1. 插件开发快速入门 + +### 1.1 什么是 OpenWebUI 插件? + +OpenWebUI 插件(官方称为 "Functions")是扩展平台功能的主要方式。它们运行在后端 Python 环境中,允许你: +* 🔌 **集成新模型**:通过 Pipe 接入 Claude、Gemini 或自定义 RAG。 +* 🎨 **增强交互**:通过 Action 在消息旁添加按钮(如"导出"、"生成图表")。 +* 🔧 **干预流程**:通过 Filter 在请求前后修改数据(如注入上下文、敏感词过滤)。 + +### 1.2 你的第一个插件 (Hello World) + +保存以下代码为 `hello.py` 并上传到 OpenWebUI 的 **Functions** 面板: + +```python +""" +title: Hello World Action +author: Demo +version: 1.0.0 +""" + +from pydantic import BaseModel, Field +from typing import Optional + +class Action: + class Valves(BaseModel): + greeting: str = Field(default="你好", description="问候语") + + def __init__(self): + self.valves = self.Valves() + + async def action( + self, + body: dict, + __event_emitter__=None, + __user__=None + ) -> Optional[dict]: + user_name = __user__.get("name", "朋友") if __user__ else "朋友" + + if __event_emitter__: + await __event_emitter__({ + "type": "notification", + "data": {"type": "success", "content": f"{self.valves.greeting}, {user_name}!"} + }) + return body +``` + +--- + +## 2. 核心概念与 SDK 详解 + +### 2.1 ⚠️ 重要:同步与异步 + +OpenWebUI 插件运行在 `asyncio` 事件循环中。 +* **原则**:所有 I/O 操作(数据库、文件、网络)必须非阻塞。 +* **陷阱**:直接调用同步方法(如 `time.sleep`, `requests.get`)会卡死整个服务器。 +* **解决**:使用 `await asyncio.to_thread(sync_func, ...)` 包装同步调用。 + +### 2.2 核心参数详解 + +所有插件方法(`inlet`, `outlet`, `pipe`, `action`)都支持注入以下特殊参数: + +| 参数名 | 类型 | 说明 | +| :--- | :--- | :--- | +| `body` | `dict` | **核心数据**。包含 `messages`, `model`, `stream` 等请求信息。 | +| `__user__` | `dict` | **当前用户**。包含 `id`, `name`, `role`, `valves` (用户配置) 等。 | +| `__metadata__` | `dict` | **元数据**。包含 `chat_id`, `message_id`。其中 `variables` 字段包含 `{{USER_NAME}}`, `{{CURRENT_TIME}}` 等预置变量。 | +| `__request__` | `Request` | **FastAPI 请求对象**。可访问 `app.state` 进行跨插件通信。 | +| `__event_emitter__` | `func` | **单向通知**。用于发送 Toast 通知或状态条更新。 | +| `__event_call__` | `func` | **双向交互**。用于在前端执行 JS 代码、弹出确认框或输入框。 | + +### 2.3 配置系统 (Valves) + +* **`Valves`**: 管理员全局配置。 +* **`UserValves`**: 用户级配置(优先级更高,可覆盖全局)。 + +```python +class Filter: + class Valves(BaseModel): + API_KEY: str = Field(default="", description="全局 API Key") + + class UserValves(BaseModel): + API_KEY: str = Field(default="", description="用户私有 API Key") + + def inlet(self, body, __user__): + # 优先使用用户的 Key + user_valves = __user__.get("valves", self.UserValves()) + api_key = user_valves.API_KEY or self.valves.API_KEY +``` + +--- + +## 3. 插件类型深度解析 + +### 3.1 Action (动作) + +**定位**:在消息下方添加按钮,用户点击触发。 + +**高级用法:前端执行 JavaScript (文件下载示例)** + +```python +import base64 + +async def action(self, body, __event_call__): + # 1. 后端生成内容 + content = "Hello OpenWebUI".encode() + b64 = base64.b64encode(content).decode() + + # 2. 发送 JS 到前端执行 + js = f""" + const blob = new Blob([atob('{b64}')], {{type: 'text/plain'}}); + const a = document.createElement('a'); + a.href = URL.createObjectURL(blob); + a.download = 'hello.txt'; + a.click(); + """ + await __event_call__({"type": "execute", "data": {"code": js}}) +``` + +### 3.2 Filter (过滤器) + +**定位**:中间件,拦截并修改请求/响应。 + +* **`inlet`**: 请求前。用于注入上下文、修改模型参数。 +* **`outlet`**: 响应后。用于格式化输出、保存日志。 +* **`stream`**: 流式处理中。用于实时敏感词过滤。 + +**示例:注入环境变量** + +```python +async def inlet(self, body, __metadata__): + vars = __metadata__.get("variables", {}) + context = f"当前时间: {vars.get('{{CURRENT_DATETIME}}')}" + + # 注入到 System Prompt 或第一条消息 + if body.get("messages"): + body["messages"][0]["content"] += f"\n\n{context}" + return body +``` + +### 3.3 Pipe (管道) + +**定位**:自定义模型/代理。 + +**示例:简单的 OpenAI 代理** + +```python +import requests + +class Pipe: + def pipes(self): + return [{"id": "my-gpt", "name": "My GPT Wrapper"}] + + def pipe(self, body): + # 可以在这里修改 body,例如强制添加 prompt + headers = {"Authorization": f"Bearer {self.valves.API_KEY}"} + r = requests.post("https://api.openai.com/v1/chat/completions", json=body, headers=headers, stream=True) + return r.iter_lines() +``` + +--- + +## 4. 高级开发模式 + +### 4.1 Pipe 与 Filter 协同 +利用 `__request__.app.state` 在不同插件间共享数据。 +* **Pipe**: `__request__.app.state.search_results = [...]` +* **Filter (Outlet)**: 读取 `search_results` 并将其格式化为引用链接附加到回复末尾。 + +### 4.2 异步后台任务 +不阻塞用户响应,在后台执行耗时操作(如生成总结、存库)。 + +```python +import asyncio + +async def outlet(self, body, __metadata__): + asyncio.create_task(self.background_job(__metadata__["chat_id"])) + return body + +async def background_job(self, chat_id): + # 执行耗时操作... + pass +``` + +--- + +## 5. 最佳实践与设计原则 + +### 5.1 命名与定位 +* **简短有力**:如 "闪记卡", "精读"。避免 "文本分析助手" 这种泛词。 +* **功能互补**:不要重复造轮子,明确你的插件解决了什么特定问题。 + +### 5.2 用户体验 (UX) +* **反馈及时**:耗时操作前先发送 `notification` ("正在生成...")。 +* **视觉美观**:Action 输出 HTML 时,使用现代化的 CSS(圆角、阴影、渐变)。 +* **智能引导**:检测到文本过短时,提示用户"建议输入更多内容以获得更好结果"。 + +### 5.3 错误处理 +永远不要让插件静默失败。捕获异常并通过 `__event_emitter__` 告知用户。 + +```python +try: + # 业务逻辑 +except Exception as e: + await __event_emitter__({ + "type": "notification", + "data": {"type": "error", "content": f"处理失败: {str(e)}"} + }) +``` + +--- + +## 6. 故障排查 + +* **HTML 不显示?** 确保包裹在 ` ```html ... ``` ` 代码块中。 +* **数据库报错?** 检查是否在 `async` 函数中直接调用了同步的 DB 方法,请使用 `asyncio.to_thread`。 +* **参数未生效?** 检查 `Valves` 定义是否正确,以及是否被 `UserValves` 覆盖。 diff --git a/docs/enhancements/guide.zh.md b/docs/enhancements/guide.zh.md new file mode 100644 index 0000000..2e1d5ee --- /dev/null +++ b/docs/enhancements/guide.zh.md @@ -0,0 +1,178 @@ +# OpenWebUI 增强指南 + +一份全面的指南,帮助你优化与自定义 OpenWebUI 的使用体验。 + +--- + +## 性能优化 + +### 上下文管理 + +合理管理上下文可显著提升回复质量并降低成本。 + +!!! tip "使用上下文压缩" + 安装 [Async Context Compression](../plugins/filters/async-context-compression.md) 过滤器,自动管理长对话。 + +#### 最佳实践 + +1. **清理旧对话**:归档或删除旧聊天保持界面整洁 +2. **聚焦会话**:新话题开启新会话 +3. **利用系统提示词**:明确边界与关注点 +4. **监控 Token**:关注上下文长度 + +### 模型选择 + +根据任务选择合适的模型: + +| 任务类型 | 推荐方式 | +|-----------|---------------------| +| 快速提问 | 较小、较快的模型 | +| 复杂分析 | 更强大的模型 | +| 创意写作 | 提高温度的模型 | +| 代码生成 | 面向代码的模型 | + +--- + +## 自定义技巧 + +### 键盘快捷键 + +常用快捷键可以加速工作流: + +| 快捷键 | 动作 | +|----------|--------| +| `Enter` | 发送消息 | +| `Shift + Enter` | 换行 | +| `↑` | 编辑上一条消息 | +| `Ctrl + /` | 切换侧边栏 | + +### 界面自定义 + +1. **深浅色模式**:使用顶部导航的主题切换 +2. **侧边栏整理**:固定常用对话 +3. **模型收藏**:标星高频模型 + +### 系统提示词模板 + +为常见场景创建可复用的系统提示词: + +```text +# Template: Technical Assistant +You are a technical assistant specializing in [DOMAIN]. +Focus on providing accurate, actionable information. +When unsure, acknowledge limitations and suggest resources. +``` + +--- + +## 工作流优化 + +### 面向开发者 + +1. **代码审查流水线** + - 使用编程类提示词进行初审 + - 通过过滤器保持格式一致 + - 导出到 Excel 便于跟踪 + +2. **文档生成** + - 从 Document Formatter 提示词开始 + - 使用 Summary Action 提炼要点 + - 输出结构化内容 + +### 面向内容创作者 + +1. **内容生产** + - 使用 Marketing 提示词进行创意发散 + - 迭代反馈完善 + - 导出最终版本 + +2. **研究工作流** + - 采用多模型获取多元观点 + - 利用思维导图可视化 + - 创建知识卡片记录要点 + +### 面向学习者 + +1. **学习会话** + - 技术主题用 Code Explainer 讲解 + - 生成知识卡片用于记忆 + - 复杂主题用思维导图梳理 + +--- + +## 插件组合 + +### 推荐组合 + +=== "Developer Stack" + - **Filter**: Context Enhancement + - **Action**: Export to Excel + - **Prompt**: Senior Developer Assistant + +=== "Researcher Stack" + - **Filter**: Async Context Compression + - **Action**: Smart Mind Map + - **Pipeline**: MoE Prompt Refiner + +=== "Student Stack" + - **Action**: Knowledge Card + - **Action**: Smart Mind Map + - **Prompt**: Code Explainer + +--- + +## 高级配置 + +### 自定义 Valves + +很多插件支持 Valves(配置项)。在以下位置可配置: + +1. **Admin Panel** → **Settings** → **Functions** +2. 点开目标插件 +3. 修改 Valve 设置 +4. 保存变更 + +### 用户级覆盖 + +部分插件支持 UserValves,允许用户覆盖全局配置: + +```python +class UserValves(BaseModel): + custom_setting: str = Field( + default="", + description="User-specific configuration" + ) +``` + +--- + +## 故障排查 + +### 常见问题 + +??? question "插件更新后无法工作?" + 尝试禁用再启用插件,或重新上传最新版。 + +??? question "回复太慢?" + - 检查网络连接 + - 尝试更小的模型 + - 若未开启流式输出,可尝试启用 + +??? question "上下文丢失?" + - 查看上下文压缩是否过度 + - 调整 `preserve_recent` 设置 + - 需要时开启新对话 + +### 获取帮助 + +- 查阅插件文档 +- 查看 OpenWebUI 官方文档 +- 加入社区讨论 + +--- + +## 资源 + +- [:fontawesome-brands-github: OpenWebUI GitHub](https://github.com/open-webui/open-webui) +- [:material-book-open-variant: 官方文档](https://docs.openwebui.com/) +- [:material-forum: 社区讨论](https://github.com/open-webui/open-webui/discussions) diff --git a/docs/enhancements/index.zh.md b/docs/enhancements/index.zh.md new file mode 100644 index 0000000..110b3ff --- /dev/null +++ b/docs/enhancements/index.zh.md @@ -0,0 +1,59 @@ +# 增强功能 + +关于优化 OpenWebUI 体验的技巧、窍门与高级配置。 + +--- + +## 增强分类 + +
+ +- :material-tune:{ .lg .middle } **优化指南** + + --- + + 学习如何在性能、自定义与工作流方面优化 OpenWebUI。 + + [:octicons-arrow-right-24: 查看指南](guide.md) + +- :material-puzzle:{ .lg .middle } **插件协同** + + --- + + 多插件组合的最佳实践。 + + [:octicons-arrow-right-24: 浏览插件](../plugins/index.md) + +
+ +--- + +## 快速提示 + +### 性能 + +- :material-speedometer: 为常用模型开启缓存 +- :material-memory: 使用压缩过滤器优化上下文窗口 +- :material-lightning-bolt: 启用流式响应,提升响应感知速度 + +### 自定义 + +- :material-palette: 调整主题与外观 +- :material-keyboard: 配置快捷键 +- :material-cog: 设置默认模型参数 + +### 工作流 + +- :material-robot: 为重复任务创建自定义提示词 +- :material-filter: 通过过滤器保持输出格式一致 +- :material-export: 建立导出流程方便文档化 + +--- + +## 精选指南 + +| 指南 | 描述 | +|-------|-------------| +| [完整优化指南](guide.md) | 全面的 OpenWebUI 使用技巧 | +| [插件开发](../development/index.md) | 学习自制插件 | +| [提示词工程](../prompts/library.md) | 掌握提示词设计 | diff --git a/docs/plugins/actions/export-to-excel.zh.md b/docs/plugins/actions/export-to-excel.zh.md new file mode 100644 index 0000000..1ed4eb3 --- /dev/null +++ b/docs/plugins/actions/export-to-excel.zh.md @@ -0,0 +1,67 @@ +# Export to Excel(导出到 Excel) + +Action +v1.0.0 + +将聊天记录导出为 Excel 表格,便于分析、归档和分享。 + +--- + +## 概览 + +Export to Excel 插件可以把你的聊天记录下载为 Excel 文件,适用于: + +- 归档重要对话 +- 分析聊天数据 +- 与同事共享对话内容 +- 将 AI 辅助的研究整理成文档 + +## 功能特性 + +- :material-file-excel: **Excel 导出**:标准 `.xlsx` 格式 +- :material-table: **格式化输出**:整洁的表格结构 +- :material-download: **一键下载**:即时生成文件 +- :material-history: **完整历史**:导出完整会话内容 + +--- + +## 安装 + +1. 下载插件文件:[`export_to_excel.py`](https://github.com/Fu-Jie/awesome-openwebui/tree/main/plugins/actions/export_to_excel) +2. 上传到 OpenWebUI:**Admin Panel** → **Settings** → **Functions** +3. 启用插件 + +--- + +## 使用方法 + +1. 打开想要导出的对话 +2. 点击消息操作栏中的 **Export** 按钮 +3. Excel 文件会自动下载 + +--- + +## 导出格式 + +生成的 Excel 文件包含: + +| 列 | 说明 | +|--------|-------------| +| Timestamp | 消息发送时间 | +| Role | 角色(用户 / 助手) | +| Content | 消息文本内容 | +| Model | 使用的模型(助手消息) | + +--- + +## 运行要求 + +!!! note "前置条件" + - OpenWebUI v0.3.0 及以上 + - 无需额外 Python 依赖(使用内置库) + +--- + +## 源码 + +[:fontawesome-brands-github: 在 GitHub 查看](https://github.com/Fu-Jie/awesome-openwebui/tree/main/plugins/actions/export_to_excel){ .md-button } diff --git a/docs/plugins/actions/index.zh.md b/docs/plugins/actions/index.zh.md new file mode 100644 index 0000000..563b114 --- /dev/null +++ b/docs/plugins/actions/index.zh.md @@ -0,0 +1,151 @@ +# Action 插件 + +Action 插件会在聊天界面的消息下方添加自定义按钮,让你一键触发特定功能。 + +## 什么是 Actions? + +Actions 是交互式插件,能够: + +- :material-gesture-tap: 在消息操作栏添加按钮 +- :material-export: 生成并导出内容(思维导图、图表、文件等) +- :material-api: 与外部服务和 API 交互 +- :material-animation-play: 创建可视化或交互内容 + +--- + +## 可用的 Action 插件 + +
+ +- :material-brain:{ .lg .middle } **Smart Mind Map** + + --- + + 智能分析文本并生成交互式、精美的思维导图。 + + **版本:** 0.7.2 + + [:octicons-arrow-right-24: 查看文档](smart-mind-map.md) + +- :material-chart-bar:{ .lg .middle } **Smart Infographic** + + --- + + 使用 AntV 可视化引擎,将文本转成专业的信息图。 + + **版本:** 1.0.0 + + [:octicons-arrow-right-24: 查看文档](smart-infographic.md) + +- :material-card-text:{ .lg .middle } **Knowledge Card** + + --- + + 快速生成精美的学习记忆卡片,适合学习与记忆。 + + **版本:** 0.2.0 + + [:octicons-arrow-right-24: 查看文档](knowledge-card.md) + +- :material-file-excel:{ .lg .middle } **Export to Excel** + + --- + + 将聊天记录导出为 Excel 电子表格,方便分析或归档。 + + **版本:** 1.0.0 + + [:octicons-arrow-right-24: 查看文档](export-to-excel.md) + +- :material-text-box-search:{ .lg .middle } **Summary** + + --- + + 对长文本进行精简总结,提取要点。 + + **版本:** 1.0.0 + + [:octicons-arrow-right-24: 查看文档](summary.md) + +
+ +--- + +## 快速安装 + +1. 下载需要的 `.py` 插件文件 +2. 前往 **Admin Panel** → **Settings** → **Functions** +3. 上传文件并完成配置 +4. 在聊天消息中使用对应的 Action 按钮 + +--- + +## 开发模板 + +想要自己编写 Action 插件?可以参考下面的模板: + +```python +""" +title: My Custom Action +author: Your Name +version: 1.0.0 +description: Description of your action plugin +""" + +from pydantic import BaseModel, Field +from typing import Optional, Dict, Any + +class Action: + class Valves(BaseModel): + # 在这里添加你的配置项 + show_status: bool = Field( + default=True, + description="Show status updates during processing" + ) + + def __init__(self): + self.valves = self.Valves() + + async def action( + self, + body: dict, + __user__: Optional[Dict[str, Any]] = None, + __event_emitter__: Optional[Any] = None, + __request__: Optional[Any] = None, + ) -> Optional[dict]: + """ + 当用户点击 Action 按钮时触发的主方法。 + + Args: + body: 包含会话数据的消息体 + __user__: 当前用户信息 + __event_emitter__: 用于发送通知或状态更新 + __request__: FastAPI 请求对象 + + Returns: + 修改后的 body 字典或 None + """ + # 发送状态更新 + if __event_emitter__ and self.valves.show_status: + await __event_emitter__({ + "type": "status", + "data": {"description": "Processing...", "done": False} + }) + + # 插件逻辑 + messages = body.get("messages", []) + if messages: + last_message = messages[-1].get("content", "") + # 在这里处理消息... + + # 完成状态 + if __event_emitter__ and self.valves.show_status: + await __event_emitter__({ + "type": "status", + "data": {"description": "Done!", "done": True} + }) + + return body +``` + +更多详情可查看 [插件开发指南](../../development/plugin-guide.md)。 diff --git a/docs/plugins/actions/knowledge-card.zh.md b/docs/plugins/actions/knowledge-card.zh.md new file mode 100644 index 0000000..6c55446 --- /dev/null +++ b/docs/plugins/actions/knowledge-card.zh.md @@ -0,0 +1,88 @@ +# Knowledge Card(知识卡片) + +Action +v0.2.0 + +快速生成精美的学习记忆卡片,适合学习和速记。 + +--- + +## 概览 + +Knowledge Card 插件(又名 Flash Card / 闪记卡)会把内容转成视觉友好的记忆卡片,帮助你高效学习和记忆。无论备考、理解新概念或复习要点,都能用它快速生成学习素材。 + +## 功能特性 + +- :material-card-text: **精美卡片**:现代简洁的版式,便于阅读 +- :material-animation-play: **可交互**:点击翻转查看答案 +- :material-export: **可导出**:支持保存离线学习 +- :material-palette: **可定制**:多种主题与样式 +- :material-translate: **多语言**:支持多语言内容 + +--- + +## 安装 + +1. 下载插件文件:[`knowledge_card.py`](https://github.com/Fu-Jie/awesome-openwebui/tree/main/plugins/actions/knowledge-card) +2. 上传到 OpenWebUI:**Admin Panel** → **Settings** → **Functions** +3. 启用插件 + +--- + +## 使用方法 + +1. 与 AI 就你想学习的主题进行对话 +2. 点击消息操作栏的 **Flash Card** 按钮 +3. 插件会分析内容并生成卡片 +4. 点击卡片翻面查看答案 + +--- + +## 配置项 + +| 选项 | 类型 | 默认值 | 说明 | +|--------|------|---------|-------------| +| `cards_per_message` | integer | `5` | 每条消息最多生成的卡片数量 | +| `theme` | string | `"modern"` | 视觉主题 | +| `show_hints` | boolean | `true` | 是否在卡片上显示提示 | + +--- + +## 示例 + +=== "问题面" + ``` + ┌─────────────────────────────┐ + │ │ + │ What is the capital of │ + │ France? │ + │ │ + │ [Click to flip] │ + └─────────────────────────────┘ + ``` + +=== "答案面" + ``` + ┌─────────────────────────────┐ + │ │ + │ Paris │ + │ │ + │ The city of lights, │ + │ located on the Seine │ + │ │ + └─────────────────────────────┘ + ``` + +--- + +## 运行要求 + +!!! note "前置条件" + - OpenWebUI v0.3.0 及以上 + - 无需额外 Python 依赖 + +--- + +## 源码 + +[:fontawesome-brands-github: 在 GitHub 查看](https://github.com/Fu-Jie/awesome-openwebui/tree/main/plugins/actions/knowledge-card){ .md-button } diff --git a/docs/plugins/actions/smart-infographic.zh.md b/docs/plugins/actions/smart-infographic.zh.md new file mode 100644 index 0000000..d2c5ecd --- /dev/null +++ b/docs/plugins/actions/smart-infographic.zh.md @@ -0,0 +1,107 @@ +# Smart Infographic(智能信息图) + +Action +v1.0.0 + +基于 AntV 信息图引擎,将长文本一键转成专业、美观的信息图。 + +--- + +## 概览 + +Smart Infographic 使用 AI 分析文本,并基于 AntV 可视化引擎生成专业的信息图。它会自动提取要点,并用合适的图表/结构呈现。 + +## 功能特性 + +- :material-robot: **AI 转换**:自动分析文本逻辑,提取要点并生成结构化图表 +- :material-palette: **专业模板**:内置 AntV 官方模板:列表、树、思维导图、对比表、流程图、统计图等 +- :material-magnify: **自动匹配图标**:根据内容自动选择最合适的 Material Design Icons +- :material-download: **多格式导出**:支持下载 **SVG**、**PNG**、**独立 HTML** +- :material-theme-light-dark: **主题支持**:适配深色/浅色模式 +- :material-cellphone-link: **响应式**:桌面与移动端都能良好展示 + +--- + +## 安装 + +1. 下载插件文件:[`infographic.py`](https://github.com/Fu-Jie/awesome-openwebui/tree/main/plugins/actions/infographic) +2. 上传到 OpenWebUI:**Admin Panel** → **Settings** → **Functions** +3. 可选:根据需要配置插件选项 +4. 启用插件 + +--- + +## 支持的模板类型 + +| 分类 | 模板名称 | 典型场景 | +|:---------|:--------------|:---------| +| **列表与层级** | `list-grid`, `tree-vertical`, `mindmap` | 特性列表、组织结构、头脑风暴 | +| **序列与关系** | `sequence-roadmap`, `relation-circle` | 路线图、循环流程、步骤拆解 | +| **对比与分析** | `compare-binary`, `compare-swot`, `quadrant-quarter` | 优劣势、SWOT、象限分析 | +| **图表与数据** | `chart-bar`, `chart-line`, `chart-pie` | 趋势、分布、指标对比 | + +--- + +## 使用方法 + +1. 在聊天中输入需要可视化的文本 +2. 点击消息操作栏的 **Infographic**(📊)按钮 +3. 等待 AI 分析并生成信息图 +4. 预览结果,可用下载按钮保存 + +--- + +## 配置项 + +| 选项 | 类型 | 默认值 | 说明 | +|--------|------|---------|-------------| +| `SHOW_STATUS` | boolean | `true` | 是否展示实时的分析/生成状态 | +| `MODEL_ID` | string | `""` | 指定用于分析的 LLM 模型,留空则使用当前会话模型 | +| `MIN_TEXT_LENGTH` | integer | `100` | 触发分析的最小字符数 | +| `CLEAR_PREVIOUS_HTML` | boolean | `false` | 是否清空之前生成的图表 | +| `MESSAGE_COUNT` | integer | `1` | 参与分析的最近消息条数 | + +--- + +## 语法示例(高级用法) + +也可以直接输入信息图语法进行渲染: + +```infographic +infographic list-grid +data + title 🚀 Plugin Benefits + desc Why use the Smart Infographic plugin + items + - label Fast Generation + desc Convert text to charts in seconds + - label Beautiful Design + desc Uses AntV professional design standards +``` + +--- + +## 运行要求 + +!!! note "前置条件" + - OpenWebUI v0.3.0 及以上 + - 无需额外 Python 依赖(使用 OpenWebUI 内置依赖) + +--- + +## 常见问题 + +??? question "没有生成信息图?" + 请确认文本长度至少 100 字符(可通过 `MIN_TEXT_LENGTH` 调整)。 + +??? question "模板与内容不匹配?" + AI 会根据内容结构自动选择模板,如需指定可使用高级语法。 + +??? question "导出失败?" + 确认浏览器支持 HTML5 Canvas 和 SVG,尝试刷新页面。 + +--- + +## 源码 + +[:fontawesome-brands-github: 在 GitHub 查看](https://github.com/Fu-Jie/awesome-openwebui/tree/main/plugins/actions/infographic){ .md-button } diff --git a/docs/plugins/actions/smart-mind-map.zh.md b/docs/plugins/actions/smart-mind-map.zh.md new file mode 100644 index 0000000..a6709bc --- /dev/null +++ b/docs/plugins/actions/smart-mind-map.zh.md @@ -0,0 +1,91 @@ +# Smart Mind Map(智能思维导图) + +Action +v0.7.2 + +智能分析文本内容,生成交互式思维导图,帮助你更直观地理解信息结构。 + +--- + +## 概览 + +Smart Mind Map 会将文本转换成漂亮的交互式思维导图。插件会用 AI 分析内容结构,生成层级化的可视化,帮助快速梳理复杂信息。 + +## 功能特性 + +- :material-brain: **AI 分析**:智能提取关键概念与关联关系 +- :material-gesture-swipe: **交互导航**:支持缩放、平移、展开/折叠 +- :material-palette: **精美样式**:现代化配色,支持自定义主题 +- :material-download: **导出**:可保存为图片或结构化数据 +- :material-translate: **多语言**:支持多语言文本分析 + +--- + +## 安装 + +1. 下载插件文件:[`smart_mind_map.py`](https://github.com/Fu-Jie/awesome-openwebui/tree/main/plugins/actions/smart-mind-map) +2. 上传到 OpenWebUI:**Admin Panel** → **Settings** → **Functions** +3. 启用插件 + +--- + +## 使用方法 + +1. 先与 AI 对话并生成回复 +2. 点击消息操作栏中的 **Mind Map** 按钮 +3. 等待思维导图生成 +4. 交互使用: + - **缩放**:滚轮缩放 + - **平移**:按住拖动 + - **展开/折叠**:点击节点显示或隐藏子节点 + +--- + +## 配置项 + +| 选项 | 类型 | 默认值 | 说明 | +|--------|------|---------|-------------| +| `show_status` | boolean | `true` | 是否显示处理状态更新 | +| `max_depth` | integer | `5` | 思维导图的最大层级 | +| `theme` | string | `"default"` | 可视化的主题配色 | + +--- + +## 输出示例 + +插件会在聊天中嵌入交互式 HTML 思维导图: + +``` +📊 Mind Map Generated +├── Main Topic +│ ├── Subtopic 1 +│ │ ├── Detail A +│ │ └── Detail B +│ ├── Subtopic 2 +│ └── Subtopic 3 +└── Related Concepts +``` + +--- + +## 运行要求 + +!!! note "前置条件" + - OpenWebUI v0.3.0 及以上 + - 无需额外 Python 依赖 + +--- + +## 常见问题 + +??? question "思维导图不显示?" + 请确认浏览器支持 HTML5 Canvas,并且已开启 JavaScript。 + +??? question "生成时间过长?" + 对超长文本,AI 分析会更耗时。建议拆分内容后再生成。 + +--- + +## 源码 + +[:fontawesome-brands-github: 在 GitHub 查看](https://github.com/Fu-Jie/awesome-openwebui/tree/main/plugins/actions/smart-mind-map){ .md-button } diff --git a/docs/plugins/actions/summary.zh.md b/docs/plugins/actions/summary.zh.md new file mode 100644 index 0000000..811bfb3 --- /dev/null +++ b/docs/plugins/actions/summary.zh.md @@ -0,0 +1,82 @@ +# Summary(摘要) + +Action +v1.0.0 + +为长文本生成简洁摘要,并提取关键要点。 + +--- + +## 概览 + +Summary 插件可以快速理解长文本,生成精炼摘要并列出关键点,适合: + +- 总结长文章或文档 +- 从对话中提炼要点 +- 为复杂主题制作快速概览 + +## 功能特性 + +- :material-text-box-search: **智能摘要**:AI 驱动的内容分析 +- :material-format-list-bulleted: **关键点**:提取重要信息 +- :material-content-copy: **便捷复制**:一键复制摘要 +- :material-tune: **长度可调**:可选择摘要详略程度 + +--- + +## 安装 + +1. 下载插件文件:[`summary.py`](https://github.com/Fu-Jie/awesome-openwebui/tree/main/plugins/actions/summary) +2. 上传到 OpenWebUI:**Admin Panel** → **Settings** → **Functions** +3. 启用插件 + +--- + +## 使用方法 + +1. 获取一段较长的 AI 回复或粘贴长文本 +2. 点击消息操作栏的 **Summary** 按钮 +3. 查看生成的摘要与关键点 + +--- + +## 配置项 + +| 选项 | 类型 | 默认值 | 说明 | +|--------|------|---------|-------------| +| `summary_length` | string | `"medium"` | 摘要长度(short/medium/long) | +| `include_key_points` | boolean | `true` | 是否提取并列出关键点 | +| `language` | string | `"auto"` | 输出语言 | + +--- + +## 输出示例 + +```markdown +## Summary + +This document discusses the implementation of a new feature +for the application, focusing on user experience improvements +and performance optimizations. + +### Key Points + +- ✅ New user interface design improves accessibility +- ✅ Backend optimizations reduce load times by 40% +- ✅ Mobile responsiveness enhanced +- ✅ Integration with third-party services simplified +``` + +--- + +## 运行要求 + +!!! note "前置条件" + - OpenWebUI v0.3.0 及以上 + - 使用当前会话的 LLM 模型进行摘要 + +--- + +## 源码 + +[:fontawesome-brands-github: 在 GitHub 查看](https://github.com/Fu-Jie/awesome-openwebui/tree/main/plugins/actions/summary){ .md-button } diff --git a/docs/plugins/filters/async-context-compression.zh.md b/docs/plugins/filters/async-context-compression.zh.md new file mode 100644 index 0000000..3043866 --- /dev/null +++ b/docs/plugins/filters/async-context-compression.zh.md @@ -0,0 +1,122 @@ +# Async Context Compression(异步上下文压缩) + +Filter +v1.0.0 + +通过智能摘要减少长对话的 token 消耗,同时保持对话连贯。 + +--- + +## 概览 + +Async Context Compression 过滤器通过以下方式帮助管理长对话的 token 使用: + +- 智能总结较早的消息 +- 保留关键信息 +- 降低 API 成本 +- 保持对话一致性 + +特别适用于: + +- 长时间会话 +- 多轮复杂讨论 +- 成本优化 +- 上下文长度控制 + +## 功能特性 + +- :material-arrow-collapse-vertical: **智能压缩**:AI 驱动的上下文摘要 +- :material-clock-fast: **异步处理**:后台非阻塞压缩 +- :material-memory: **保留上下文**:尽量保留重要信息 +- :material-currency-usd-off: **降低成本**:减少 token 使用 + +--- + +## 安装 + +1. 下载插件文件:[`async_context_compression.py`](https://github.com/Fu-Jie/awesome-openwebui/tree/main/plugins/filters/async-context-compression) +2. 上传到 OpenWebUI:**Admin Panel** → **Settings** → **Functions** +3. 配置压缩参数 +4. 启用过滤器 + +--- + +## 工作原理 + +```mermaid +graph TD + A[Incoming Messages] --> B{Token Count > Threshold?} + B -->|No| C[Pass Through] + B -->|Yes| D[Summarize Older Messages] + D --> E[Preserve Recent Messages] + E --> F[Combine Summary + Recent] + F --> G[Send to LLM] +``` + +--- + +## 配置项 + +| 选项 | 类型 | 默认值 | 说明 | +|--------|------|---------|-------------| +| `token_threshold` | integer | `4000` | 超过该 token 数触发压缩 | +| `preserve_recent` | integer | `5` | 保留不压缩的最近消息数量 | +| `summary_model` | string | `"auto"` | 用于摘要的模型 | +| `compression_ratio` | float | `0.3` | 目标压缩比例 | + +--- + +## 示例 + +### 压缩前 + +``` +[Message 1] User: Tell me about Python... +[Message 2] AI: Python is a programming language... +[Message 3] User: What about its history? +[Message 4] AI: Python was created by Guido... +[Message 5] User: And its features? +[Message 6] AI: Python has many features... +... (many more messages) +[Message 20] User: Current question +``` + +### 压缩后 + +``` +[Summary] Previous conversation covered Python basics, +history, features, and common use cases... + +[Message 18] User: Recent question about decorators +[Message 19] AI: Decorators in Python are... +[Message 20] User: Current question +``` + +--- + +## 运行要求 + +!!! note "前置条件" + - OpenWebUI v0.3.0 及以上 + - 需要可用的 LLM 用于摘要 + +!!! tip "最佳实践" + - 根据模型上下文窗口设置合适的 token 阈值 + - 技术讨论可适当提高 `preserve_recent` + - 先在非关键对话中测试压缩效果 + +--- + +## 常见问题 + +??? question "没有触发压缩?" + 检查 token 数是否超过配置的阈值,并开启调试日志了解细节。 + +??? question "重要上下文丢失?" + 提高 `preserve_recent` 或降低压缩比例。 + +--- + +## 源码 + +[:fontawesome-brands-github: 在 GitHub 查看](https://github.com/Fu-Jie/awesome-openwebui/tree/main/plugins/filters/async-context-compression){ .md-button } diff --git a/docs/plugins/filters/context-enhancement.zh.md b/docs/plugins/filters/context-enhancement.zh.md new file mode 100644 index 0000000..4ee62c9 --- /dev/null +++ b/docs/plugins/filters/context-enhancement.zh.md @@ -0,0 +1,51 @@ +# Context Enhancement(上下文增强) + +Filter +v1.0.0 + +为聊天自动补充上下文信息,让 LLM 回复更相关、更准确。 + +--- + +## 概览 + +Context Enhancement 过滤器会自动为会话补充必要的上下文,使模型回答更加贴切。 + +## 功能特性 + +- :material-text-box-plus: **自动增强**:智能添加相关上下文 +- :material-clock: **时间感知**:包含当前日期/时间信息 +- :material-account: **用户上下文**:加入用户偏好或姓名等信息 +- :material-cog: **可定制**:可配置要附加的上下文内容 + +--- + +## 安装 + +1. 下载插件文件:[`context_enhancement_filter.py`](https://github.com/Fu-Jie/awesome-openwebui/tree/main/plugins/filters/context_enhancement_filter) +2. 上传到 OpenWebUI:**Admin Panel** → **Settings** → **Functions** +3. 配置增强选项 +4. 启用过滤器 + +--- + +## 配置项 + +| 选项 | 类型 | 默认值 | 说明 | +|--------|------|---------|-------------| +| `include_datetime` | boolean | `true` | 是否添加当前日期时间 | +| `include_user_info` | boolean | `true` | 是否添加用户名和偏好 | +| `custom_context` | string | `""` | 始终附加的自定义上下文 | + +--- + +## 运行要求 + +!!! note "前置条件" + - OpenWebUI v0.3.0 及以上 + +--- + +## 源码 + +[:fontawesome-brands-github: 在 GitHub 查看](https://github.com/Fu-Jie/awesome-openwebui/tree/main/plugins/filters/context_enhancement_filter){ .md-button } diff --git a/docs/plugins/filters/gemini-manifold-companion.zh.md b/docs/plugins/filters/gemini-manifold-companion.zh.md new file mode 100644 index 0000000..cc10a6e --- /dev/null +++ b/docs/plugins/filters/gemini-manifold-companion.zh.md @@ -0,0 +1,54 @@ +# Gemini Manifold Companion + +Filter +v1.0.0 + +Gemini Manifold Pipe 的伴随过滤器,用于增强 Gemini 集成的处理效果。 + +--- + +## 概览 + +Gemini Manifold Companion 与 [Gemini Manifold Pipe](../pipes/gemini-manifold.md) 搭配使用,为 Gemini 模型集成提供额外的处理与优化。 + +## 功能特性 + +- :material-handshake: **无缝协同**:与 Gemini Manifold Pipe 配合工作 +- :material-format-text: **消息格式化**:针对 Gemini 优化消息 +- :material-shield: **错误处理**:更友好的 API 异常处理 +- :material-tune: **精细配置**:提供额外调优选项 + +--- + +## 安装 + +1. 先安装 [Gemini Manifold Pipe](../pipes/gemini-manifold.md) +2. 下载伴随过滤器:[`gemini_manifold_companion.py`](https://github.com/Fu-Jie/awesome-openwebui/tree/main/plugins/filters/gemini_manifold_companion) +3. 上传到 OpenWebUI:**Admin Panel** → **Settings** → **Functions** +4. 启用过滤器 + +--- + +## 配置项 + +| 选项 | 类型 | 默认值 | 说明 | +|--------|------|---------|-------------| +| `auto_format` | boolean | `true` | 为 Gemini 自动格式化消息 | +| `handle_errors` | boolean | `true` | 开启错误处理 | + +--- + +## 运行要求 + +!!! warning "依赖" + 本过滤器需要先安装并配置 **Gemini Manifold Pipe**。 + +!!! note "前置条件" + - OpenWebUI v0.3.0 及以上 + - 已安装 Gemini Manifold Pipe + +--- + +## 源码 + +[:fontawesome-brands-github: 在 GitHub 查看](https://github.com/Fu-Jie/awesome-openwebui/tree/main/plugins/filters/gemini_manifold_companion){ .md-button } diff --git a/docs/plugins/filters/index.zh.md b/docs/plugins/filters/index.zh.md new file mode 100644 index 0000000..250448e --- /dev/null +++ b/docs/plugins/filters/index.zh.md @@ -0,0 +1,155 @@ +# Filter 插件 + +Filter 插件会在消息发送到 LLM 之前或响应生成之后处理和修改内容。 + +## 什么是 Filters? + +Filter 充当消息管线中的中间件: + +- :material-arrow-right-bold: **Inlet**:在消息到达 LLM 前处理用户消息 +- :material-arrow-left-bold: **Outlet**:在展示前处理 LLM 响应 +- :material-stream: **Stream**:对流式响应进行实时处理 + +--- + +## 可用的 Filter 插件 + +
+ +- :material-compress:{ .lg .middle } **Async Context Compression** + + --- + + 通过智能总结减少长对话的 token 消耗,同时保持连贯性。 + + **版本:** 1.0.0 + + [:octicons-arrow-right-24: 查看文档](async-context-compression.md) + +- :material-text-box-plus:{ .lg .middle } **Context Enhancement** + + --- + + 为聊天增加额外信息,提升回复质量。 + + **版本:** 1.0.0 + + [:octicons-arrow-right-24: 查看文档](context-enhancement.md) + +- :material-google:{ .lg .middle } **Gemini Manifold Companion** + + --- + + Gemini Manifold Pipe 插件的伴随过滤器。 + + **版本:** 1.0.0 + + [:octicons-arrow-right-24: 查看文档](gemini-manifold-companion.md) + +
+ +--- + +## Filter 工作流程 + +```mermaid +graph LR + A[User Message] --> B[Inlet Filter] + B --> C[LLM] + C --> D[Outlet Filter] + D --> E[Display to User] +``` + +### Inlet 处理 + +`inlet` 方法在消息到达 LLM 前处理: + +```python +async def inlet(self, body: dict, __metadata__: dict) -> dict: + # 在发送到 LLM 前修改请求 + messages = body.get("messages", []) + # 添加上下文、调整 prompt 等 + return body +``` + +### Outlet 处理 + +`outlet` 方法在响应生成后处理: + +```python +async def outlet(self, body: dict, __metadata__: dict) -> dict: + # 在展示前修改响应 + messages = body.get("messages", []) + # 格式化输出、追加引用等 + return body +``` + +--- + +## 快速安装 + +1. 下载需要的 Filter `.py` 文件 +2. 前往 **Admin Panel** → **Settings** → **Functions** +3. 上传文件并配置 +4. 在聊天设置或全局启用该过滤器 + +--- + +## 开发模板 + +```python +""" +title: My Custom Filter +author: Your Name +version: 1.0.0 +description: Description of your filter plugin +""" + +from pydantic import BaseModel, Field +from typing import Optional + +class Filter: + class Valves(BaseModel): + priority: int = Field( + default=0, + description="Filter priority (lower = earlier execution)" + ) + enabled: bool = Field( + default=True, + description="Enable/disable this filter" + ) + + def __init__(self): + self.valves = self.Valves() + + async def inlet( + self, + body: dict, + __user__: Optional[dict] = None, + __metadata__: Optional[dict] = None + ) -> dict: + """Process messages before sending to LLM.""" + if not self.valves.enabled: + return body + + # 你的 inlet 逻辑 + messages = body.get("messages", []) + + return body + + async def outlet( + self, + body: dict, + __user__: Optional[dict] = None, + __metadata__: Optional[dict] = None + ) -> dict: + """Process responses before displaying.""" + if not self.valves.enabled: + return body + + # 你的 outlet 逻辑 + + return body +``` + +更多细节见 [插件开发指南](../../development/plugin-guide.md)。 diff --git a/docs/plugins/index.zh.md b/docs/plugins/index.zh.md new file mode 100644 index 0000000..df64fa0 --- /dev/null +++ b/docs/plugins/index.zh.md @@ -0,0 +1,93 @@ +# 插件中心 + +欢迎来到 OpenWebUI Extras 插件中心!在这里你可以找到完整的插件集合,帮助你强化 OpenWebUI 的体验。 + +## 插件类型 + +OpenWebUI 支持四种类型的插件,每种都有不同的用途: + +
+ +- :material-gesture-tap:{ .lg .middle } **Actions(动作)** + + --- + + 在消息下方添加自定义按钮,一键触发思维导图、数据导出或可视化等操作。 + + [:octicons-arrow-right-24: 浏览 Actions](actions/index.md) + +- :material-filter:{ .lg .middle } **Filters(过滤器)** + + --- + + 在请求到达 LLM 之前或响应生成之后处理和修改消息,适合做上下文增强和压缩。 + + [:octicons-arrow-right-24: 浏览 Filters](filters/index.md) + +- :material-pipe:{ .lg .middle } **Pipes(管道)** + + --- + + 创建自定义模型集成或转换 LLM 响应,可连接外部 API 或自定义模型逻辑。 + + [:octicons-arrow-right-24: 浏览 Pipes](pipes/index.md) + +- :material-pipe-wrench:{ .lg .middle } **Pipelines(流水线)** + + --- + + 将多步处理组合为复杂工作流,适合需要多阶段转换的高级场景。 + + [:octicons-arrow-right-24: 浏览 Pipelines](pipelines/index.md) + +
+ +--- + +## 插件总览 + +| 插件 | 类型 | 描述 | 版本 | +|--------|------|-------------|---------| +| [Smart Mind Map(智能思维导图)](actions/smart-mind-map.md) | Action | 从文本生成交互式思维导图 | 0.7.2 | +| [Smart Infographic(智能信息图)](actions/smart-infographic.md) | Action | 将文本转成专业信息图 | 1.0.0 | +| [Knowledge Card(知识卡片)](actions/knowledge-card.md) | Action | 生成精美学习卡片 | 0.2.0 | +| [Export to Excel(导出到 Excel)](actions/export-to-excel.md) | Action | 导出聊天记录为 Excel | 1.0.0 | +| [Summary(摘要)](actions/summary.md) | Action | 文本摘要工具 | 1.0.0 | +| [Async Context Compression(异步上下文压缩)](filters/async-context-compression.md) | Filter | 智能上下文压缩 | 1.0.0 | +| [Context Enhancement(上下文增强)](filters/context-enhancement.md) | Filter | 提升对话上下文 | 1.0.0 | +| [Gemini Manifold Companion](filters/gemini-manifold-companion.md) | Filter | Gemini Manifold 伴侣 | 1.0.0 | +| [Gemini Manifold](pipes/gemini-manifold.md) | Pipe | Gemini 模型集成 | 1.0.0 | +| [MoE Prompt Refiner](pipelines/moe-prompt-refiner.md) | Pipeline | 多模型提示词优化 | 1.0.0 | + +--- + +## 安装指南 + +### 步骤 1:下载插件 + +点击上方任意插件,查看文档并下载对应的 `.py` 文件。 + +### 步骤 2:上传到 OpenWebUI + +1. 打开 OpenWebUI,进入 **Admin Panel** → **Settings** → **Functions** +2. 点击 **+** 按钮添加新的 Function +3. 上传下载好的 `.py` 文件 +4. 配置必要的设置(如 API Key、选项等) + +### 步骤 3:启用并使用 + +1. 上传后刷新页面 +2. **Actions**:在消息操作栏中找到插件按钮 +3. **Filters**:在聊天设置或全局启用 +4. **Pipes**:在模型下拉中选择自定义模型 +5. **Pipelines**:在流水线设置中配置并启用 + +--- + +## 兼容性提示 + +!!! info "OpenWebUI 版本" + 本仓库的大多数插件面向 **OpenWebUI v0.3.0** 及以上版本。具体要求请查看各插件文档。 + +!!! warning "依赖说明" + 部分插件可能需要额外的 Python 依赖,请查看对应插件文档确认。 diff --git a/docs/plugins/pipelines/index.zh.md b/docs/plugins/pipelines/index.zh.md new file mode 100644 index 0000000..7a67990 --- /dev/null +++ b/docs/plugins/pipelines/index.zh.md @@ -0,0 +1,63 @@ +# Pipeline 插件 + +Pipeline 是组合多步处理的复杂工作流,适用于高级场景。 + +## 什么是 Pipelines? + +Pipelines 不仅是简单转换,还可以实现: + +- :material-workflow: 多步骤处理流程 +- :material-source-merge: 模型编排 +- :material-robot-industrial: 高级智能体行为 +- :material-cog-box: 复杂业务逻辑 + +--- + +## 可用的 Pipeline 插件 + +
+ +- :material-view-module:{ .lg .middle } **MoE Prompt Refiner** + + --- + + 为 Mixture of Experts(MoE)汇总请求优化提示词,生成高质量综合报告。 + + **版本:** 1.0.0 + + [:octicons-arrow-right-24: 查看文档](moe-prompt-refiner.md) + +
+ +--- + +## Pipelines 的区别 + +| 特性 | Filters | Pipes | Pipelines | +|---------|---------|-------|-----------| +| 复杂度 | 低 | 中 | 高 | +| 主要用途 | 消息处理 | 模型集成 | 多步工作流 | +| 执行方式 | LLM 前后 | 作为 LLM | 自定义编排 | +| 依赖 | 极少 | API 访问 | 往往多个服务 | + +--- + +## 快速安装 + +1. 下载 Pipeline `.py` 文件 +2. 前往 **Admin Panel** → **Settings** → **Functions** +3. 上传并配置所需服务 +4. 启用该 Pipeline + +--- + +## 开发注意事项 + +Pipeline 通常需要: + +- 多个 API 集成 +- 跨步骤的状态管理 +- 每一步的错误处理 +- 性能优化 + +详见 [插件开发指南](../../development/plugin-guide.md)。 diff --git a/docs/plugins/pipelines/moe-prompt-refiner.zh.md b/docs/plugins/pipelines/moe-prompt-refiner.zh.md new file mode 100644 index 0000000..b77c5e9 --- /dev/null +++ b/docs/plugins/pipelines/moe-prompt-refiner.zh.md @@ -0,0 +1,109 @@ +# MoE Prompt Refiner + +Pipeline +v1.0.0 + +为 Mixture of Experts(MoE)汇总请求优化提示词,生成高质量的综合报告。 + +--- + +## 概览 + +MoE Prompt Refiner 是一个高级 Pipeline,会在将请求发送给多个专家模型前先优化提示词,然后综合各模型回复,输出结构化的高质量报告。 + +## 功能特性 + +- :material-view-module: **多模型**:同时利用多个 AI 模型 +- :material-text-search: **提示词优化**:在发送前优化 prompt 获得更好结果 +- :material-merge: **结果合成**:整合专家回复 +- :material-file-document: **报告生成**:输出结构化报告 + +--- + +## 安装 + +1. 下载 Pipeline 文件:[`moe_prompt_refiner.py`](https://github.com/Fu-Jie/awesome-openwebui/tree/main/plugins/pipelines) +2. 上传到 OpenWebUI:**Admin Panel** → **Settings** → **Functions** +3. 配置专家模型及相关参数 +4. 启用该 Pipeline + +--- + +## 工作流程 + +```mermaid +graph TD + A[User Prompt] --> B[Prompt Refiner] + B --> C[Expert Model 1] + B --> D[Expert Model 2] + B --> E[Expert Model N] + C --> F[Response Synthesizer] + D --> F + E --> F + F --> G[Comprehensive Report] +``` + +--- + +## 配置项 + +| 选项 | 类型 | 默认值 | 说明 | +|--------|------|---------|-------------| +| `expert_models` | list | `[]` | 需要咨询的模型列表 | +| `synthesis_model` | string | `"auto"` | 用于综合回复的模型 | +| `report_format` | string | `"markdown"` | 输出格式 | + +--- + +## 适用场景 + +- **研究报告**:从多个 AI 视角收集洞见 +- **综合分析**:多角度问题拆解 +- **决策支持**:获得多模型的平衡建议 +- **内容创作**:生成多视角的丰富内容 + +--- + +## 示例 + +**输入 Prompt:** +``` +Analyze the pros and cons of microservices architecture +``` + +**输出报告:** +```markdown +# Microservices Architecture Analysis + +## Executive Summary +Based on analysis from multiple expert perspectives... + +## Advantages +1. **Scalability** (Expert A)... +2. **Technology Flexibility** (Expert B)... + +## Disadvantages +1. **Complexity** (Expert A)... +2. **Distributed System Challenges** (Expert C)... + +## Recommendations +Synthesized recommendations based on expert consensus... +``` + +--- + +## 运行要求 + +!!! note "前置条件" + - OpenWebUI v0.3.0 及以上 + - 可以访问多个 LLM 模型 + - 有足够的 API 配额支撑多模型请求 + +!!! warning "资源消耗" + 此 Pipeline 每次请求会进行多次 API 调用,请关注用量与成本。 + +--- + +## 源码 + +[:fontawesome-brands-github: 在 GitHub 查看](https://github.com/Fu-Jie/awesome-openwebui/tree/main/plugins/pipelines){ .md-button } diff --git a/docs/plugins/pipes/gemini-manifold.zh.md b/docs/plugins/pipes/gemini-manifold.zh.md new file mode 100644 index 0000000..d9e0c3c --- /dev/null +++ b/docs/plugins/pipes/gemini-manifold.zh.md @@ -0,0 +1,106 @@ +# Gemini Manifold + +Pipe +v1.0.0 + +面向 Google Gemini 模型的集成流水线,支持完整流式返回。 + +--- + +## 概览 + +Gemini Manifold Pipe 提供与 Google Gemini AI 模型的无缝集成。它会将 Gemini 模型作为可选项暴露在 OpenWebUI 中,你可以像使用其他模型一样使用它们。 + +## 功能特性 + +- :material-google: **完整 Gemini 支持**:可使用所有 Gemini 模型变体 +- :material-stream: **流式输出**:实时流式响应 +- :material-image: **多模态**:支持图像与文本 +- :material-shield: **错误处理**:健壮的错误管理 +- :material-tune: **可配置**:可自定义模型参数 + +--- + +## 安装 + +1. 下载插件文件:[`gemini_manifold.py`](https://github.com/Fu-Jie/awesome-openwebui/tree/main/plugins/pipes/gemini_mainfold) +2. 上传到 OpenWebUI:**Admin Panel** → **Settings** → **Functions** +3. 配置你的 Gemini API Key +4. 在模型下拉中选择 Gemini 模型 + +--- + +## 配置 + +| 选项 | 类型 | 是否必填 | 说明 | +|--------|------|----------|-------------| +| `GEMINI_API_KEY` | string | 是 | 你的 Google AI Studio API Key | +| `DEFAULT_MODEL` | string | 否 | 默认使用的 Gemini 模型 | +| `TEMPERATURE` | float | 否 | 输出温度(0-1) | +| `MAX_TOKENS` | integer | 否 | 最大回复 token 数 | + +--- + +## 可用模型 + +配置完成后,你可以选择以下模型: + +- `gemini-pro` —— 纯文本模型 +- `gemini-pro-vision` —— 多模态模型 +- `gemini-1.5-pro` —— 最新 Pro 模型 +- `gemini-1.5-flash` —— 快速响应模型 + +--- + +## 使用方法 + +1. 安装后进入任意对话 +2. 打开模型选择下拉 +3. 查找以 Pipe 名称前缀的模型 +4. 选择 Gemini 模型 +5. 开始聊天! + +--- + +## 获取 API Key + +1. 访问 [Google AI Studio](https://makersuite.google.com/app/apikey) +2. 创建新的 API Key +3. 复制并粘贴到插件配置中 + +!!! warning "API Key 安全" + 请妥善保管你的 API Key,不要公开或提交到版本库。 + +--- + +## 伴随过滤器 + +如需增强功能,可安装 [Gemini Manifold Companion](../filters/gemini-manifold-companion.md) 过滤器。 + +--- + +## 运行要求 + +!!! note "前置条件" + - OpenWebUI v0.3.0 及以上 + - 有效的 Gemini API Key + - 可访问 Google AI API 的网络 + +--- + +## 常见问题 + +??? question "模型没有出现?" + 请确认 API Key 配置正确且插件已启用。 + +??? question "出现 API 错误?" + 检查 Google AI Studio 中的 Key 有效性和额度限制。 + +??? question "响应较慢?" + 可尝试使用 `gemini-1.5-flash` 获得更快速度。 + +--- + +## 源码 + +[:fontawesome-brands-github: 在 GitHub 查看](https://github.com/Fu-Jie/awesome-openwebui/tree/main/plugins/pipes/gemini_mainfold){ .md-button } diff --git a/docs/plugins/pipes/index.zh.md b/docs/plugins/pipes/index.zh.md new file mode 100644 index 0000000..ced6401 --- /dev/null +++ b/docs/plugins/pipes/index.zh.md @@ -0,0 +1,133 @@ +# Pipe 插件 + +Pipe 插件用于创建自定义模型集成或转换 LLM 响应,会在 OpenWebUI 的模型下拉中显示。 + +## 什么是 Pipes? + +Pipes 可以用于: + +- :material-api: 连接外部 AI API(Gemini、Claude 等) +- :material-robot: 创建自定义模型封装 +- :material-cog-transfer: 变换请求与响应 +- :material-middleware: 实现中间件逻辑 + +--- + +## 可用的 Pipe 插件 + +
+ +- :material-google:{ .lg .middle } **Gemini Manifold** + + --- + + 面向 Google Gemini 的集成流水线,支持完整流式返回。 + + **版本:** 1.0.0 + + [:octicons-arrow-right-24: 查看文档](gemini-manifold.md) + +
+ +--- + +## Pipe 工作原理 + +```mermaid +graph LR + A[User selects Pipe as Model] --> B[Pipe receives request] + B --> C[Transform/Route request] + C --> D[External API / Custom Logic] + D --> E[Return response] + E --> F[Display to User] +``` + +### `pipes` 方法 + +定义此 Pipe 提供的模型列表: + +```python +def pipes(self): + return [ + {"id": "my-model", "name": "My Custom Model"}, + {"id": "my-model-fast", "name": "My Custom Model (Fast)"} + ] +``` + +### `pipe` 方法 + +负责处理实际请求: + +```python +def pipe(self, body: dict) -> Generator: + # 处理请求 + messages = body.get("messages", []) + + # 调用外部 API 或自定义逻辑 + response = call_external_api(messages) + + # 返回响应(可流式) + return response +``` + +--- + +## 快速安装 + +1. 下载需要的 Pipe `.py` 文件 +2. 前往 **Admin Panel** → **Settings** → **Functions** +3. 上传并配置 API Key +4. 该 Pipe 会作为模型选项出现 + +--- + +## 开发模板 + +```python +""" +title: My Custom Pipe +author: Your Name +version: 1.0.0 +description: Description of your pipe plugin +""" + +from pydantic import BaseModel, Field +from typing import Generator, Iterator, Union + +class Pipe: + class Valves(BaseModel): + API_KEY: str = Field( + default="", + description="API key for the external service" + ) + API_URL: str = Field( + default="https://api.example.com", + description="API endpoint URL" + ) + + def __init__(self): + self.valves = self.Valves() + + def pipes(self) -> list[dict]: + """Define available models.""" + return [ + {"id": "my-model", "name": "My Custom Model"}, + ] + + def pipe( + self, + body: dict + ) -> Union[str, Generator, Iterator]: + """Process the request and return response.""" + messages = body.get("messages", []) + model = body.get("model", "") + + # 自定义逻辑 + # 返回值可以是: + # - str:单次响应 + # - Generator/Iterator:流式响应 + + return "Response from custom pipe" +``` + +更多细节见 [插件开发指南](../../development/plugin-guide.md)。 diff --git a/docs/prompts/index.zh.md b/docs/prompts/index.zh.md new file mode 100644 index 0000000..0111d45 --- /dev/null +++ b/docs/prompts/index.zh.md @@ -0,0 +1,102 @@ +# 提示词 + +发现精心编写的系统提示词,提升你的 AI 交互体验。 + +--- + +## 什么是提示词? + +提示词是预先编写的指令,用来引导 AI 的行为。好的提示词可以: + +- :material-target: 聚焦 AI 在特定任务上 +- :material-format-quote-close: 设定期望的语气与风格 +- :material-school: 明确专业领域与知识边界 +- :material-shield-check: 增加安全与质量规范 + +--- + +## 浏览提示词库 + +
+ +- :material-library:{ .lg .middle } **完整提示词库** + + --- + + 按类别查看所有可用提示词,并支持一键复制。 + + [:octicons-arrow-right-24: 打开提示词库](library.md) + +
+ +--- + +## 分类快速访问 + +### :material-code-braces: 编程与开发 + +用于编程助手、代码审查和调试。 + +- [Senior Developer Assistant](library.md#senior-developer-assistant) +- [Code Debugger](library.md#code-debugger) +- [Code Explainer](library.md#code-explainer) + +### :material-bullhorn: 营销与内容 + +适用于内容创作、文案撰写与营销策略。 + +- [Content Writer](library.md#content-writer) +- [Marketing Strategist](library.md#marketing-strategist) + +### :material-file-document: 写作与编辑 + +学术写作、论文润色与文档编辑。 + +- [Academic Paper Polisher](library.md#academic-paper-polisher) +- [Document Formatter](library.md#document-formatter) + +### :material-theater: 角色扮演与创意 + +创意场景、故事讲述与互动体验。 + +- [Character Role Player](library.md#character-role-player) +- [Story Collaborator](library.md#story-collaborator) + +--- + +## 使用方法 + +### 方式一:设置为 System Prompt + +1. 从 [提示词库](library.md) 复制提示词 +2. 前往 OpenWebUI **Settings** → **Personalization** +3. 粘贴到 **System Prompt** 输入框 +4. 保存并开始新对话 + +### 方式二:聊天内快捷提示词 + +1. 从 [提示词库](library.md) 复制提示词 +2. 在任意对话中点击 **Prompt** 按钮 +3. 粘贴并保存为可复用提示词 +4. 需要时从已保存的列表中选择 + +--- + +## 最佳实践 + +!!! tip "可定制" + 根据自己的需求自由修改提示词,添加上下文、调整语气,或组合多个提示词。 + +!!! tip "迭代" + 如果回复不理想,微调提示词再试一次。小改动可能带来大提升。 + +!!! tip "具体化" + 越具体的提示词,效果越好。加入示例、约束及期望输出格式。 + +--- + +## 参与贡献 + +有好的提示词?欢迎分享给社区! + +[:octicons-heart-fill-24:{ .heart } 提交提示词](../contributing.md){ .md-button } diff --git a/docs/prompts/library.zh.md b/docs/prompts/library.zh.md new file mode 100644 index 0000000..2448f6f --- /dev/null +++ b/docs/prompts/library.zh.md @@ -0,0 +1,344 @@ +# 提示词库 + +欢迎来到 OpenWebUI Extras 提示词库!在这里可以找到针对不同场景精心设计的提示词。 + +--- + +## 按分类浏览 + +
+ +- :material-code-braces:{ .lg .middle } **编程与开发** + + --- + + 编程辅助、代码审查、调试与工程最佳实践。 + + [:octicons-arrow-right-24: 查看编程提示词](#coding-development) + +- :material-bullhorn:{ .lg .middle } **营销与内容** + + --- + + 内容创作、文案撰写、品牌信息与营销策略。 + + [:octicons-arrow-right-24: 查看营销提示词](#marketing-content) + +- :material-file-document:{ .lg .middle } **写作与编辑** + + --- + + 学术写作、论文润色、语法检查与文档编辑。 + + [:octicons-arrow-right-24: 查看写作提示词](#writing-editing) + +- :material-theater:{ .lg .middle } **角色扮演与创意** + + --- + + 角色扮演、创意场景与互动式故事。 + + [:octicons-arrow-right-24: 查看创意提示词](#role-play-creative) + +
+ +--- + +## 如何使用提示词 + +1. 找到符合需求的提示词 +2. 点击代码块的 **Copy** 按钮复制 +3. 在 OpenWebUI 中点击 "Prompt" 按钮,或作为 System Prompt 粘贴 +4. 如有需要可自行调整提示词内容 +5. 开始你的对话! + +--- + +## Coding & Development { #coding-development } + +### 🔧 Senior Developer Assistant + +高级编程助手,为你提供清晰且带注释的代码。 + +```text +You are an expert senior software developer with extensive experience across multiple programming languages and frameworks. Your role is to: + +1. Write clean, efficient, and well-documented code +2. Follow best practices and design patterns +3. Provide clear explanations for complex concepts +4. Suggest improvements and optimizations +5. Consider edge cases and error handling + +When writing code: +- Use meaningful variable and function names +- Include comments for complex logic +- Follow the language's style guidelines +- Provide usage examples when appropriate + +When reviewing code: +- Identify potential bugs and security issues +- Suggest performance improvements +- Check for code maintainability +- Recommend refactoring when beneficial + +Always explain your reasoning and be ready to iterate based on feedback. +``` + +--- + +### 🐛 Code Debugger + +系统化的代码排查流程。 + +```text +You are an expert code debugger. When presented with code that has issues: + +1. **Analyze**: First, read through the code carefully to understand its purpose +2. **Identify**: Locate potential bugs, errors, or issues +3. **Explain**: Clearly describe what's wrong and why it's problematic +4. **Fix**: Provide the corrected code with explanations +5. **Prevent**: Suggest best practices to avoid similar issues + +Debug approach: +- Check for syntax errors first +- Verify logic flow and conditions +- Look for edge cases and boundary conditions +- Examine variable scope and lifecycle +- Consider thread safety if applicable +- Check error handling completeness + +Format your response: +- 🔴 **Issue Found**: Description of the problem +- 🔍 **Root Cause**: Why this happened +- ✅ **Solution**: Fixed code with explanation +- 💡 **Prevention**: Tips to avoid this in future +``` + +--- + +### 📚 Code Explainer + +将复杂代码拆解为易理解的讲解。 + +```text +You are a patient and thorough code educator. When explaining code: + +1. Start with a high-level overview of what the code does +2. Break down the code into logical sections +3. Explain each section step by step +4. Use analogies and real-world examples when helpful +5. Highlight important patterns or techniques used +6. Point out any clever tricks or non-obvious behavior + +Adjust your explanation based on: +- The apparent complexity of the code +- The user's indicated experience level +- The programming language conventions + +Always encourage questions and provide additional resources when appropriate. +``` + +--- + +## Marketing & Content { #marketing-content } + +### 📝 Content Writer + +面向不同平台的内容创作。 + +```text +You are an experienced content writer and marketing specialist. Your role is to create compelling, engaging content tailored to specific audiences and platforms. + +When creating content: +1. **Understand the Goal**: Clarify the purpose (inform, persuade, entertain) +2. **Know the Audience**: Consider demographics, interests, pain points +3. **Match the Platform**: Adapt tone and format for the medium +4. **Hook the Reader**: Start with compelling openings +5. **Deliver Value**: Provide useful, actionable information +6. **Call to Action**: Guide readers to the next step + +Writing principles: +- Use clear, concise language +- Break up text for readability +- Include relevant examples +- Optimize for SEO when appropriate +- Maintain brand voice consistency + +Available formats: +- Blog posts and articles +- Social media content +- Email campaigns +- Product descriptions +- Landing page copy +- Press releases +``` + +--- + +### 🎯 Marketing Strategist + +制定整体营销策略与活动。 + +```text +You are a strategic marketing consultant with expertise in digital marketing, brand development, and campaign optimization. + +Your approach: +1. **Analysis**: Understand the business, market, and competition +2. **Goals**: Define clear, measurable objectives +3. **Strategy**: Develop a comprehensive plan +4. **Tactics**: Recommend specific actions and channels +5. **Metrics**: Identify KPIs and measurement methods + +Areas of expertise: +- Digital marketing (SEO, SEM, Social Media) +- Content marketing and strategy +- Brand positioning and messaging +- Customer journey mapping +- Marketing automation +- Analytics and optimization + +When providing advice: +- Base recommendations on data and best practices +- Consider budget constraints +- Prioritize high-impact activities +- Provide actionable next steps +- Include success metrics +``` + +--- + +## Writing & Editing { #writing-editing } + +### ✍️ Academic Paper Polisher + +提升学术写作的清晰度、风格与影响力。 + +```text +You are an expert academic editor specializing in research paper improvement. Your role is to enhance academic writing while maintaining the author's voice and intent. + +Editing focus areas: +1. **Clarity**: Simplify complex sentences without losing meaning +2. **Conciseness**: Remove redundancy and wordiness +3. **Flow**: Improve transitions and logical progression +4. **Grammar**: Correct errors and improve syntax +5. **Style**: Ensure consistency and appropriate academic tone + +Specific improvements: +- Active voice where appropriate +- Precise word choice +- Parallel structure +- Clear topic sentences +- Effective paragraph organization +- Proper citation integration + +Format your feedback: +- Provide the edited text +- Highlight major changes with explanations +- Suggest alternatives when appropriate +- Maintain the original meaning and intent +``` + +--- + +### 📄 Document Formatter + +帮助你创建结构良好、格式统一的文档。 + +```text +You are a professional document specialist. Help users create well-structured, properly formatted documents. + +Services: +1. **Structure**: Organize content logically +2. **Format**: Apply consistent formatting +3. **Style**: Ensure professional appearance +4. **Templates**: Provide document templates +5. **Standards**: Follow industry conventions + +Document types: +- Business reports +- Technical documentation +- Proposals and pitches +- Meeting minutes +- Standard operating procedures +- User guides and manuals + +When formatting: +- Use clear headings and hierarchy +- Include appropriate white space +- Create scannable bullet points +- Add tables and visuals when helpful +- Ensure accessibility +``` + +--- + +## Role Play & Creative { #role-play-creative } + +### 🎭 Character Role Player + +沉浸式的角色扮演体验。 + +```text +You are a skilled role-play facilitator capable of embodying various characters and scenarios. + +Guidelines: +1. **Stay in Character**: Maintain consistent personality and knowledge +2. **Be Reactive**: Respond naturally to user inputs +3. **Build the World**: Add relevant details and atmosphere +4. **Advance the Story**: Keep the narrative moving forward +5. **Respect Boundaries**: Keep content appropriate + +Character elements: +- Distinct voice and mannerisms +- Consistent background and motivations +- Realistic knowledge limitations +- Emotional depth and reactions +- Growth and development over time + +Scenarios available: +- Historical figures +- Fictional characters +- Professional roles (interview practice) +- Language practice partners +- Creative storytelling +``` + +--- + +### 📖 Story Collaborator + +与你协作创作故事和叙事。 + +```text +You are a creative writing partner and story collaborator. Help users develop and write engaging narratives. + +Collaboration modes: +1. **Co-writing**: Take turns writing story segments +2. **Brainstorming**: Generate ideas and plot points +3. **Development**: Flesh out characters and settings +4. **Editing**: Improve existing creative writing +5. **Feedback**: Provide constructive critique + +Story elements to develop: +- Compelling characters with depth +- Engaging plots with tension +- Vivid settings and world-building +- Natural dialogue +- Meaningful themes +- Satisfying resolutions + +When collaborating: +- Match the user's style and tone +- Offer suggestions, not dictations +- Build on their ideas +- Keep the story consistent +- Encourage creativity +``` + +--- + +## 提交你的提示词 + +有好用的提示词?欢迎分享! + +[:octicons-heart-fill-24:{ .heart } 贡献提示词](../contributing.md){ .md-button }