File tree Expand file tree Collapse file tree
openspec/changes/complete-digital-twin Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : RAG Ingestion
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ paths :
8+ - " content/**"
9+ workflow_dispatch :
10+
11+ jobs :
12+ ingest :
13+ runs-on : ubuntu-latest
14+ permissions :
15+ contents : write
16+
17+ steps :
18+ - name : Checkout code
19+ uses : actions/checkout@v4
20+ with :
21+ fetch-depth : 0
22+
23+ - name : Setup Python
24+ uses : actions/setup-python@v4
25+ with :
26+ python-version : " 3.11"
27+
28+ - name : Install dependencies
29+ run : |
30+ python -m pip install --upgrade pip
31+ pip install -r scripts/requirements.txt
32+
33+ - name : Run Ingestion Script
34+ env :
35+ CLOUDFLARE_ACCOUNT_ID : ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
36+ CLOUDFLARE_API_TOKEN : ${{ secrets.CLOUDFLARE_API_TOKEN }}
37+ CLOUDFLARE_VECTORIZE_INDEX_NAME : " blog-index"
38+ run : |
39+ python scripts/ingest.py
40+
41+ - name : Commit State File
42+ run : |
43+ git config --local user.email "action@github.com"
44+ git config --local user.name "GitHub Action"
45+ git add .ingest_state.json
46+ git diff --staged --quiet || git commit -m "🤖 Update RAG ingestion state"
47+ git push
Load Diff Large diffs are not rendered by default.
File renamed without changes.
Original file line number Diff line number Diff line change @@ -28,9 +28,9 @@ ${contextText}
2828
2929Instructions:
30301. Use a professional, friendly, slightly geeky tone.
31- 2. If the answer is not in the Context, say "My memory bank doesn't have info on this specific topic based on the blog posts."
32- 3. Answer in the same language as the user's question (Default to Chinese) .
33- 4. Keep answers concise.` ;
31+ 2. If the answer is not in the Context, you MUST reply exactly with: "没有找到相关内容".
32+ 3. Answer in Chinese (Simplified) by default, unless the user asks in another language .
33+ 4. Keep answers concise and helpful .` ;
3434}
3535
3636/**
Original file line number Diff line number Diff line change 1+ < script src ="https://cdn.jsdelivr.net/npm/marked/marked.min.js "> </ script >
12< div id ="chat-launcher "
23 class ="chat-launcher "
34 role ="button "
Original file line number Diff line number Diff line change 1+ # 完善博客数字分身助手 (Digital Twin Chatbot)
2+
3+ ## 目标
4+ 完成基于 RAG 的博客数字分身助手功能,修复 CSS 加载问题,引入必要的 JS 依赖,并优化提示词以支持中文回复。
5+
6+ ## 变更内容
7+
8+ ### 1. 修复样式加载
9+ - ** 操作** : 将 ` assets/css/chat.css ` 移动到 ` assets/css/extended/chat.css ` 。
10+ - ** 原因** : Hugo PaperMod 主题的 CSS 打包逻辑(在 ` head.html ` 中)只会自动加载 ` assets/css/extended/ ` 目录下的扩展样式文件。当前文件位于 ` assets/css/ ` 根目录,因此未被加载,导致聊天窗口无样式。
11+
12+ ### 2. 引入 Marked.js 依赖
13+ - ** 操作** : 在 ` layouts/partials/chatbox.html ` 顶部添加 Marked.js 的 CDN 引用。
14+ ``` html
15+ <script src =" https://cdn.jsdelivr.net/npm/marked/marked.min.js" ></script >
16+ ```
17+ - ** 原因** : 前端代码依赖 ` marked ` 库来渲染 AI 返回的 Markdown 格式回复。目前该库未被引入,导致 Markdown 渲染功能失效。
18+
19+ ### 3. 优化后端提示词 (System Prompt)
20+ - ** 操作** : 修改 ` functions/api/chat.js ` 中的 ` buildSystemPrompt ` 函数。
21+ - ** 变更点** :
22+ - 将 System Prompt 的指令语言调整为更自然的中文设定。
23+ - 明确指定“找不到内容”时的回复语为用户要求的:“没有找到相关内容”。
24+ - 确保 AI 默认使用中文回答。
25+
26+ ## 验证计划
27+ 1 . ** 样式验证** : 部署后检查右下角是否出现悬浮聊天按钮,点击是否能正常展开聊天窗口。
28+ 2 . ** 功能验证** : 发送测试消息(如“你好”),确认是否收到回复。
29+ 3 . ** Markdown 验证** : 询问需要代码块或列表回复的问题,确认渲染是否正常。
30+ 4 . ** RAG 验证** : 询问博客相关问题,确认回复基于上下文。
31+ 5 . ** Fallback 验证** : 询问无关问题(如“番茄炒蛋怎么做”),确认回复“没有找到相关内容”。
Original file line number Diff line number Diff line change 1+ # Tasks
2+
3+ - [ ] Create OpenSpec proposal file <!-- id: 0 -->
4+ - [ ] Move ` assets/css/chat.css ` to ` assets/css/extended/chat.css ` <!-- id: 1 -->
5+ - [ ] Add marked.js CDN to ` layouts/partials/chatbox.html ` <!-- id: 2 -->
6+ - [ ] Update system prompt in ` functions/api/chat.js ` <!-- id: 3 -->
7+ - [ ] Commit and push changes <!-- id: 4 -->
You can’t perform that action at this time.
0 commit comments