{"id":28977127,"url":"https://github.com/tsai1030/deploy-safe","last_synced_at":"2026-04-10T02:19:38.636Z","repository":{"id":300471059,"uuid":"1006259968","full_name":"Tsai1030/deploy-safe","owner":"Tsai1030","description":"💬 Local RAG system with Chinese semantic search, Ollama-based LLM, Nginx hosting, and DuckDNS access.","archived":false,"fork":false,"pushed_at":"2025-06-21T21:37:22.000Z","size":5688,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-21T22:26:51.274Z","etag":null,"topics":["chatbot","chromadb","duckdns","fastapi","langchain","local-llm","nginx","ollama","rag","react","vite"],"latest_commit_sha":null,"homepage":"http://kmu-rag.duckdns.org","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Tsai1030.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-21T21:14:55.000Z","updated_at":"2025-06-21T21:42:45.000Z","dependencies_parsed_at":"2025-06-21T22:37:08.350Z","dependency_job_id":null,"html_url":"https://github.com/Tsai1030/deploy-safe","commit_stats":null,"previous_names":["tsai1030/deploy-safe"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Tsai1030/deploy-safe","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tsai1030%2Fdeploy-safe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tsai1030%2Fdeploy-safe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tsai1030%2Fdeploy-safe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tsai1030%2Fdeploy-safe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tsai1030","download_url":"https://codeload.github.com/Tsai1030/deploy-safe/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tsai1030%2Fdeploy-safe/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261700261,"owners_count":23196489,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chatbot","chromadb","duckdns","fastapi","langchain","local-llm","nginx","ollama","rag","react","vite"],"created_at":"2025-06-24T15:00:45.356Z","updated_at":"2026-04-10T02:19:38.601Z","avatar_url":"https://github.com/Tsai1030.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\ntitle: RAG QA System for Air Pollution (DuckDNS + Nginx Version)\ndescription: A LangChain + Chroma + Ollama powered RAG chatbot system deployed with DuckDNS and Nginx, focused on air pollution and public health.\nkeywords: RAG, LangChain, Ollama, DuckDNS, Nginx, chatbot, air pollution, QA system, react, fastapi, chromadb\n--\u003e\n\n# 🌱 RAG 空氣污染問答系統（DuckDNS + Nginx 部署版本）\n\n本專案為一套結合語意檢索（Retrieval-Augmented Generation, RAG）與生成式 AI 的智慧型問答系統，針對空氣污染政策、健康影響與環境法規等主題，提供即時、精準且具可查證性的回應。\n\n本版本為原始專案的強化版，**新增整合 DuckDNS 免費網域與 Nginx 靜態頁面 + 反向代理部署機制**，可於區網外部透過自訂網址（如 `http://kmu-rag.duckdns.org`）進行存取。\n\n---\n\n## 🔗 線上測試網址\n\n👉 [http://kmu-rag.duckdns.org/](http://kmu-rag.duckdns.org/)\n\n---\n\n## 🔧 本地端快速啟動說明\n\n### 📦 建立 Conda 環境\n\n```bash\nconda env create -f environment.yml\nconda activate test2\n```\n\n---\n\n### 🧩 前端啟動（React + Vite）\n\n```bash\ncd frontend\nnpm install\nnpm run dev\n```\n\n如為部署模式，請執行：\n\n```bash\nnpm run build\n```\n\n並確認 `dist/` 資料夾內容已更新。\n\n---\n\n### ⚙️ 後端啟動（FastAPI + LangChain + Ollama）\n\n```bash\ncd backend\nconda activate test2\nuvicorn main:app --reload\n```\n\n後端 Swagger 測試網址：  \n[http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs)\n\n---\n\n### 🌐 外部部署（Nginx + DuckDNS）\n\n- 將前端打包後產生的 `dist` 目錄掛載至 Nginx `root` 設定目錄\n- Nginx 設定中 `location /api` 需反向代理至後端 FastAPI (`http://127.0.0.1:8000`)\n- 執行 `duckdns_update.bat` 以自動更新 DuckDNS 的 IP\n- 確保防火牆開放 80 及 FastAPI 對應 port\n\n---\n\n### 前端每次更新 要做的步驟\n```bash\nnpm run build\n\n```\n```bash\ncd C:\\nginx\nnginx -s reload\n```\n\n### 停止再啟動\n```bash\nnginx -s stop\nstart nginx\n```\n\n## 📁 專案結構（新版本）\n\n```\ndeploy-safe/\n├── backend/                 # FastAPI 後端\n├── frontend/                # React + Vite 前端原始碼\n├── dist/                    # 打包後的靜態前端檔案（供 Nginx 部署）\n├── duckdns_update.bat       # DuckDNS 網域 IP 更新批次檔\n├── environment.yml          # Conda 環境設定\n├── nginx.conf               # Nginx 配置檔（若有備份）\n├── package.json             # 前端專案設定\n├── README.md                # 本說明文件\n```\n\n---\n\n## 🧠 技術架構總覽\n\n| 元件             | 說明                                                                 |\n|------------------|----------------------------------------------------------------------|\n| **RAG 架構**      | 使用 LangChain 整合 Chroma 向量資料庫與本地 LLM 模型（如 Gemma、Qwen）     |\n| **語意檢索**       | 採用 BGE-m3 或 all-mpnet-base-v2 向量模型進行文件嵌入與查詢                        |\n| **回答生成**       | 結合查詢結果與自訂 Prompt，透過本地部署 LLM 生成答案                               |\n| **後端 API**      | 使用 FastAPI 撰寫 `/api/predict` 等推論服務，支援 JSON 格式資料交換                  |\n| **靜態網頁與反向代理** | 使用 Nginx 提供前端 `dist` 靜態檔案並轉發 `/api` 請求至後端 FastAPI API                  |\n| **前端介面**       | 使用 Vite 建立的 React 前端，支援提問、回覆呈現與格式化 Markdown                        |\n| **模型部署**       | 搭配 Ollama 進行本地 LLM 部署，可支援 Gemma 3B、Qwen 14B 等模型                       |\n| **免費網域串接**     | 使用 DuckDNS 建立自訂網域（如 `kmu-rag.duckdns.org`），供外部使用者連線                   |\n| **評估機制**       | 可搭配 RAGAS 框架進行忠實度、語意相關性等指標的自動評估                                   |\n| **版本控管**       | 使用 Git 控制前後端與部署環境變更，搭配 `.gitignore` 排除暫存與模型檔案                     |\n\n---\n\n## 🧾 資料處理方式說明\n\n- **長文資料**：以標題為單位切割段落，再以語意斷句處理，每段設計 chunk_size 與 overlap 切片後進行向量化。\n- **QA 文件**：完整保留問答對內容，不進行切段，確保回答語境與邏輯一致性。\n- 所有文件轉換為結構化 JSON 格式，欄位包含 `title`、`content`、`doc_id`、`source` 等欄位。\n\n\u003e 🔧 設定上，QA 的文本不進行切割，僅針對長文本進行 chunk 處理。\n\n---\n\n## 🖼️ 系統展示畫面\n\n![RAG 系統展示圖](https://github.com/Tsai1030/rag-air-pollution/blob/main/frontend/public/images/%E5%B1%95%E7%A4%BA%E7%85%A7%E7%89%87.png?raw=true)\n\n---\n\n## 📬 聯絡方式\n\n**蔡承紘 Cheng-Hung, Tsai**  \n📧 Email : pijh102511@gmail.com  \n📍 高雄醫學大學 醫療資訊研究所（AI組）碩士生\n\n---\n\n\u003e 若你覺得此專案對你有幫助，歡迎 Star 🌟 或提出 Issue / Pull Request 改進 🙌\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsai1030%2Fdeploy-safe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftsai1030%2Fdeploy-safe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsai1030%2Fdeploy-safe/lists"}