繁體中文
本項目 AS-FAQ-Web-ChatBot 是 AS-FAQ-RAG 的前端聊天介面,並包含呼叫後端 API 的功能。
AS-FAQ-RAG 是一個基於 RAG(Retrieval-Augmented Generation)技術的 FAQ 系統。它結合了前端網頁和後端 API,提供了一個解決方案來自動回應常見問題。前端網頁 AS-FAQ-Web-ChatBot 提供了使用者友善的介面,而後端 API AS-FAQ-RAG 負責處理數據檢索和產生答案。
English
This project (AS-FAQ-Web-ChatBot) is the front-end chat interface for AS-FAQ-RAG and includes the functionality to call the back-end API.
AS-FAQ-RAG is an FAQ system based on RAG (Retrieval-Augmented Generation) technology. It combines a front-end web interface with a back-end API to provide automated responses to frequently asked questions. The front-end web interface, AS-FAQ-Web-ChatBot, offers a user-friendly interface, while the back-end API, AS-FAQ-RAG, handles data retrieval and answer generation.
繁體中文
以下提供兩種安裝方式:使用 CLI 或使用 Docker Compose。
English
Below are two methods of installation: using the CLI or using Docker Compose.
- node v20.18.0
- npm 8.15.0
繁體中文
-
進入專案目錄
cd AS-FAQ-Web-ChatBot -
安裝前端套件
npm install
-
執行 tailwindcss (即時編譯前端 CSS)
npm run watch
-
編輯
.env.example文件,根據需要修改cp .env.example .env vim .env
-
啟動 node server
node server.js
-
開啟瀏覽器,並輸入網址:http://localhost:3000
English
-
Enter the project directory:
cd AS-FAQ-Web-ChatBot -
Install front-end dependencies:
npm install
-
Run tailwindcss for real-time CSS compilation:
npm run watch
-
Copy and edit
.env.exampleas needed:cp .env.example .env vim .env
-
Start the Node server:
node server.js
-
Open your browser at: http://localhost:3000
繁體中文
-
進入專案目錄
cd AS-FAQ-Web-ChatBot -
編輯
.env.example文件,根據需要修改cp .env.example .env vim .env
-
使用 Docker Compose 啟動服務
docker compose up -d
-
開啟瀏覽器,並輸入網址:http://localhost:3080
English
-
Enter the project directory:
cd AS-FAQ-Web-ChatBot -
Copy and edit
.env.exampleas needed:cp .env.example .env vim .env
-
Start the service with Docker Compose:
docker compose up -d
-
Open your browser at: http://localhost:3080
繁體中文
假設您的目錄架構如下:
YOUR-DIR/
├── docker-compose.yml
├── AS-FAQ-RAG/
│ ├── Dockerfile
│ ├── .env
│ └── ...(其他檔案)
└── AS-FAQ-Web-ChatBot/
├── Dockerfile
├── .env
└── ...(其他檔案)
-
在第一層目錄建立
docker-compose.ymlservices: api: build: ./AS-FAQ-RAG ports: - "4000:8000" environment: - TZ=Asia/Taipei env_file: - ./AS-FAQ-RAG/.env volumes: - ./AS-FAQ-RAG:/app - ./hf_cache:/app/hf_cache working_dir: /app restart: always web: build: ./AS-FAQ-Web-ChatBot ports: - "3080:3000" environment: - TZ=Asia/Taipei working_dir: /app env_file: - ./AS-FAQ-Web-ChatBot/.env restart: always
-
進入專案目錄,編輯
.env.example文件,根據需要修改bash CopyEdit cp .env.example .env vim .env
-
設定 AS-FAQ-RAG 的部分請參考相關專案
-
使用 Docker Compose 啟動服務
bash CopyEdit docker compose up -d
-
開啟瀏覽器,並輸入網址:http://localhost:3080
English
Assume your directory structure is as follows:
YOUR-DIR/
├── docker-compose.yml
├── AS-FAQ-RAG/
│ ├── Dockerfile
│ ├── .env
│ └── ... (other files)
└── AS-FAQ-Web-ChatBot/
├── Dockerfile
├── .env
└── ... (other files)
-
Create a file named
docker-compose.ymlin the top-level directory:services: api: build: ./AS-FAQ-RAG ports: - "4000:8000" environment: - TZ=Asia/Taipei env_file: - ./AS-FAQ-RAG/.env volumes: - ./AS-FAQ-RAG:/app - ./hf_cache:/app/hf_cache working_dir: /app restart: always web: build: ./AS-FAQ-Web-ChatBot ports: - "3080:3000" environment: - TZ=Asia/Taipei working_dir: /app env_file: - ./AS-FAQ-Web-ChatBot/.env restart: always
-
Go into the project directory, copy and edit the
.env.examplefile as needed:bash CopyEdit cp .env.example .env vim .env
-
Refer to the AS-FAQ-RAG project for its specific configuration.
-
Start the services using Docker Compose:
bash CopyEdit docker compose up -d
-
Open your browser at: http://localhost:3080
-
停止容器
sudo docker compose down -
更新程式碼 (git)
git pull -
建立新映像
sudo docker compose build --no-cache -
啟動容器
sudo docker compose up -d
-
Stop the containers:
sudo docker compose down -
Update the code (git):
git pull -
Build new images:
sudo docker compose build --no-cache -
Start the containers:
sudo docker compose up -d
繁體中文
將使用條款 (tos.html) 與個資政策 (privacy.html) 放在與 index.html 同一層目錄,或在 index.html 中將其指向現有的網頁連結。
在 index.html 中,你可以使用 JavaScript 變數來動態設置這些連結的 URL。
<script>
// 定義變數來存儲連結的 URL
const tosUrl = "tos.html";
const privacyPolicyUrl = "https://www.sinica.edu.tw/CP/377";
document.getElementById('tos-link').href = tosUrl;
document.getElementById('privacy-policy-link').href = privacyPolicyUrl;
</script>English
Place the Terms of Service (tos.html) and Privacy Policy (privacy.html) files in the same directory as index.html, or modify the corresponding links in index.html to point to your existing pages.
In index.html, you can use JavaScript variables to dynamically set the URLs for these links. Here is an example code:
<script>
// Define variables to store the URLs
const tosUrl = "tos.html";
const privacyPolicyUrl = "https://www.sinica.edu.tw/CP/377";
document.getElementById('tos-link').href = tosUrl;
document.getElementById('privacy-policy-link').href = privacyPolicyUrl;
</script>繁體中文
本專案的原始版本為 墜昆霖 先生於中央研究院資訊服務處服務時完成撰寫 (2025/01),特此致謝。
English
The original version of this project was authored by Mr. Kun-Ling Zui during his service at the Department of Information Technology Services of Academia Sinica (2025/01). We would like to express our gratitude.