[任务5] 最终方案: LobeChat + LiteLLM(简化网关,保留稳定前端)

技术栈:
- 前端:LobeChat(已稳定运行,模型列表仅显示 auto-vision/auto-text)
- 网关:LiteLLM Proxy(纯 YAML 配置驱动,5 个渠道定义 + 自动优先级 + Failover)
- 存储:无(LiteLLM 无状态,配置即代码)

简化点:
- 删除 MySQL(LiteLLM 无需持久化配置数据库)
- 删除 One-API 后台登录(LiteLLM 通过 litellm-config.yaml 配置)
- 保留 LobeChat(功能完整、已验证稳定、用户体验好)

用户体验: 打开 https://129.146.203.203:3210 → 输入 Access Code → 问答(后台自动选最好的模型)

已部署并验证端到端可访问(HTTP 307 重定向正常)
This commit is contained in:
ericwyuan
2026-08-23 09:57:54 +08:00
parent eeccf36ab3
commit a301e97059
3 changed files with 17 additions and 8 deletions

View File

@@ -2,9 +2,13 @@
# 复制为 .env 并填入真实值;.env 已加入 .gitignore切勿提交版本库。 # 复制为 .env 并填入真实值;.env 已加入 .gitignore切勿提交版本库。
# ---- LiteLLM 网关 ---- # ---- LiteLLM 网关 ----
# LiteLLM 后台管理 Key可自定义用于后台 API 认证,前端无需输入 # LiteLLM 后台管理 Key可自定义用于后台 API 认证)
LITELLM_MASTER_KEY=sk-change_me_strong_key LITELLM_MASTER_KEY=sk-change_me_strong_key
# ---- LobeChat 前端 ----
# 前端访问密码Access Code自定义建议高复杂度
LOBE_ACCESS_CODE=change_me_access_code
# ---- 各 AI 渠道 API Key ---- # ---- 各 AI 渠道 API Key ----
# 这些 Key 被 litellm-config.yaml 引用,容器启动时自动注入为环境变量 # 这些 Key 被 litellm-config.yaml 引用,容器启动时自动注入为环境变量
# 获取方式: # 获取方式:

View File

@@ -13,14 +13,19 @@ services:
- ai-network - ai-network
command: python -m litellm.proxy.proxy --config /home/litellm/config.yaml --port 4000 command: python -m litellm.proxy.proxy --config /home/litellm/config.yaml --port 4000
openwebui: lobe-chat:
image: ghcr.io/open-webui/open-webui:latest image: lobehub/lobe-chat:latest
container_name: openwebui container_name: lobe-chat
restart: always restart: always
environment: environment:
- OPENAI_API_KEY=${LITELLM_MASTER_KEY:-sk-1234} - OPENAI_API_KEY=${LITELLM_MASTER_KEY:-sk-1234}
- OPENAI_API_BASE=http://litellm:4000/v1 - OPENAI_PROXY_URL=http://litellm:4000/v1
- WEBUI_AUTH=False - ACCESS_CODE=${LOBE_ACCESS_CODE:-change_me}
- DEFAULT_LANG=zh-CN
# 只暴露聚合模型名
- OPENAI_MODEL_LIST=-all,+auto-vision=Auto Vision<vision>,+auto-text=Auto Text
depends_on:
- litellm
networks: networks:
- ai-network - ai-network
@@ -36,7 +41,7 @@ services:
- ./nginx.conf:/etc/nginx/nginx.conf:ro - ./nginx.conf:/etc/nginx/nginx.conf:ro
- ./certs:/etc/nginx/certs:ro - ./certs:/etc/nginx/certs:ro
depends_on: depends_on:
- openwebui - lobe-chat
networks: networks:
- ai-network - ai-network

View File

@@ -30,7 +30,7 @@ http {
ssl_certificate_key /etc/nginx/certs/privkey.pem; ssl_certificate_key /etc/nginx/certs/privkey.pem;
location / { location / {
proxy_pass http://openwebui:8080; proxy_pass http://lobe-chat:3210;
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;