Lobe Chat 開源 AI 聊天平台

使用 Lobe Chat 建立多模型 AI 聊天助手,支援外掛系統、知識庫、多模態對話

專案簡介

Lobe Chat 是一個開源的多模型 AI 聊天平台,提供類似 ChatGPT 的使用體驗。支援多種 LLM 提供者、外掛生態系統、知識庫整合等功能。

GitHub Stars: 72K+

主要功能

  • 多模型 - OpenAI、Claude、Gemini、本地模型
  • 外掛系統 - 200+ 外掛擴展功能
  • 知識庫 - RAG 檔案對話
  • 多模態 - 圖片、語音、檔案
  • 自訂助手 - 建立專屬 AI 角色

快速部署

Vercel 部署

Deploy with Vercel

Docker 部署

1
2
3
4
docker run -d -p 3210:3210 \
  -e OPENAI_API_KEY=sk-xxx \
  --name lobe-chat \
  lobehub/lobe-chat

訪問 http://localhost:3210

Docker Compose

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
version: '3.8'
services:
  lobe-chat:
    image: lobehub/lobe-chat
    ports:
      - "3210:3210"
    environment:
      - OPENAI_API_KEY=sk-xxx
      - OPENAI_PROXY_URL=https://api.openai.com/v1
      - ACCESS_CODE=your-password
    volumes:
      - ./data:/root/.lobe-chat

模型設定

支援的提供者

提供者環境變數
OpenAIOPENAI_API_KEY
AnthropicANTHROPIC_API_KEY
GoogleGOOGLE_API_KEY
AzureAZURE_API_KEY
OllamaOLLAMA_PROXY_URL

本地模型整合

1
2
3
docker run -d -p 3210:3210 \
  -e OLLAMA_PROXY_URL=http://host.docker.internal:11434/v1 \
  lobehub/lobe-chat

多模型設定

1
2
3
4
5
environment:
  - OPENAI_API_KEY=sk-xxx
  - ANTHROPIC_API_KEY=sk-ant-xxx
  - ENABLED_OLLAMA=1
  - OLLAMA_PROXY_URL=http://ollama:11434/v1

外掛系統

內建外掛

  • Web Browsing - 網頁搜尋
  • DALL-E - 圖片生成
  • Code Interpreter - 程式執行
  • PDF Reader - PDF 解析

安裝外掛

  1. 進入設定 → 外掛
  2. 瀏覽外掛商店
  3. 點擊安裝

自訂外掛

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
{
  "identifier": "security-scanner",
  "api": [
    {
      "name": "scanUrl",
      "description": "Scan URL for vulnerabilities",
      "parameters": {
        "type": "object",
        "properties": {
          "url": { "type": "string" }
        }
      }
    }
  ],
  "gateway": "https://your-api.com/scan"
}

知識庫功能

上傳文件

支援格式:

  • PDF
  • Word
  • Markdown
  • 純文字

建立知識庫

  1. 進入「知識庫」頁面
  2. 建立新知識庫
  3. 上傳文件
  4. 在對話中啟用

RAG 設定

1
2
3
environment:
  - ENABLED_KNOWLEDGE=1
  - EMBEDDING_MODEL=text-embedding-3-small

自訂助手

建立助手

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
name: Security Advisor
description: Cybersecurity expert assistant
systemRole: |
  You are a cybersecurity expert. Help users with:
  - Vulnerability assessment
  - Security best practices
  - Incident response
  - Compliance guidance

  Always prioritize security and provide actionable advice.  

助手市場

瀏覽和使用社群分享的助手:

  • 程式開發
  • 文案寫作
  • 資料分析
  • 安全顧問

進階設定

存取控制

1
2
3
environment:
  # 設定存取密碼
  - ACCESS_CODE=your-secure-password

資料庫模式

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
services:
  lobe-chat:
    environment:
      - DATABASE_URL=postgresql://user:pass@postgres:5432/lobe

  postgres:
    image: postgres:16
    environment:
      - POSTGRES_USER=user
      - POSTGRES_PASSWORD=pass
      - POSTGRES_DB=lobe

自訂域名

1
2
environment:
  - NEXTAUTH_URL=https://chat.example.com

API 使用

OpenAI 格式 API

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:3210/api/openai/v1",
    api_key="your-access-code"
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {"role": "user", "content": "Hello!"}
    ]
)

相關連結

延伸閱讀

comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy