{"id":21009093,"url":"https://github.com/adt109119/chatpdf-linebot","last_synced_at":"2025-05-15T02:32:58.274Z","repository":{"id":239727305,"uuid":"798688183","full_name":"ADT109119/ChatPDF-LineBot","owner":"ADT109119","description":"使用LnagChain+FastAPI+Vue，搭建一個可以上傳並讀取PDF回答問題的LineBot。","archived":false,"fork":false,"pushed_at":"2024-07-26T05:36:27.000Z","size":285,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-07-26T06:41:24.755Z","etag":null,"topics":["ai","chatbot","chatgpt","linebot","llm","python","rag"],"latest_commit_sha":null,"homepage":"https://adt109119.github.io/ChatPDF-LineBot-Docs/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ADT109119.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2024-05-10T09:29:37.000Z","updated_at":"2024-07-26T05:36:31.000Z","dependencies_parsed_at":"2024-06-17T11:53:49.836Z","dependency_job_id":null,"html_url":"https://github.com/ADT109119/ChatPDF-LineBot","commit_stats":null,"previous_names":["adt109119/chatpdf-linebot"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ADT109119%2FChatPDF-LineBot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ADT109119%2FChatPDF-LineBot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ADT109119%2FChatPDF-LineBot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ADT109119%2FChatPDF-LineBot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ADT109119","download_url":"https://codeload.github.com/ADT109119/ChatPDF-LineBot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225324103,"owners_count":17456460,"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":["ai","chatbot","chatgpt","linebot","llm","python","rag"],"created_at":"2024-11-19T09:15:25.318Z","updated_at":"2024-11-19T09:15:25.918Z","avatar_url":"https://github.com/ADT109119.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Line PDF 問答機器人\n\n這是一個使用 LangChain、FastAPI 和 Vue 構建的 Line Bot，可以透過 Line Liff 網頁上傳 PDF 文件並回答相關問題。\n\n## 範例\n\n| ![Screenshot_20240514-132200](https://github.com/ADT109119/ChatPDF-LineBot/assets/106337749/996fea6c-3ae8-4d9a-baff-7ada3860b4f9) | ![Screenshot_20240514-131836](https://github.com/ADT109119/ChatPDF-LineBot/assets/106337749/0cb06999-e8c3-4779-8fe2-c6f87a7a370c) |Demo 連結(每次更新時刪檔)  ![image](https://github.com/ADT109119/ChatPDF-LineBot/assets/106337749/c1860b26-3371-4b2d-935f-cc4823286092)   https://lin.ee/QajGJOY|\n|------|------|------|\n\n## 說明文件\n\n* [中文](https://adt109119.github.io/ChatPDF-LineBot-Docs/)\n* [English](https://adt109119.github.io/ChatPDF-LineBot-Docs/en/) (使用 ChatGPT 翻譯)\n\n## 功能\n\n目前支援以下幾種功能:\n- [x] 上傳 PDF 文件\n- [x] 自然語言處理，從 PDF 中提取相關內容回答問題\n- [x] 自動 Embedding 文件\n- [x] 使用 Line Bot 進行互動\n\n尚待完成:\n- [ ] 顯示用戶使用量\n- [ ] 文件預覽\n- [ ] 功能列表\n\n## 技術\n\n- **LangChain**: 用於構建問答系統和文本處理\n- **FastAPI**: 用於構建 Web API 服務\n- **Vue.js**: 用於構建用戶介面\n- **Line Bot SDK**: 用於與 Line 平台集成\n\n## Hugging Face 一鍵部署\n\n本專案可以快速部署在 Hugging Face 上\n\n支援 CloudFlare Tunnel 自訂網址\n\n但要注意若無購買 Hugging Face 的永久儲存空間\n\n每次更新或更改資料時檔案都會遺失\n\n[![](https://huggingface.co/datasets/huggingface/badges/resolve/main/deploy-on-spaces-lg-dark.svg)](https://huggingface.co/spaces/ADT109119/ChatPDF-LineBot?duplicate=true)\n\n## 安裝\n\u003e 使用 Docker 的人可直接跳至第 5 步\n\n### 1. 複製存儲庫:\n```\ngit clone https://github.com/ADT109119/ChatPDF-LineBot-Docs.git\n```\n\n### 2. 安裝伺服器依賴:\n```\ncd ChatPDF-LineBot\npip install -r requirements.txt\n```\n可考慮在虛擬環境中執行，這裡提供 Python 內建的虛擬環境指令:\n```\ncd ChatPDF-LineBot\npython -m venv .\\venv\n.\\venv\\Scripts\\activate\npip install -r requirements.txt\n```\n\n### 3. 安裝 Node 依賴:\n```\ncd ChatPDF-LineBot/View\nnpn install\n```\n\n### 4. Build 前端網頁\n```\ncd View\nnpm install\nnpm run build\n```\n\n### 5. 登入 LINE 平台\n   * 創建 Line Bot。\n      * 新增一個提供者（Provider），例如「My Provider」。\n      * 在「My Provider」新增一個類型為「Messaging API」的頻道（Channel），例如「My AI Assistant」。\n      * 進到「My AI Assistant」頻道頁面，點選「Messaging API」頁籤，生成一個頻道的 channel access token。\n   * 創建 LIFF 網頁。\n      * 在與「Messaging API」同一個 `Provider` 內(例如:「My Provider」)新增一個類型為「Line Login」的頻道（Channel），例如「My LIFF Page」。\n      * 進到「My LIFF Page」頻道頁面，點選「LIFF」頁籤，創建一個新的 LIFF 網頁。\n      * `Endpoint URL` 填入 `https://\u003c你的網域或IP地址\u003e/liff`(可先隨便填後續再來改)。\n      * `Scopes` 選項請勾選「chat_message.write」、「openid」。\n      * 點選 `Add` 創建。\n\n### 6. 登入 OpenAI、Groq 平台(或其他平台)\n* 生成一個 OpenAI 的 API key。\n* 也可以生成其他平台的API Key(例如 Groq)，只是該平台的 API 必須與 OpenAI 兼容，且要記得在下一步改`BASE_URL`\n\n### 7. 設定環境變數\n\n伺服器或 Docker 可直接設定環境變數\n\n自己電腦上跑的話可複製 `.env.example` 文件，並改名為 `.env`，接著設定 API Key、模型等參數。\n\n以下為 `環境變數列表` `*` 代表必改項目\n\n#### 環境變數列表\n\n| 變數 | 說明 | 預設值 |\n|------|------|------|\n| `MODEL_NAME` | 用於問答的模型名稱,多個模型以`\\|`分隔 | `llama3-8b-8192\\|gpt-3.5-turbo\\|gpt-4-1106-preview` |\n| `BASE_URL` | 對應模型的 API 基礎 URL,多個 URL 以`\\|`分隔 | `https://api.groq.com/openai/v1\\|https://api.openai.com/v1\\|https://api.openai.com/v1` |\n| * `API_KEY` | 對應模型的 API 密鑰,多個密鑰以`\\|`分隔 | `API_KEY_1\\|API_KEY_2\\|API_KEY_3` |\n| `MAX_CHAT_HISTORY` | 保留的最大聊天記錄數 | `5` |\n| `EMBEDDING_MODEL` | 用於文本嵌入的模型名稱(請填入HF模型路徑) | `sentence-transformers/all-MiniLM-L6-v2` |\n| `EMBEDDING_DEVICE` | 運行文本嵌入模型的設備(cpu或cuda，可用cuda:0、cuda:1選擇顯卡) | `cpu` |\n| * `LINE_CHANNEL_ACCESS_TOKEN` | Line Bot 的access token | `YOUR_LINE_CHANNEL_ACCESS_TOKEN` |\n| * `LINE_CHANNEL_SECRET` | Line Bot 的secret | `YOUR_LINE_CHANNEL_SECRET` |\n| * `LINE_LIFF_ID` | Line LIFF 網頁 ID | `YOUR_LINE_LIFF_ID` |\n| * `LINE_LOGIN_CHANNEL_ID` | Line LIFF 所在的 LINE Login Channel ID | `YOUR_LINE_LOGIN_CHANNEL_ID` |\n| `FILE_MAX_SIZE` | 允許上傳的最大文件大小 | `5MB` |\n| `SPACE_PER_USER` | 每個用戶可用的最大空間大小 | `200MB` |\n| `ALLOW_FILE_TYPE` | 允許上傳的文件類型,多個類型以`,`分隔 | `pdf,csv,txt` |\n\n\n### 8. 運行伺服器\n\n#### 使用 Docker\n\n![Docker Image Size (tag)](https://img.shields.io/docker/image-size/adt109119/chatpdf-linebot/latest)\n\n```\ndocker run -d \\\n--name chatpdf-linebot \\\n-p 8000:8000 \\\n-v /local/file/store/path:/app/db\n-e LINE_CHANNEL_ACCESS_TOKEN=YOUR_LINE_CHANNEL_ACCESS_TOKEN \\\n-e LINE_CHANNEL_SECRET=YOUR_LINE_CHANNEL_SECRET \\\n-e LINE_LIFF_ID=YOUR_LINE_LIFF_ID \\\n-e LINE_LOGIN_CHANNEL_ID=YOUR_LINE_LOGIN_CHANNEL_ID \\\n-e MODEL_NAME=YOUR_MODELS \\\n-e BASE_URL=BASE_URLS \\\n-e API_KEY=API_KEYS \\\nadt109119/chatpdf-linebot\n```\n\n#### 本機直接運行\n\n若 1. ~ 4. 步的安裝皆無問題，僅需直接執行以下指令便可開啟伺服器\n\n預設使用 `PORT` `8000`\n```\npython .\\main.py\n```\n\n### 9. 回到 LINE 設定\n* Line Bot 設定\n  * 進到「My AI Assistant」頻道頁面，點選「Messaging API」頁籤，設置「Webhook URL」，填入應用程式網址並加上「/callback」路徑，例如 `https://line.the-walking.fish.com/callback`，點選「Update」按鈕。\n  * 點選「Verify」按鈕，驗證是否呼叫成功。\n  * 將「Use webhook」功能開啟。\n  * 將「Auto-reply messages」功能關閉。\n  * 將「Greeting messages」功能關閉。\n  \n* Line LIFF 網頁設定\n  * 進到「LIFF」頁籤\n  * 若原本`Endpoint URL` 隨便填的，現在請正式填入 LIFF 網頁網址，路徑為「/liff」，例如 `https://line.the-walking.fish.com/liff`。\n  * 回到「LIFF」頁籤，複製「LIFF URL」\n \n* 圖文選單設定\n  * 進到「LINE Official Account Manager」\n  * 在側邊欄找到「圖文選單」\n  * 點選「建立」\n  * 名稱、版型等可照自己的喜好填寫\n  * 在「動作」選擇「連結」，並填入上一部複製的 LIFF URL\n  * 按「儲存」\n\n## 貢獻\n\n如果您有任何改進建議或錯誤修復，歡迎提交 Pull Request。\n\n\u003ca href=\"https://github.com/ADT109119/ChatPDF-LineBot/graphs/contributors\" target=\"_blank\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=ADT109119/ChatPDF-LineBot\"/\u003e\n\u003c/a\u003e\n\n## 聯繫作者\n\n你可以透過以下方式與我聯絡\n\n- 2.jerry32262686@gmail.com\n\n\n## License\nThis project is under the Apache 2.0 License. See [LICENSE](https://github.com/ADT109119/ChatPDF-LineBot/blob/main/LICENSE) for further details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadt109119%2Fchatpdf-linebot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadt109119%2Fchatpdf-linebot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadt109119%2Fchatpdf-linebot/lists"}