Add Flash Card plugin with HTML generation and key point extraction
- Introduced a new Flash Card plugin that generates visually appealing flashcards from text input. - Implemented functionality to extract key points and categories for efficient learning. - Added a new Python file for the plugin logic and a corresponding image asset. - Removed outdated README files for the previous knowledge card plugin.
This commit is contained in:
41
plugins/actions/flash-card/README.md
Normal file
41
plugins/actions/flash-card/README.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# Flash Card
|
||||
|
||||
Generate polished learning flashcards from any text—title, summary, key points, tags, and category—ready for review and sharing.
|
||||
|
||||

|
||||
|
||||
## Highlights
|
||||
|
||||
- **One-click generation**: Drop in text, get a structured card.
|
||||
- **Concise extraction**: 3–5 key points and 2–4 tags automatically surfaced.
|
||||
- **Multi-language**: Choose target language (default English).
|
||||
- **Progressive merge**: Multiple runs append cards into the same HTML container; enable clearing to reset.
|
||||
- **Status updates**: Live notifications for generating/done/error.
|
||||
|
||||
## Parameters
|
||||
|
||||
| Param | Description | Default |
|
||||
| ------------------- | ------------------------------------------------------------ | ------- |
|
||||
| MODEL_ID | Model to use; empty falls back to current session model | empty |
|
||||
| MIN_TEXT_LENGTH | Minimum text length; below this prompts for more text | 50 |
|
||||
| LANGUAGE | Output language (e.g., en, zh) | en |
|
||||
| SHOW_STATUS | Whether to show status updates | true |
|
||||
| CLEAR_PREVIOUS_HTML | Whether to clear previous card HTML (otherwise append/merge) | false |
|
||||
| MESSAGE_COUNT | Use the latest N messages to build the card | 1 |
|
||||
|
||||
## How to Use
|
||||
|
||||
1. Install and enable “Flash Card”.
|
||||
2. Send the text to the chat (multi-turn supported; governed by MESSAGE_COUNT).
|
||||
3. Watch status updates; the card HTML is embedded into the latest message.
|
||||
4. To regenerate from scratch, toggle CLEAR_PREVIOUS_HTML or resend text.
|
||||
|
||||
## Output Format
|
||||
|
||||
- JSON fields: `title`, `summary`, `key_points` (3–5), `tags` (2–4), `category`.
|
||||
- UI: gradient-styled card with tags, key-point list; supports stacking multiple cards.
|
||||
|
||||
## Tips
|
||||
|
||||
- Very short text triggers a prompt to add more; consider summarizing first.
|
||||
- Long text is accepted; for deep analysis, pre-condense with other tools before card creation.
|
||||
41
plugins/actions/flash-card/README_CN.md
Normal file
41
plugins/actions/flash-card/README_CN.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# 闪记卡 (Flash Card)
|
||||
|
||||
快速将文本提炼为精美的学习记忆卡片,自动抽取标题、摘要、关键要点、标签和分类,适合复习与分享。
|
||||
|
||||

|
||||
|
||||
## 功能亮点
|
||||
|
||||
- **一键生成**:输入任意文本,直接产出结构化卡片。
|
||||
- **要点聚合**:自动提取 3-5 个记忆要点与 2-4 个标签。
|
||||
- **多语言支持**:可设定目标语言(默认中文)。
|
||||
- **渐进合并**:多次调用会将新卡片合并到同一 HTML 容器中;如需重置可启用清空选项。
|
||||
- **状态提示**:实时推送“生成中/完成/错误”等状态与通知。
|
||||
|
||||
## 参数说明
|
||||
|
||||
| 参数 | 说明 | 默认值 |
|
||||
| ------------------- | ------------------------------------- | ------ |
|
||||
| MODEL_ID | 指定推理模型;为空则使用当前会话模型 | 空 |
|
||||
| MIN_TEXT_LENGTH | 最小文本长度,不足时提示补充 | 50 |
|
||||
| LANGUAGE | 输出语言(如 zh、en) | zh |
|
||||
| SHOW_STATUS | 是否显示状态更新 | true |
|
||||
| CLEAR_PREVIOUS_HTML | 是否清空旧的卡片 HTML(否则合并追加) | false |
|
||||
| MESSAGE_COUNT | 取最近 N 条消息生成卡片 | 1 |
|
||||
|
||||
## 使用步骤
|
||||
|
||||
1. 在插件市场安装并启用“闪记卡”。
|
||||
2. 将待整理的文本发送到聊天框(可多轮对话,受 MESSAGE_COUNT 控制)。
|
||||
3. 等待状态提示,卡片将以 HTML 形式嵌入到最新消息中。
|
||||
4. 若需重新生成,开启 CLEAR_PREVIOUS_HTML 或直接重发文本。
|
||||
|
||||
## 输出格式
|
||||
|
||||
- JSON 字段:`title`、`summary`、`key_points`(3-5 条)、`tags`(2-4 条)、`category`。
|
||||
- 前端呈现:单卡片带渐变主题、标签胶囊、要点列表,可连续追加多张卡片。
|
||||
|
||||
## 使用建议
|
||||
|
||||
- 文本过短会提醒补充,可先汇总再生成卡片。
|
||||
- 长文本无需截断,直接生成;如需深度分析可先用其他工具精炼后再制作卡片。
|
||||
BIN
plugins/actions/flash-card/flash_card.png
Normal file
BIN
plugins/actions/flash-card/flash_card.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 268 KiB |
@@ -80,10 +80,6 @@ class Action:
|
||||
default=50,
|
||||
description="Minimum text length required to generate a flashcard (characters).",
|
||||
)
|
||||
MAX_TEXT_LENGTH: int = Field(
|
||||
default=2000,
|
||||
description="Recommended maximum text length. For longer texts, deep analysis tools are recommended.",
|
||||
)
|
||||
LANGUAGE: str = Field(
|
||||
default="en",
|
||||
description="Target language for card content (e.g., 'en', 'zh').",
|
||||
@@ -153,13 +149,6 @@ class Action:
|
||||
)
|
||||
return body
|
||||
|
||||
if text_length > self.valves.MAX_TEXT_LENGTH:
|
||||
await self._emit_notification(
|
||||
__event_emitter__,
|
||||
f"Text quite long ({text_length} chars), consider using 'Deep Reading' for deep analysis.",
|
||||
"info",
|
||||
)
|
||||
|
||||
# Notify user that we are generating the card
|
||||
await self._emit_notification(
|
||||
__event_emitter__, "⚡ Generating Flash Card...", "info"
|
||||
BIN
plugins/actions/flash-card/flash_card_cn.png
Normal file
BIN
plugins/actions/flash-card/flash_card_cn.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 291 KiB |
@@ -12,6 +12,7 @@ from pydantic import BaseModel, Field
|
||||
from typing import Optional, Dict, Any, List
|
||||
import json
|
||||
import logging
|
||||
import re
|
||||
from open_webui.utils.chat import generate_chat_completion
|
||||
from open_webui.models.users import Users
|
||||
|
||||
@@ -78,10 +79,6 @@ class Action:
|
||||
MIN_TEXT_LENGTH: int = Field(
|
||||
default=50, description="生成闪记卡所需的最小文本长度(字符数)。"
|
||||
)
|
||||
MAX_TEXT_LENGTH: int = Field(
|
||||
default=2000,
|
||||
description="建议的最大文本长度。超过此长度建议使用深度分析工具。",
|
||||
)
|
||||
LANGUAGE: str = Field(
|
||||
default="zh", description="卡片内容的目标语言 (例如 'zh', 'en')。"
|
||||
)
|
||||
@@ -149,13 +146,6 @@ class Action:
|
||||
)
|
||||
return body
|
||||
|
||||
if text_length > self.valves.MAX_TEXT_LENGTH:
|
||||
await self._emit_notification(
|
||||
__event_emitter__,
|
||||
f"文本较长({text_length}字符),建议使用'墨海拾贝'进行深度分析。",
|
||||
"info",
|
||||
)
|
||||
|
||||
# Notify user that we are generating the card
|
||||
await self._emit_notification(__event_emitter__, "⚡ 正在生成闪记卡...", "info")
|
||||
await self._emit_status(__event_emitter__, "⚡ 闪记卡: 开始生成...", done=False)
|
||||
@@ -177,13 +167,13 @@ class Action:
|
||||
你是一个闪记卡生成专家,专注于创建适合学习和记忆的知识卡片。你的任务是将文本提炼成简洁、易记的学习卡片。
|
||||
|
||||
请提取以下字段,并以 JSON 格式返回:
|
||||
1. "title": 创建一个简短、精准的标题(6-12 字),突出核心概念
|
||||
2. "summary": 用一句话总结核心要义(20-40 字),要通俗易懂、便于记忆
|
||||
3. "key_points": 列出 3-5 个关键记忆点(每个 10-20 字)
|
||||
- 每个要点应该是独立的知识点
|
||||
- 使用简洁、口语化的表达
|
||||
- 避免冗长的句子
|
||||
4. "tags": 列出 2-4 个分类标签(每个 2-5 字)
|
||||
1. "title": 创建一个简短、精准的标题(3-8 个词),突出核心概念
|
||||
2. "summary": 用一句话总结核心要义(10-25 个词),要通俗易懂、便于记忆
|
||||
3. "key_points": 列出 3-5 个关键记忆点(每个 5-15 个词)
|
||||
- 每个要点应该是独立的知识点
|
||||
- 使用简洁、口语化的表达
|
||||
- 避免冗长的句子
|
||||
4. "tags": 列出 2-4 个分类标签(每个 1-3 个词)
|
||||
5. "category": 选择一个主分类(如:概念、技能、事实、方法等)
|
||||
|
||||
目标语言: {self.valves.LANGUAGE}
|
||||
@@ -680,7 +670,7 @@ class Action:
|
||||
tags_html = ""
|
||||
if "tags" in data and data["tags"]:
|
||||
for tag in data["tags"]:
|
||||
tags_html += f'<span class="card-tag">#{tag}</span>'
|
||||
tags_html += f'<div class="card-tag"><span class="card-tag-label">#</span>{tag}</div>'
|
||||
|
||||
# Generate key points HTML
|
||||
points_html = ""
|
||||
@@ -708,7 +698,6 @@ class Action:
|
||||
</ul>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<span class="card-tag-label">标签</span>
|
||||
{tags_html}
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,15 +0,0 @@
|
||||
# Flash Card
|
||||
|
||||
Quickly generates beautiful flashcards from text, extracting key points and categories for efficient learning.
|
||||
|
||||
## Features
|
||||
|
||||
- **Instant Generation**: Turn any text into a structured flashcard.
|
||||
- **Key Point Extraction**: Automatically identifies core concepts.
|
||||
- **Visual Design**: Generates a visually appealing HTML card.
|
||||
|
||||
## Usage
|
||||
|
||||
1. Install the plugin.
|
||||
2. Send text to the chat.
|
||||
3. The plugin will analyze the text and generate a flashcard.
|
||||
@@ -1,15 +0,0 @@
|
||||
# 闪记卡 (Flash Card)
|
||||
|
||||
快速将文本提炼为精美的学习记忆卡片,支持核心要点提取与分类,助力高效学习。
|
||||
|
||||
## 功能特点
|
||||
|
||||
- **即时生成**:将任何文本转化为结构化的记忆卡片。
|
||||
- **要点提取**:自动识别核心概念。
|
||||
- **视觉设计**:生成视觉精美的 HTML 卡片。
|
||||
|
||||
## 使用方法
|
||||
|
||||
1. 安装插件。
|
||||
2. 发送文本到聊天框。
|
||||
3. 插件将分析文本并生成一张闪记卡。
|
||||
Reference in New Issue
Block a user