github-actions[bot] commited on
Commit ·
f938cda
1
Parent(s): caa8226
sync huggingface deployment from Viciy2023/CLIProxyAPI@757f412a36d42bcd769c7008d4edf8ab528ada99
Browse files- .env +63 -0
- .gitattributes +0 -35
- .gitignore +3 -0
- Dockerfile +42 -0
- README.md +24 -5
- config.yaml +72 -0
- entrypoint.sh +30 -0
.env
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Hugging Face Space 部署模式。
|
| 2 |
+
# 必须保留为 cloud,用于启用项目的云部署启动逻辑。
|
| 3 |
+
DEPLOY=cloud
|
| 4 |
+
|
| 5 |
+
# 管理接口密码。
|
| 6 |
+
# 必须设置为你自己的强密码,否则远程管理接口不可安全使用。
|
| 7 |
+
MANAGEMENT_PASSWORD=change-this-to-a-strong-random-password
|
| 8 |
+
|
| 9 |
+
# 管理面板静态资源目录。
|
| 10 |
+
# 默认不需要设置,只有你要手动指定管理面板静态文件目录时才启用。
|
| 11 |
+
# MANAGEMENT_STATIC_PATH=
|
| 12 |
+
|
| 13 |
+
# PostgreSQL 存储连接串。
|
| 14 |
+
# 默认文件存储部署不需要设置,只有切换到 PostgreSQL 存储时才启用。
|
| 15 |
+
# PGSTORE_DSN=postgresql://user:password@host:5432/cliproxyapi
|
| 16 |
+
|
| 17 |
+
# PostgreSQL 使用的 schema。
|
| 18 |
+
# 默认文件存储部署不需要设置,只有切换到 PostgreSQL 存储时才启用。
|
| 19 |
+
# PGSTORE_SCHEMA=public
|
| 20 |
+
|
| 21 |
+
# PostgreSQL 本地缓冲目录。
|
| 22 |
+
# 默认文件存储部署不需要设置,只有切换到 PostgreSQL 存储时才启用。
|
| 23 |
+
# PGSTORE_LOCAL_PATH=/data
|
| 24 |
+
|
| 25 |
+
# Git 存储仓库地址。
|
| 26 |
+
# 默认文件存储部署不需要设置,只有切换到 Git 存储时才启用。
|
| 27 |
+
# GITSTORE_GIT_URL=https://github.com/your-org/cli-proxy-config.git
|
| 28 |
+
|
| 29 |
+
# Git 存储仓库用户名。
|
| 30 |
+
# 默认文件存储部署不需要设置,只有切换到 Git 存储时才启用。
|
| 31 |
+
# GITSTORE_GIT_USERNAME=git-user
|
| 32 |
+
|
| 33 |
+
# Git 存储仓库访问令牌。
|
| 34 |
+
# 默认文件存储部署不需要设置,只有切换到 Git 存储时才启用。
|
| 35 |
+
# GITSTORE_GIT_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxx
|
| 36 |
+
|
| 37 |
+
# Git 存储使用的分支名。
|
| 38 |
+
# 默认文件存储部署不需要设置,只有切换到 Git 存储时才启用。
|
| 39 |
+
# GITSTORE_GIT_BRANCH=main
|
| 40 |
+
|
| 41 |
+
# Git 存储本地工作目录。
|
| 42 |
+
# 默认文件存储部署不需要设置,只有切换到 Git 存储时才启用。
|
| 43 |
+
# GITSTORE_LOCAL_PATH=/data
|
| 44 |
+
|
| 45 |
+
# 对象存储服务地址。
|
| 46 |
+
# 默认文件存储部署不需要设置,只有切换到对象存储时才启用。
|
| 47 |
+
# OBJECTSTORE_ENDPOINT=https://s3.your-cloud.example.com
|
| 48 |
+
|
| 49 |
+
# 对象存储访问密钥 ID。
|
| 50 |
+
# 默认文件存储部署不需要设置,只有切换到对象存储时才启用。
|
| 51 |
+
# OBJECTSTORE_ACCESS_KEY=your-access-key
|
| 52 |
+
|
| 53 |
+
# 对象存储访问密钥 Secret。
|
| 54 |
+
# 默认文件存储部署不需要设置,只有切换到对象存储时才启用。
|
| 55 |
+
# OBJECTSTORE_SECRET_KEY=your-secret-key
|
| 56 |
+
|
| 57 |
+
# 对象存储桶名称。
|
| 58 |
+
# 默认文件存储部署不需要设置,只有切换到对象存储时才启用。
|
| 59 |
+
# OBJECTSTORE_BUCKET=cli-proxy-config
|
| 60 |
+
|
| 61 |
+
# 对象存储本地缓存目录。
|
| 62 |
+
# 默认文件存储部署不需要设置,只有切换到对象存储时才启用。
|
| 63 |
+
# OBJECTSTORE_LOCAL_PATH=/data
|
.gitattributes
DELETED
|
@@ -1,35 +0,0 @@
|
|
| 1 |
-
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
-
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
-
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
-
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
-
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
-
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
-
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
-
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
-
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
-
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
-
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
-
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
-
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
-
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
-
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
-
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
-
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
-
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
-
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
-
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
-
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
-
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
-
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
-
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.gitignore
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.DS_Store
|
| 2 |
+
*.log
|
| 3 |
+
tmp/
|
Dockerfile
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM alpine:3.22.0
|
| 2 |
+
|
| 3 |
+
ARG CLIPROXYAPI_REPO=router-for-me/CLIProxyAPI
|
| 4 |
+
|
| 5 |
+
ENV APP_HOME=/opt/cli-proxy-api \
|
| 6 |
+
DATA_DIR=/data \
|
| 7 |
+
HOME=/data \
|
| 8 |
+
TZ=Asia/Shanghai
|
| 9 |
+
|
| 10 |
+
RUN apk add --no-cache ca-certificates curl tar tzdata
|
| 11 |
+
|
| 12 |
+
RUN mkdir -p "$APP_HOME" "$DATA_DIR"
|
| 13 |
+
|
| 14 |
+
RUN set -eux; \
|
| 15 |
+
latest_url="$(curl -fsSLI -o /dev/null -w '%{url_effective}' "https://github.com/${CLIPROXYAPI_REPO}/releases/latest")"; \
|
| 16 |
+
tag="${latest_url##*/}"; \
|
| 17 |
+
version="${tag#v}"; \
|
| 18 |
+
asset="CLIProxyAPI_${version}_linux_amd64.tar.gz"; \
|
| 19 |
+
asset_url="https://github.com/${CLIPROXYAPI_REPO}/releases/download/${tag}/${asset}"; \
|
| 20 |
+
checksums_url="https://github.com/${CLIPROXYAPI_REPO}/releases/download/${tag}/checksums.txt"; \
|
| 21 |
+
curl -fsSL "$checksums_url" -o /tmp/checksums.txt; \
|
| 22 |
+
curl -fsSL "$asset_url" -o /tmp/cli-proxy-api.tar.gz; \
|
| 23 |
+
expected_sha="$(grep " ${asset}$" /tmp/checksums.txt | awk '{print $1}')"; \
|
| 24 |
+
test -n "$expected_sha"; \
|
| 25 |
+
echo "$expected_sha /tmp/cli-proxy-api.tar.gz" | sha256sum -c -; \
|
| 26 |
+
tar -xzf /tmp/cli-proxy-api.tar.gz -C "$APP_HOME"; \
|
| 27 |
+
if [ -f "$APP_HOME/CLIProxyAPI" ]; then mv "$APP_HOME/CLIProxyAPI" "$APP_HOME/cli-proxy-api"; fi; \
|
| 28 |
+
test -f "$APP_HOME/cli-proxy-api"; \
|
| 29 |
+
chmod +x "$APP_HOME/cli-proxy-api"; \
|
| 30 |
+
rm -f /tmp/checksums.txt /tmp/cli-proxy-api.tar.gz
|
| 31 |
+
|
| 32 |
+
COPY entrypoint.sh /entrypoint.sh
|
| 33 |
+
|
| 34 |
+
RUN chmod +x /entrypoint.sh && \
|
| 35 |
+
cp /usr/share/zoneinfo/${TZ} /etc/localtime && \
|
| 36 |
+
echo "${TZ}" > /etc/timezone
|
| 37 |
+
|
| 38 |
+
WORKDIR /data
|
| 39 |
+
|
| 40 |
+
EXPOSE 8317
|
| 41 |
+
|
| 42 |
+
ENTRYPOINT ["/entrypoint.sh"]
|
README.md
CHANGED
|
@@ -1,10 +1,29 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji: 🏆
|
| 4 |
-
colorFrom: red
|
| 5 |
-
colorTo: yellow
|
| 6 |
sdk: docker
|
|
|
|
| 7 |
pinned: false
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: CLIProxyAPI Server
|
|
|
|
|
|
|
|
|
|
| 3 |
sdk: docker
|
| 4 |
+
app_port: 8317
|
| 5 |
pinned: false
|
| 6 |
---
|
| 7 |
|
| 8 |
+
# CLIProxyAPI Server
|
| 9 |
+
|
| 10 |
+
This Space runs `CLIProxyAPI` from the latest upstream GitHub release instead of building from source.
|
| 11 |
+
|
| 12 |
+
## Runtime Layout
|
| 13 |
+
|
| 14 |
+
- Persistent data directory: `/data`
|
| 15 |
+
- Environment file: `/data/.env`
|
| 16 |
+
- Main config file: `/data/config.yaml`
|
| 17 |
+
- Default home directory: `/data`
|
| 18 |
+
|
| 19 |
+
## Startup Behavior
|
| 20 |
+
|
| 21 |
+
- The container downloads the latest release from `router-for-me/CLIProxyAPI` during image build.
|
| 22 |
+
- On first start, if `/data/config.yaml` does not exist, it is created from the bundled `config.example.yaml`.
|
| 23 |
+
- The service starts with `--config /data/config.yaml`.
|
| 24 |
+
- Because the working directory is `/data`, CLIProxyAPI loads `/data/.env` automatically.
|
| 25 |
+
|
| 26 |
+
## Notes
|
| 27 |
+
|
| 28 |
+
- Keep the service port aligned with this Space setting. The default here is `8317`.
|
| 29 |
+
- Persisted auth data and other runtime files stay under `/data`.
|
config.yaml
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Hugging Face Space 推荐最小配置模板。
|
| 2 |
+
# 容器启动时会优先读取 /data/config.yaml。
|
| 3 |
+
# 如果 /data/config.yaml 不存在,可先将本文件内容作为初始配置使用。
|
| 4 |
+
|
| 5 |
+
# 监听所有网卡,便于 Hugging Face 外部访问。
|
| 6 |
+
host: ""
|
| 7 |
+
|
| 8 |
+
# 服务端口,需要和 Space 的 app_port 保持一致。
|
| 9 |
+
port: 8317
|
| 10 |
+
|
| 11 |
+
remote-management:
|
| 12 |
+
# 允许从外部访问管理接口,否则 Hugging Face 域名无法打开管理功能。
|
| 13 |
+
allow-remote: true
|
| 14 |
+
|
| 15 |
+
# 管理密钥。
|
| 16 |
+
# 建议与 /data/.env 里的 MANAGEMENT_PASSWORD 使用同一个强密码,便于统一管理。
|
| 17 |
+
secret-key: "change-this-to-a-strong-random-password"
|
| 18 |
+
|
| 19 |
+
# 保持默认即可。首次访问管理面板时会自动获取管理面板资源。
|
| 20 |
+
disable-control-panel: false
|
| 21 |
+
|
| 22 |
+
# 管理面板资源仓库,保持默认即可。
|
| 23 |
+
panel-github-repository: "https://github.com/router-for-me/Cli-Proxy-API-Management-Center"
|
| 24 |
+
|
| 25 |
+
# 客户端调用本代理服务时使用的访问密钥。
|
| 26 |
+
# 至少保留一个,并替换为你自己的值。
|
| 27 |
+
api-keys:
|
| 28 |
+
- "change-this-to-your-client-api-key"
|
| 29 |
+
|
| 30 |
+
# 认证数据默认落在 /data 下,配合挂载存储可持久化。
|
| 31 |
+
auth-dir: "/data/.cli-proxy-api"
|
| 32 |
+
|
| 33 |
+
# 初期建议关闭调试日志,稳定后再按需打开。
|
| 34 |
+
debug: false
|
| 35 |
+
|
| 36 |
+
# 默认为关闭,避免额外暴露调试端口。
|
| 37 |
+
pprof:
|
| 38 |
+
enable: false
|
| 39 |
+
addr: "127.0.0.1:8316"
|
| 40 |
+
|
| 41 |
+
# 默认关闭,避免无配置时暴露 websocket 接口。
|
| 42 |
+
ws-auth: false
|
| 43 |
+
|
| 44 |
+
# 使用默认轮询策略即可。
|
| 45 |
+
routing:
|
| 46 |
+
strategy: "round-robin"
|
| 47 |
+
session-affinity: false
|
| 48 |
+
session-affinity-ttl: "1h"
|
| 49 |
+
|
| 50 |
+
# 下面按需启用至少一种上游能力,否则服务虽然能启动,但无法真正转发模型请求。
|
| 51 |
+
|
| 52 |
+
# 方式一:Gemini API Key
|
| 53 |
+
# gemini-api-key:
|
| 54 |
+
# - api-key: "AIzaSy..."
|
| 55 |
+
|
| 56 |
+
# 方式二:Codex API Key
|
| 57 |
+
# codex-api-key:
|
| 58 |
+
# - api-key: "sk-..."
|
| 59 |
+
|
| 60 |
+
# 方式三:Claude API Key
|
| 61 |
+
# claude-api-key:
|
| 62 |
+
# - api-key: "sk-ant-..."
|
| 63 |
+
|
| 64 |
+
# 方式四:OpenAI 兼容上游
|
| 65 |
+
# openai-compatibility:
|
| 66 |
+
# - name: "openrouter"
|
| 67 |
+
# base-url: "https://openrouter.ai/api/v1"
|
| 68 |
+
# api-key-entries:
|
| 69 |
+
# - api-key: "sk-or-v1-..."
|
| 70 |
+
# models:
|
| 71 |
+
# - name: "moonshotai/kimi-k2:free"
|
| 72 |
+
# alias: "kimi-k2"
|
entrypoint.sh
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -eu
|
| 3 |
+
|
| 4 |
+
APP_HOME="${APP_HOME:-/opt/cli-proxy-api}"
|
| 5 |
+
DATA_DIR="${DATA_DIR:-/data}"
|
| 6 |
+
CONFIG_PATH="${CONFIG_PATH:-${DATA_DIR}/config.yaml}"
|
| 7 |
+
EXAMPLE_PATH="${APP_HOME}/config.example.yaml"
|
| 8 |
+
|
| 9 |
+
mkdir -p "${DATA_DIR}" "${DATA_DIR}/auths" "${DATA_DIR}/logs" "${DATA_DIR}/.cli-proxy-api"
|
| 10 |
+
|
| 11 |
+
export HOME="${DATA_DIR}"
|
| 12 |
+
export DEPLOY="${DEPLOY:-cloud}"
|
| 13 |
+
|
| 14 |
+
cd "${DATA_DIR}"
|
| 15 |
+
|
| 16 |
+
if [ ! -f "${DATA_DIR}/.env" ]; then
|
| 17 |
+
printf '%s\n' "warning: ${DATA_DIR}/.env not found, starting without extra environment variables" >&2
|
| 18 |
+
fi
|
| 19 |
+
|
| 20 |
+
if [ ! -f "${CONFIG_PATH}" ]; then
|
| 21 |
+
if [ ! -f "${EXAMPLE_PATH}" ]; then
|
| 22 |
+
printf '%s\n' "fatal: bundled config.example.yaml not found at ${EXAMPLE_PATH}" >&2
|
| 23 |
+
exit 1
|
| 24 |
+
fi
|
| 25 |
+
|
| 26 |
+
cp "${EXAMPLE_PATH}" "${CONFIG_PATH}"
|
| 27 |
+
printf '%s\n' "initialized ${CONFIG_PATH} from bundled config.example.yaml"
|
| 28 |
+
fi
|
| 29 |
+
|
| 30 |
+
exec "${APP_HOME}/cli-proxy-api" --config "${CONFIG_PATH}"
|