Skip to content

Commit 688522c

Browse files
committed
release: v2.1.2 - plugin lib fixes, doc context persistence, release workflow
Plugin fixes: - excel-parser v1.0.2: lib 404 fix, install downloads deps from manifest - markdown-enhancer v1.0.1: add dependencies for market install - Plugin settings: fix x-for key for select options (object format) Features: - Document/table content now persists in chat history for follow-up Fixes: - AbortError when stopping stream generation - BUNDLED_PLUGINS_DIR path for local dev Docs: - Plugins README: dependencies requirement for lib/ plugins - Add .github/workflows/release.yml for multi-platform Docker build
1 parent 3e83f9b commit 688522c

File tree

11 files changed

+180
-52
lines changed

11 files changed

+180
-52
lines changed

.github/workflows/release.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
build-and-push:
10+
name: Build multi-platform Docker image
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
packages: write
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Set up QEMU
20+
uses: docker/setup-qemu-action@v3
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
- name: Extract version from tag
26+
id: version
27+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
28+
29+
- name: Login to Docker Hub
30+
uses: docker/login-action@v3
31+
with:
32+
username: ${{ secrets.DOCKERHUB_USERNAME }}
33+
password: ${{ secrets.DOCKERHUB_TOKEN }}
34+
35+
- name: Login to GHCR
36+
uses: docker/login-action@v3
37+
with:
38+
registry: ghcr.io
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Build and push
43+
uses: docker/build-push-action@v6
44+
with:
45+
context: .
46+
file: ./Dockerfile
47+
platforms: linux/amd64,linux/arm64
48+
push: true
49+
tags: |
50+
massif01/chatraw:${{ steps.version.outputs.VERSION }}
51+
massif01/chatraw:latest
52+
ghcr.io/${{ github.repository_owner }}/chatraw:${{ steps.version.outputs.VERSION }}
53+
ghcr.io/${{ github.repository_owner }}/chatraw:latest

Plugins/Plugin_market/excel-parser/main.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,10 +562,12 @@
562562
const workbook = xlsxLib.read(arrayBuffer, {
563563
type: 'array',
564564
cellDates: true, // Parse dates as Date objects
565+
cellNF: true, // Include number format (cell.z) for date/currency
565566
cellFormula: false, // Don't need formula text, just results
566-
cellText: true, // Get formatted text
567+
cellText: true, // Get formatted text (cell.w)
567568
cellStyles: false, // Don't need styles
568569
sheetRows: (settings.max_rows || 1000) + 1, // +1 for header detection
570+
raw: false, // Use formatted values where available
569571
WTF: false // Don't throw on unexpected features
570572
});
571573

Plugins/Plugin_market/index.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
},
101101
{
102102
"id": "markdown-enhancer",
103-
"version": "1.0.0",
103+
"version": "1.0.1",
104104
"name": {
105105
"en": "Markdown Renderer Plus",
106106
"zh": "Markdown 渲染增强"

Plugins/Plugin_market/markdown-enhancer/manifest.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "markdown-enhancer",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"name": {
55
"en": "Markdown Renderer Plus",
66
"zh": "Markdown 渲染增强"
@@ -15,6 +15,26 @@
1515
"main": "main.js",
1616
"type": "message_processor",
1717
"hooks": ["after_receive"],
18+
"dependencies": {
19+
"katex-css": "/api/plugins/markdown-enhancer/lib/katex.min.css",
20+
"katex-js": "/api/plugins/markdown-enhancer/lib/katex.min.js",
21+
"mermaid": "/api/plugins/markdown-enhancer/lib/mermaid.min.js",
22+
"hljs-c": "/api/plugins/markdown-enhancer/lib/hljs-c.min.js",
23+
"hljs-cpp": "/api/plugins/markdown-enhancer/lib/hljs-cpp.min.js",
24+
"hljs-csharp": "/api/plugins/markdown-enhancer/lib/hljs-csharp.min.js",
25+
"hljs-go": "/api/plugins/markdown-enhancer/lib/hljs-go.min.js",
26+
"hljs-java": "/api/plugins/markdown-enhancer/lib/hljs-java.min.js",
27+
"hljs-kotlin": "/api/plugins/markdown-enhancer/lib/hljs-kotlin.min.js",
28+
"hljs-php": "/api/plugins/markdown-enhancer/lib/hljs-php.min.js",
29+
"hljs-ruby": "/api/plugins/markdown-enhancer/lib/hljs-ruby.min.js",
30+
"hljs-rust": "/api/plugins/markdown-enhancer/lib/hljs-rust.min.js",
31+
"hljs-shell": "/api/plugins/markdown-enhancer/lib/hljs-shell.min.js",
32+
"hljs-sql": "/api/plugins/markdown-enhancer/lib/hljs-sql.min.js",
33+
"hljs-swift": "/api/plugins/markdown-enhancer/lib/hljs-swift.min.js",
34+
"hljs-typescript": "/api/plugins/markdown-enhancer/lib/hljs-typescript.min.js",
35+
"hljs-xml": "/api/plugins/markdown-enhancer/lib/hljs-xml.min.js",
36+
"hljs-yaml": "/api/plugins/markdown-enhancer/lib/hljs-yaml.min.js"
37+
},
1838
"settings": [
1939
{
2040
"id": "enableKatex",

Plugins/README.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ your-plugin/
8989
| `type` | string | Yes | Plugin type (see below) |
9090
| `hooks` | array | Yes | List of hooks the plugin uses |
9191
| `fileTypes` | array | No | File extensions for document_parser type. When plugin is enabled, these extensions are automatically added to the file upload dialog. |
92-
| `dependencies` | object | No | External JS libraries (name: CDN URL) |
92+
| `dependencies` | object | No | JS/CSS libraries: CDN URL for remote, or `/api/plugins/{id}/lib/{filename}` for bundled lib. **Required for lib/ plugins when publishing to market** — list all lib files so they are downloaded during install. |
9393
| `settings` | array | No | Plugin settings schema (for standard settings UI) |
9494
| `customSettings` | boolean | No | Set to `true` for custom settings UI |
9595
| `proxy` | array | No | External API services requiring API keys |
@@ -378,7 +378,7 @@ For complex plugins that need full control over settings UI, use `customSettings
378378
379379
### CSS Variables and Theming
380380
381-
ChatRaw v2.1.1+ uses an HSL-based color token system. All CSS variables automatically adapt to light/dark themes via `[data-theme="dark"]`. Use these variables in your plugin UI for consistent styling.
381+
ChatRaw v2.1.2+ uses an HSL-based color token system. All CSS variables automatically adapt to light/dark themes via `[data-theme="dark"]`. Use these variables in your plugin UI for consistent styling.
382382
383383
#### Color Variables
384384
@@ -718,6 +718,16 @@ To distribute your plugin:
718718
719719
For plugins that need to work completely offline, you can bundle dependencies in the `lib/` directory.
720720
721+
**Important for plugin market**: If your plugin uses `lib/` files and will be installed from the market (GitHub URL), you **must** declare them in manifest `dependencies` using the format `/api/plugins/{plugin_id}/lib/{filename}`. Otherwise users get 404/MIME errors. Example:
722+
723+
```json
724+
"dependencies": {
725+
"katex-css": "/api/plugins/my-plugin/lib/katex.min.css",
726+
"katex-js": "/api/plugins/my-plugin/lib/katex.min.js",
727+
"mermaid": "/api/plugins/my-plugin/lib/mermaid.min.js"
728+
}
729+
```
730+
721731
**Loading CSS files** (the framework only supports JS, CSS must be loaded manually):
722732
723733
```javascript
@@ -1023,7 +1033,7 @@ your-plugin/
10231033
| `type` | string | 是 | 插件类型(见下表) |
10241034
| `hooks` | array | 是 | 插件使用的钩子列表 |
10251035
| `fileTypes` | array | 否 | document_parser 类型的文件扩展名。插件启用后,这些扩展名会自动添加到文件上传对话框中。 |
1026-
| `dependencies` | object | 否 | 外部 JS 库(名称: CDN URL |
1036+
| `dependencies` | object | 否 | JS/CSS 库:远程用 CDN URL,本地用 `/api/plugins/{id}/lib/{filename}`。**发布到插件市场且含 lib/ 时必填** — 列出所有 lib 文件以便安装时下载。 |
10271037
| `settings` | array | 否 | 插件设置架构(用于标准设置 UI) |
10281038
| `customSettings` | boolean | 否 | 设为 `true` 启用自定义设置 UI |
10291039
| `proxy` | array | 否 | 需要 API Key 的外部服务 |
@@ -1312,7 +1322,7 @@ your-plugin/
13121322
13131323
### CSS 变量与主题系统
13141324
1315-
ChatRaw v2.1.1+ 使用基于 HSL 的颜色令牌系统。所有 CSS 变量会通过 `[data-theme="dark"]` 自动适配明暗主题。在插件 UI 中使用这些变量即可获得一致的样式。
1325+
ChatRaw v2.1.2+ 使用基于 HSL 的颜色令牌系统。所有 CSS 变量会通过 `[data-theme="dark"]` 自动适配明暗主题。在插件 UI 中使用这些变量即可获得一致的样式。
13161326
13171327
#### 颜色变量
13181328
@@ -1652,6 +1662,16 @@ const allData = ChatRaw.storage.getAll(PLUGIN_ID);
16521662
16531663
对于需要完全离线运行的插件,可以将依赖打包到 `lib/` 目录中。
16541664
1665+
**插件市场发布须知**:若插件使用 `lib/` 且用户从市场(GitHub URL)安装,**必须在** manifest 的 `dependencies` 中声明所有 lib 文件,格式为 `/api/plugins/{plugin_id}/lib/{filename}`,否则会 404/ MIME 报错。示例:
1666+
1667+
```json
1668+
"dependencies": {
1669+
"katex-css": "/api/plugins/my-plugin/lib/katex.min.css",
1670+
"katex-js": "/api/plugins/my-plugin/lib/katex.min.js",
1671+
"mermaid": "/api/plugins/my-plugin/lib/mermaid.min.js"
1672+
}
1673+
```
1674+
16551675
**加载 CSS 文件**(框架仅支持 JS,CSS 需要手动加载):
16561676
16571677
```javascript

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ ChatRaw features a complete **plugin system** to extend functionality:
139139

140140
**Prerequisites**: [Docker](https://docs.docker.com/get-docker/) installed.
141141

142-
Docker images are published to **Docker Hub** and **GitHub Container Registry**. To get the **latest** image (not a cached old one), always run `docker pull` with the tag you want before creating the container. Use `:latest` for the current release, or a version tag (e.g. `v2.1.1`) from [Releases](https://github.com/massif-01/ChatRaw/releases) for a fixed version.
142+
Docker images are published to **Docker Hub** and **GitHub Container Registry**. To get the **latest** image (not a cached old one), always run `docker pull` with the tag you want before creating the container. Use `:latest` for the current release, or a version tag (e.g. `v2.1.2`) from [Releases](https://github.com/massif-01/ChatRaw/releases) for a fixed version.
143143

144144
**Supported platforms**: linux/amd64 (Intel/AMD), linux/arm64 (Apple Silicon, Raspberry Pi 4/5).
145145

@@ -210,7 +210,7 @@ python main.py
210210
| Docker Hub | `docker pull massif01/chatraw:latest` |
211211
| GitHub Container Registry | `docker pull ghcr.io/massif-01/chatraw:latest` |
212212

213-
Use the same tag for a specific version, e.g. `massif01/chatraw:v2.1.1` (see [Releases](https://github.com/massif-01/ChatRaw/releases)).
213+
Use the same tag for a specific version, e.g. `massif01/chatraw:v2.1.2` (see [Releases](https://github.com/massif-01/ChatRaw/releases)).
214214

215215
---
216216

@@ -445,7 +445,7 @@ ChatRaw 拥有完整的**插件系统**以扩展功能:
445445

446446
**前置条件**:已安装 [Docker](https://docs.docker.com/get-docker/)
447447

448-
镜像发布在 **Docker Hub****GitHub Container Registry**。若想用**最新**镜像(避免用到本地缓存的旧镜像),在创建容器前请先执行一次 `docker pull`。使用 `:latest` 表示当前最新版本;如需固定版本,可使用 [Releases](https://github.com/massif-01/ChatRaw/releases) 中的版本号标签(如 `v2.1.1`)。
448+
镜像发布在 **Docker Hub****GitHub Container Registry**。若想用**最新**镜像(避免用到本地缓存的旧镜像),在创建容器前请先执行一次 `docker pull`。使用 `:latest` 表示当前最新版本;如需固定版本,可使用 [Releases](https://github.com/massif-01/ChatRaw/releases) 中的版本号标签(如 `v2.1.2`)。
449449

450450
**支持平台**:linux/amd64(Intel/AMD)、linux/arm64(Apple Silicon、树莓派 4/5)。
451451

@@ -516,7 +516,7 @@ python main.py
516516
| Docker Hub | `docker pull massif01/chatraw:latest` |
517517
| GitHub Container Registry | `docker pull ghcr.io/massif-01/chatraw:latest` |
518518

519-
需要固定版本时使用相同标签格式,例如 `massif01/chatraw:v2.1.1`,版本号见 [Releases](https://github.com/massif-01/ChatRaw/releases)
519+
需要固定版本时使用相同标签格式,例如 `massif01/chatraw:v2.1.2`,版本号见 [Releases](https://github.com/massif-01/ChatRaw/releases)
520520

521521
---
522522

RELEASE_v2.1.2.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# ChatRaw v2.1.2
2+
3+
## 插件相关修复 / Plugin Fixes
4+
5+
### Excel 解析器 (v1.0.2)
6+
- 修复从插件市场安装时 lib/ 文件 404 问题
7+
- 安装流程会下载 manifest dependencies 中的 lib 文件
8+
- 修复 BUNDLED_PLUGINS_DIR 路径(支持本地开发)
9+
- 增加 cellNF、raw 解析选项以提升表格读取准确性
10+
11+
### Markdown 渲染增强 (v1.0.1)
12+
- 添加 manifest dependencies,解决从市场安装时 KaTeX/Mermaid/lib 404
13+
- 安装时自动下载全部 18 个 lib 文件
14+
15+
### 插件设置
16+
- 修复 select 类型 options 为对象数组时的 Alpine x-for key 警告
17+
- 支持 `{value, label}` 格式的选项
18+
19+
## 文档上下文持久化 / Document Context Persistence
20+
21+
- 上传的表格/网页内容现会保存到对话历史
22+
- 后续追问时模型仍可访问之前的文档内容
23+
24+
## 其他修复 / Other Fixes
25+
26+
- 修复点击「停止」时的 AbortError(流式响应)
27+
- 开发者文档:补充 lib/dependencies 在插件市场安装中的说明
28+
29+
## Docker
30+
31+
多平台镜像(linux/amd64, linux/arm64)将发布至:
32+
- Docker Hub: `massif01/chatraw:v2.1.2`
33+
- GitHub Container Registry: `ghcr.io/massif-01/chatraw:v2.1.2`
34+
35+
## 如何更新 / How to Update
36+
37+
```bash
38+
docker pull massif01/chatraw:v2.1.2
39+
docker stop chatraw && docker rm chatraw
40+
docker run -d -p 51111:51111 -v chatraw-data:/app/data --name chatraw massif01/chatraw:v2.1.2
41+
```
42+
43+
---
44+
45+
Full Changelog: [v2.1.1...v2.1.2](https://github.com/massif-01/ChatRaw/compare/v2.1.1...v2.1.2)

backend/main.py

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -598,29 +598,20 @@ async def chat_stream(self, chat_id: str, message: str, use_rag: bool = False, u
598598
if use_rag:
599599
rag_context, rag_references = await self.build_rag_context(message)
600600

601-
# Web content context
602-
web_context = ""
603-
if web_content:
604-
web_context = f"以下是用户提供的网页内容作为参考 (来源: {web_url}):\n---\n{web_content}\n---\n\n"
605-
606-
# User message
607-
final_message = message
608-
if rag_context:
609-
final_message = f"{rag_context}User question: {message}"
610-
if web_context:
611-
final_message = f"{web_context}{final_message}"
612-
613-
# Handle image
614-
if image_base64 and config.capability.vision:
615-
messages.append({
601+
# User message is already in history (saved with web_content). Only add RAG to last message if needed.
602+
if rag_context and messages and messages[-1].get("role") == "user":
603+
messages[-1] = {"role": "user", "content": f"{rag_context}User question: {messages[-1]['content']}"}
604+
605+
# For vision: replace last user message with multimodal format (text + image)
606+
if image_base64 and config.capability.vision and messages and messages[-1].get("role") == "user":
607+
text_content = messages[-1]["content"]
608+
messages[-1] = {
616609
"role": "user",
617610
"content": [
618-
{"type": "text", "text": final_message},
611+
{"type": "text", "text": text_content},
619612
{"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{image_base64}"}}
620613
]
621-
})
622-
else:
623-
messages.append({"role": "user", "content": final_message})
614+
}
624615

625616
# API request
626617
url = config.api_url.rstrip("/") + "/chat/completions"
@@ -742,27 +733,20 @@ async def chat_non_stream(self, chat_id: str, message: str, use_rag: bool = Fals
742733
if use_rag:
743734
rag_context, rag_references = await self.build_rag_context(message)
744735

745-
# Web content context
746-
web_context = ""
747-
if web_content:
748-
web_context = f"以下是用户提供的网页内容作为参考 (来源: {web_url}):\n---\n{web_content}\n---\n\n"
749-
750-
final_message = message
751-
if rag_context:
752-
final_message = f"{rag_context}User question: {message}"
753-
if web_context:
754-
final_message = f"{web_context}{final_message}"
736+
# User message is already in history (saved with web_content). Only add RAG to last message if needed.
737+
if rag_context and messages and messages[-1].get("role") == "user":
738+
messages[-1] = {"role": "user", "content": f"{rag_context}User question: {messages[-1]['content']}"}
755739

756-
if image_base64 and config.capability.vision:
757-
messages.append({
740+
# For vision: replace last user message with multimodal format
741+
if image_base64 and config.capability.vision and messages and messages[-1].get("role") == "user":
742+
text_content = messages[-1]["content"]
743+
messages[-1] = {
758744
"role": "user",
759745
"content": [
760-
{"type": "text", "text": final_message},
746+
{"type": "text", "text": text_content},
761747
{"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{image_base64}"}}
762748
]
763-
})
764-
else:
765-
messages.append({"role": "user", "content": final_message})
749+
}
766750

767751
url = config.api_url.rstrip("/") + "/chat/completions"
768752
headers = {"Content-Type": "application/json"}
@@ -1354,8 +1338,12 @@ async def chat(request: Request):
13541338
chat_obj = db.create_chat("New Chat")
13551339
chat_id = chat_obj.id
13561340

1357-
# Save user message
1358-
db.add_message(chat_id, "user", message)
1341+
# Save user message (include web/document content so it persists for follow-up questions)
1342+
message_to_save = message
1343+
if web_content:
1344+
web_context = f"以下是用户提供的网页/文档内容作为参考 (来源: {web_url or '附件'}):\n---\n{web_content}\n---\n\n"
1345+
message_to_save = f"{web_context}{message}"
1346+
db.add_message(chat_id, "user", message_to_save)
13591347

13601348
settings = db.get_settings()
13611349

backend/static/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ function app() {
834834
} catch (e) {
835835
if (e.name === 'AbortError') {
836836
// User stopped generation, keep partial content
837-
reader.cancel();
837+
try { await reader.cancel(); } catch (_) { /* ignore */ }
838838
} else {
839839
throw e;
840840
}

backend/static/app.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)