fbdxdt commited on
Commit
f4e3401
·
verified ·
1 Parent(s): 0f33f8d

Upload 2 files

Browse files
Files changed (2) hide show
  1. Dockerfile +98 -0
  2. README.md +379 -5
Dockerfile ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM node:lts-alpine3.19
2
+
3
+ # Arguments
4
+ ARG APP_HOME=/home/node/app
5
+ ARG PLUGINS="" # Comma-separated list of plugin git URLs
6
+ ARG USERNAME=""
7
+ ARG PASSWORD=""
8
+
9
+ # Install system dependencies
10
+ # Add unzip for extracting the application code
11
+ # Keep git for potential use by scripts or future plugin updates
12
+ # Add wget to download the zip file
13
+ # Add curl for health checks and keep-alive
14
+ # Add dos2unix to fix CRLF issues
15
+ RUN apk add --no-cache gcompat tini git unzip wget curl dos2unix
16
+
17
+ # Create app directory
18
+ WORKDIR ${APP_HOME}
19
+
20
+ # Set NODE_ENV to production and set credentials from ARGs
21
+ ENV NODE_ENV=production
22
+ ENV APP_HOME=${APP_HOME}
23
+ ENV USERNAME=${USERNAME}
24
+ ENV PASSWORD=${PASSWORD}
25
+
26
+ # --- BEGIN: Clone SillyTavern Core from GitHub (staging branch) ---
27
+ RUN \
28
+ echo "*** Cloning SillyTavern Core from GitHub (staging branch) ***" && \
29
+ # Clone the specific branch into the current directory
30
+ git clone -b staging --depth 1 https://github.com/SillyTavern/SillyTavern.git . && \
31
+ echo "*** Cloning complete. ***"
32
+ # --- END: Clone SillyTavern Core ---
33
+
34
+ # --- BEGIN: Remove root .gitignore if exists ---
35
+ RUN \
36
+ echo "*** Attempting to remove root .gitignore if it exists ***" && \
37
+ rm -f .gitignore && \
38
+ echo "*** Root .gitignore removed (if it existed). ***"
39
+ # --- END: Remove root .gitignore ---
40
+
41
+ # Install base SillyTavern dependencies (package*.json should be in the cloned root)
42
+ RUN \
43
+ echo "*** Install Base npm packages ***" && \
44
+ if [ -f package.json ]; then \
45
+ # Added --force to potentially overcome file system issues in docker/overlayfs
46
+ npm i --no-audit --no-fund --loglevel=error --no-progress --omit=dev --force && npm cache clean --force; \
47
+ else \
48
+ echo "No package.json found in root, skipping base npm install."; \
49
+ fi
50
+
51
+ # Go back to the main app directory (redundant but safe)
52
+ WORKDIR ${APP_HOME}
53
+
54
+ # Create config directory. config.yaml will be handled at runtime by ENTRYPOINT
55
+ RUN mkdir -p config
56
+
57
+ # Pre-compile public libraries (build-lib.js should be in the unzipped structure)
58
+ RUN \
59
+ echo "*** Run Webpack ***" && \
60
+ # Check if build-lib.js exists before running
61
+ if [ -f "./docker/build-lib.js" ]; then \
62
+ node "./docker/build-lib.js"; \
63
+ elif [ -f "./build-lib.js" ]; then \
64
+ node "./build-lib.js"; \
65
+ else \
66
+ echo "build-lib.js not found, skipping Webpack build."; \
67
+ fi
68
+
69
+ # Cleanup unnecessary files (like the docker dir if it exists in the zip) and make entrypoint executable
70
+ # This block is removed as we no longer use docker-entrypoint.sh
71
+ # RUN \
72
+ # echo "*** Cleanup and Permissions ***" && \
73
+ # ...
74
+
75
+ # Fix potential git safe.directory issues if git commands are run later by scripts
76
+ RUN git config --global --add safe.directory "${APP_HOME}"
77
+
78
+ # Ensure the node user owns the application directory and its contents
79
+ RUN chown -R node:node ${APP_HOME}
80
+
81
+ # No longer download external health.sh
82
+ # RUN git clone --depth 1 https://github.com/fuwei99/docker-health.sh.git /tmp/health_repo && \
83
+ # cp /tmp/health_repo/health.sh ${APP_HOME}/health.sh && \
84
+ # rm -rf /tmp/health_repo
85
+
86
+ # Make the downloaded script executable
87
+ # RUN chmod +x ${APP_HOME}/health.sh
88
+
89
+ # Copy the entrypoint script from the repository
90
+ COPY entrypoint.sh /usr/local/bin/entrypoint.sh
91
+
92
+ # Make the new entrypoint executable
93
+ RUN chmod +x /usr/local/bin/entrypoint.sh
94
+
95
+ EXPOSE 8000
96
+
97
+ # Entrypoint: Execute the self-contained startup script
98
+ ENTRYPOINT ["tini", "--", "/usr/local/bin/entrypoint.sh"]
README.md CHANGED
@@ -1,10 +1,384 @@
1
  ---
2
- title: Sss
3
- emoji: 🦀
4
- colorFrom: yellow
5
- colorTo: purple
6
  sdk: docker
7
  pinned: false
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: SillyTavern Docker & HF部署
3
+ emoji: 🥂
4
+ colorFrom: pink
5
+ colorTo: blue
6
  sdk: docker
7
  pinned: false
8
+ app_port: 8000
9
  ---
10
 
11
+ # 最简单的方法:一键部署
12
+
13
+ > **⚠️ 重要提示:** 部署界面中的 **visibility** 一定要改为 **public**,否则无法正常使用!
14
+
15
+ 如果你不想手动配置,可以直接点击下方按钮,一键将 SillyTavern Docker 部署到你自己的 Hugging Face Space 中(需要先注册 Hugging Face 账号):
16
+
17
+ [![部署到 Hugging Face Spaces](https://huggingface.co/datasets/huggingface/badges/resolve/main/deploy-to-spaces-lg.svg)](https://huggingface.co/spaces/malt666/Tavern-Docker?duplicate=true)
18
+
19
+ ## 环境变量配置指南
20
+
21
+ 点击部署按钮后,请按照下表配置环境变量:
22
+
23
+ ### 基本配置(必填项)
24
+
25
+ | 环境变量 | 说明 | 示例值 |
26
+ |---------|------|--------|
27
+ | **PLUGINS** | 云备份插件链接 | `https://github.com/fuwei99/cloud-saves.git` |
28
+ | **认证配置** | USERNAME/PASSWORD 和 CONFIG_YAML 二选一 | - |
29
+
30
+ #### 认证方式(二选一):
31
+
32
+ 1. **USERNAME/PASSWORD**(推荐)
33
+ - 简单直接填写用户名和密码,用于酒馆的登录
34
+
35
+ 2. **CONFIG_YAML**
36
+ - 见下方命令行格式
37
+ - 记得修改配置中的用户名和密码
38
+ - **注意**:由于 Hugging Face 的部署界面有 bug,复制的内容可能会变成一行
39
+ - **解决方法**:部署后进入 Settings → Secrets,点击 CONFIG_YAML 旁边的 replace,重新复制粘贴
40
+
41
+ ### 扩展配置
42
+
43
+ | 环境变量 | 说明 | 示例值 |
44
+ |---------|------|--------|
45
+ | **EXTENSIONS** | 扩展链接列表,用英文逗号分隔 | `https://github.com/N0VI028/JS-Slash-Runner,https://gitee.com/muyoou/st-memory-enhancement` |
46
+ | **INSTALL_FOR_ALL_USERS** | 扩展安装模式 | `true` 或 `false` |
47
+
48
+ > **扩展安装模式INSTALL_FOR_ALL_USERS**:
49
+ > - `true`:安装到全局(推荐)
50
+ > - `false`:仅安装到 default-user
51
+ > - 不填写:默认安装到 default-user
52
+
53
+ ### 可选配置(cloud-saves 插件相关,自动配置基本信息,注意自动保存还是要自己开启,这里只是配置好信息)
54
+
55
+ | 环境变量 | 说明 | 默认值 |
56
+ |---------|------|-------|
57
+ | **REPO_URL** | GitHub 仓库地址 | - |
58
+ | **GITHUB_TOKEN** | GitHub 访问令牌 | - |
59
+ | **AUTOSAVE_INTERVAL** | 自动保存间隔(秒) | 30 |
60
+ | **AUTOSAVE_TARGET_TAG** | 自动保存目标标签 | 空 |
61
+
62
+ ---
63
+
64
+ ## 如何读取或者保存存档
65
+
66
+ 教程见: https://github.com/fuwei99/cloud-saves
67
+
68
+ * 对于推荐安装的 `cloud-saves` 插件,其管理界面通常位于:
69
+ `http://<你的SillyTavern访问地址>/api/plugins/cloud-saves/ui`
70
+ 例如,如果是本地部署,则为 `http://127.0.0.1:8000/api/plugins/cloud-saves/ui`。如果是 Hugging Face Space,则将 `<你的SillyTavern访问地址>` 替换为你的 Space 公共 URL
71
+
72
+ 其他插件的访问路径请参考其各自的文档。
73
+
74
+
75
+ ---
76
+
77
+ # SillyTavern Docker 与 Hugging Face 部署指南
78
+
79
+ 本指南说明了如何使用提供的 `Dockerfile` 来构建和运行 SillyTavern,以及如何在 Hugging Face Spaces 上进行部署。部署的核心思想是通过环境变量在容器启动时动态配置 SillyTavern 和安装插件。
80
+
81
+ ## 关键文件
82
+
83
+ * `Dockerfile`: 用于构建 SillyTavern 运行环境的 Docker 镜像。它会:
84
+ * 基于官方 Node.js Alpine 镜像。
85
+ * 安装必要的系统依赖(如 `git`)。
86
+ * 从 GitHub 克隆 SillyTavern 的 `staging` 分支代码。
87
+ * 设置工作目录和用户权限。
88
+ * 定义容器启动时的 `ENTRYPOINT` 脚本,该脚本负责:
89
+ * 读取 `CONFIG_YAML` 环境变量并写入 `./config.yaml` 文件。
90
+ * 读取 `PLUGINS` 环境变量,并克隆、安装指定的插件。
91
+ * 启动 SillyTavern 服务器 (`node server.js`)。
92
+ * `README.md`: 本说明文件。
93
+
94
+ ## 配置方式:环境变量
95
+
96
+ 我们通过两个主要的环境变量来配置容器:
97
+
98
+ 1. `CONFIG_YAML`: **必需**。
99
+ * **作用**: 定义 SillyTavern 的运行配置。
100
+ * **内容**: 下面是推荐的默认配置内容。你可以直接复制粘贴使用,但**强烈建议你修改其中的认证信息**。
101
+ * **推荐配置内容**:
102
+ ```yaml
103
+ dataRoot: ./data
104
+ listen: true
105
+ listenAddress:
106
+ ipv4: 0.0.0.0
107
+ ipv6: '[::]'
108
+ protocol:
109
+ ipv4: true
110
+ ipv6: false
111
+ dnsPreferIPv6: false
112
+ autorunHostname: "auto"
113
+ port: 8000
114
+ autorunPortOverride: -1
115
+ ssl:
116
+ enabled: false
117
+ certPath: "./certs/cert.pem"
118
+ keyPath: "./certs/privkey.pem"
119
+ whitelistMode: false
120
+ enableForwardedWhitelist: false
121
+ whitelist:
122
+ - ::1
123
+ - 127.0.0.1
124
+ whitelistDockerHosts: true
125
+ basicAuthMode: true
126
+ basicAuthUser:
127
+ username: "用户名" # 请务必修改为你自己的用户名
128
+ password: "密码" # 请务必修改为你自己的密码
129
+ enableCorsProxy: false
130
+ requestProxy:
131
+ enabled: false
132
+ url: "socks5://username:[email protected]:1080"
133
+ bypass:
134
+ - localhost
135
+ - 127.0.0.1
136
+ enableUserAccounts: false
137
+ enableDiscreetLogin: false
138
+ autheliaAuth: false
139
+ perUserBasicAuth: false
140
+ sessionTimeout: -1
141
+ disableCsrfProtection: false
142
+ securityOverride: false
143
+ logging:
144
+ enableAccessLog: true
145
+ minLogLevel: 0
146
+ rateLimiting:
147
+ preferRealIpHeader: false
148
+ autorun: false
149
+ avoidLocalhost: false
150
+ backups:
151
+ common:
152
+ numberOfBackups: 50
153
+ chat:
154
+ enabled: true
155
+ checkIntegrity: true
156
+ maxTotalBackups: -1
157
+ throttleInterval: 10000
158
+ thumbnails:
159
+ enabled: true
160
+ format: "jpg"
161
+ quality: 95
162
+ dimensions: { 'bg': [160, 90], 'avatar': [96, 144] }
163
+ performance:
164
+ lazyLoadCharacters: false
165
+ memoryCacheCapacity: '100mb'
166
+ useDiskCache: true
167
+ allowKeysExposure: true
168
+ skipContentCheck: false
169
+ whitelistImportDomains:
170
+ - localhost
171
+ - cdn.discordapp.com
172
+ - files.catbox.moe
173
+ - raw.githubusercontent.com
174
+ requestOverrides: []
175
+ extensions:
176
+ enabled: true
177
+ autoUpdate: false
178
+ models:
179
+ autoDownload: true
180
+ classification: Cohee/distilbert-base-uncased-go-emotions-onnx
181
+ captioning: Xenova/vit-gpt2-image-captioning
182
+ embedding: Cohee/jina-embeddings-v2-base-en
183
+ speechToText: Xenova/whisper-small
184
+ textToSpeech: Xenova/speecht5_tts
185
+ enableDownloadableTokenizers: true
186
+ promptPlaceholder: "[Start a new chat]"
187
+ openai:
188
+ randomizeUserId: false
189
+ captionSystemPrompt: ""
190
+ deepl:
191
+ formality: default
192
+ mistral:
193
+ enablePrefix: false
194
+ ollama:
195
+ keepAlive: -1
196
+ batchSize: -1
197
+ claude:
198
+ enableSystemPromptCache: false
199
+ cachingAtDepth: -1
200
+ enableServerPlugins: true
201
+ enableServerPluginsAutoUpdate: false
202
+ ```
203
+ * **⚠️ 重要警告**: 请务必修改上方配置中 `basicAuthUser` 下的 `username` 和 `password` 为你自己的凭据,以确保安全!**不要使用默认的 "用户名" 和 "密码"!**
204
+ * **注意**: 必须是有效的 YAML 格式,且**不应包含任何 `#` 开头的注释行**。
205
+
206
+ 2. `PLUGINS`: **可选**。
207
+ * **作用**: 指定需要在容器启动时自动安装的 SillyTavern 插件。
208
+ * **内容**: 一个**逗号分隔**的插件 Git 仓库 URL 列表。
209
+ * **推荐安装**: 强烈建议安装 `cloud-saves` 插件,以便在不同部署环境(如本地和 Hugging Face)之间同步数据。
210
+ * **插件地址**: `https://github.com/fuwei99/cloud-saves.git`
211
+ * **重要前置条件**: 为了让容器/Hugging Face Space 能够拉取你的存档,你**必须**先在你本地的 SillyTavern 中安装好 `cloud-saves` 插件,并**至少进行一次数据存档操作**。这样,远程部署的环境才能通过该插件下载你的存档。
212
+ * **格式示例**: `https://github.com/fuwei99/cloud-saves.git` (注意包含推荐的 cloud-saves 插件)
213
+ * **注意**: URL 之间**只能用英文逗号 `,` 分隔**,且逗号前后**不能有空格**。如果留空或不提供此变量,则不会安装额外插件。
214
+
215
+ 3. `EXTENSIONS`: **可选**。
216
+ * **作用**: 指定需要在容器启动时自动安装的 SillyTavern 扩展(Extensions)。
217
+ * **内容**: 一个**逗号分隔**的扩展 Git 仓库 URL 列表。
218
+ * **安装时机**: 扩展会在项目启动之后自动安装,确保 SillyTavern 目录结构已经准备完毕。
219
+ * **格式示例**: `https://github.com/user1/extension1.git,https://github.com/user2/extension2.git`
220
+ * **注意**: URL 之间**只能用英文逗号 `,` 分隔**,且逗号前后**不能有空格**。如果留空或不提供此变量,则不会安装额外扩展。
221
+
222
+ 4. `INSTALL_FOR_ALL_USERS`: **可选**。
223
+ * **作用**: 控制扩展的安装位置模式。
224
+ * **可选值**:
225
+ * `true`: 扩展安装到 `public/scripts/extensions/third-party` 目录下,对**所有用户**生效(系统级安装)。
226
+ * `false` 或任何其他值,或变量不存在: 扩展安装到 `data/default-user/extensions` 目录下,仅对**默认用户**生效(用户级安装)。
227
+ * **默认行为**: 如果不设置此环境变量,默认安装到用户级目录。
228
+ * **格式示例**: `true` 或 `false`
229
+
230
+ 5. `REPO_URL`: **可选**。
231
+ * **作用**: 为 cloud-saves 插件提�� GitHub 仓库 URL,用于自动配置插件。
232
+ * **前置条件**: 需要同时安装 cloud-saves 插件(通过 `PLUGINS` 环境变量)。
233
+ * **格式示例**: `https://github.com/yourusername/yourrepo`
234
+ * **说明**: 这是你用来存储 SillyTavern 数据备份的 GitHub 仓库地址。
235
+
236
+ 6. `GITHUB_TOKEN`: **可选**。
237
+ * **作用**: 为 cloud-saves 插件提供 GitHub 访问令牌,用于自动配置插件。
238
+ * **前置条件**: 需要同时设置 `REPO_URL` 和安装 cloud-saves 插件。
239
+ * **格式示例**: `ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`
240
+ * **获取方式**: 在 GitHub Settings -> Developer settings -> Personal access tokens -> Tokens (classic) 中创建,需要 `repo` 权限。
241
+ * **自动配置**: 如果同时提供了 `REPO_URL` 和 `GITHUB_TOKEN`,且安装了 cloud-saves 插件,系统会自动创建插件的配置文件。
242
+
243
+ 7. `AUTOSAVE_INTERVAL`: **可选**。
244
+ * **作用**: 设置 cloud-saves 插件的自动保存间隔时间(秒)。
245
+ * **前置条件**: 需要同时设置 `REPO_URL` 和 `GITHUB_TOKEN`。
246
+ * **格式示例**: `30`(表示每30秒自动保存一次)
247
+ * **默认值**: 如果不设置,默认为 `30` 秒。
248
+
249
+ 8. `AUTOSAVE_TARGET_TAG`: **可选**。
250
+ * **作用**: 设置 cloud-saves 插件的自动保存目标标签。
251
+ * **前置条件**: 需要同时设置 `REPO_URL` 和 `GITHUB_TOKEN`。
252
+ * **格式示例**: `auto-backup` 或 `daily-save`
253
+ * **默认值**: 如果不设置,默认为空字符串。
254
+
255
+ ## 方法一:本地 Docker 部署
256
+
257
+ 你可以在本地使用 Docker 来构建和运行 SillyTavern。
258
+
259
+ 1. **构建镜像**: 在包含 `Dockerfile` 的目录下,运行:
260
+ ```bash
261
+ docker build -t sillytavern-local .
262
+ ```
263
+ 将 `sillytavern-local` 替换为你想要的镜像名称。
264
+
265
+ 2. **准备配置**: 将你的 `config.yaml` 内容(无注释)准备好。
266
+
267
+ 3. **运行容器**: 使用 `docker run` 命令,并通过 `-e` 参数传递环境变量。
268
+ * 将上方提供的**推荐配置内容**复制,并作为 `CONFIG_YAML` 环境变量的值。**确保你已经修改了其中的用户名和密码!**
269
+ * 如果你需要安装插件(**推荐安装 `cloud-saves`**),请准备好插件 URL 列表。
270
+
271
+ ```bash
272
+ # 示例:使用推荐配置并安装 cloud-saves 插件
273
+ # 1. 将推荐配置(修改密码后)保存到名为 config_no_comments.yaml 的文件中
274
+ # 2. 运行以下命令
275
+
276
+ docker run -p 8000:8000 --name my-sillytavern \\
277
+ -e CONFIG_YAML="$(cat config_no_comments.yaml)" \\
278
+ -e PLUGINS='https://github.com/fuwei99/cloud-saves.git' \\
279
+ -e EXTENSIONS='https://github.com/user1/extension1.git,https://github.com/user2/extension2.git' \\
280
+ -e INSTALL_FOR_ALL_USERS=false \\
281
+ -e REPO_URL='https://github.com/yourusername/yourrepo' \\
282
+ -e GITHUB_TOKEN='ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \\
283
+ -e AUTOSAVE_INTERVAL=30 \\
284
+ -e AUTOSAVE_TARGET_TAG=auto-backup \\
285
+ sillytavern-local
286
+
287
+ # 如果你需要安装更多插件,用逗号隔开添加到 PLUGINS 变量中
288
+ # 例如:
289
+ # docker run -p 8000:8000 --name my-sillytavern \
290
+ # -e CONFIG_YAML="$(cat config_no_comments.yaml)" \
291
+ # -e PLUGINS='https://github.com/fuwei99/cloud-saves.git,https://github.com/user/other-plugin.git' \
292
+ # -e EXTENSIONS='https://github.com/user1/extension1.git,https://github.com/user2/extension2.git' \
293
+ # -e INSTALL_FOR_ALL_USERS=false \
294
+ # -e REPO_URL='https://github.com/yourusername/yourrepo' \
295
+ # -e GITHUB_TOKEN='ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
296
+ # -e AUTOSAVE_INTERVAL=30 \
297
+ # -e AUTOSAVE_TARGET_TAG=auto-backup \
298
+ # sillytavern-local
299
+ ```
300
+ * `-p 8000:8000`: 将容器的 8000 端口映射到宿主机的 8000 端口。
301
+ * `--name my-sillytavern`: 为容器命名,方便管理。
302
+ * `-e CONFIG_YAML="$(cat config_no_comments.yaml)"`: 从文件读取配置内容并传递。这是处理多行 YAML 最可靠的方式。**再次确认:运行前务必修改 `config_no_comments.yaml` 文件中的用户名和密码!**
303
+ * `-e PLUGINS='...'`: 传递插件列表,这里以安装 `cloud-saves` 为例。
304
+ * `-e EXTENSIONS='...'`: 传递扩展列表,这里以安装 `extension1` 和 `extension2` 为例。
305
+ * `-e INSTALL_FOR_ALL_USERS=false`: 设置扩展安装模式为用户级安装。
306
+ * `-e REPO_URL='...'`: 传递 REPO_URL 环境变量。
307
+ * `-e GITHUB_TOKEN='...'`: 传递 GITHUB_TOKEN 环境变量。
308
+ * `-e AUTOSAVE_INTERVAL=30`: 设置 AUTOSAVE_INTERVAL 环境变量。
309
+ * `-e AUTOSAVE_TARGET_TAG=auto-backup`: 设置 AUTOSAVE_TARGET_TAG 环境变量。
310
+
311
+ 4. **访问**: 打开浏览器访问 `http://localhost:8000`。
312
+
313
+ ## 方法二:Hugging Face Spaces 部署
314
+
315
+ 这是推荐的在线部署方式,利用 Hugging Face 的免费计算资源和 Secrets 管理功能。
316
+
317
+ 1. **创建 Space**: 在 Hugging Face 上创��一个新的 Space,选择 **Docker** SDK。
318
+
319
+ 2. **上传文件**: 将本项目中的 `Dockerfile` 和 `README.md` 文件上传到你的 Space 仓库根目录。
320
+
321
+ 3. **配置 Secrets**: 进入你的 Space 页面的 **Settings -> Secrets** 部分。
322
+ * **添加 `CONFIG_YAML` Secret**:
323
+ * 点击 "New secret"。
324
+ * 名称 (Name) 输入: `CONFIG_YAML`
325
+ * 值 (Value) 粘贴: **复制上方提供的推荐配置内容**。**再次强调:粘贴前请务必修改 `basicAuthUser` 下的 `username` 和 `password` 为你自己的安全凭据!**
326
+ * 点击 "Add secret"。
327
+ * **(推荐) 添加 `PLUGINS` Secret**:
328
+ * 再次点击 "New secret"。
329
+ * 名称 (Name) 输入: `PLUGINS`
330
+ * 值 (Value) 粘贴: 推荐至少包含 `cloud-saves` 插件。例如:`https://github.com/fuwei99/cloud-saves.git`。如果你需要其他插件,用逗号隔开添加,例如:`https://github.com/fuwei99/cloud-saves.git,https://github.com/user/other-plugin.git`。
331
+ * **重要提醒**: 请确保你已经在本地 SillyTavern 安装了 `cloud-saves` 并至少进行了一次存档。
332
+ * 点击 "Add secret"。如果你确实不需要任何额外插件,可以跳过这一步。
333
+
334
+ * **(可选) 添加 `EXTENSIONS` Secret**:
335
+ * 再次点击 "New secret"。
336
+ * 名称 (Name) 输入: `EXTENSIONS`
337
+ * 值 (Value) 粘贴: 你需要安装的扩展 Git URL 列表,用逗号隔开。例如:`https://github.com/user1/extension1.git,https://github.com/user2/extension2.git`。
338
+ * 点击 "Add secret"。如果你不需要安装扩展,可以跳过这一步。
339
+
340
+ * **(可选) 添加 `INSTALL_FOR_ALL_USERS` Secret**:
341
+ * 如果你添加了 `EXTENSIONS` Secret,可以继续添加这个 Secret 来控制扩展安装模式。
342
+ * 再次点击 "New secret"。
343
+ * 名称 (Name) 输入: `INSTALL_FOR_ALL_USERS`
344
+ * 值 (Value) 输入: `true`(系统级安装,所有用户可用)或 `false`(用户级安装,仅默认用户可用)。
345
+ * **推荐**: 对于 Hugging Face Space 单用户环境,建议设置为 `false` 或不设置此 Secret。
346
+ * 点击 "Add secret"。如果不设置,默认为用户级安装。
347
+
348
+ * **(可选) 添加 `REPO_URL` Secret**:
349
+ * 再次点击 "New secret"。
350
+ * 名称 (Name) 输入: `REPO_URL`
351
+ * 值 (Value) 输入: 你的 GitHub 仓库地址,用于 cloud-saves 插件自动配置。例如:`https://github.com/yourusername/yourrepo`
352
+ * 点击 "Add secret"。
353
+
354
+ * **(可选) 添加 `GITHUB_TOKEN` Secret**:
355
+ * 再次点击 "New secret"。
356
+ * 名称 (Name) 输入: `GITHUB_TOKEN`
357
+ * 值 (Value) 输入: 你的 GitHub 访问令牌,用于 cloud-saves 插件自动配置。例如:`ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`
358
+ * 点击 "Add secret"。
359
+
360
+ * **(可选) 添加 `AUTOSAVE_INTERVAL` Secret**:
361
+ * 再次点击 "New secret"。
362
+ * 名称 (Name) 输入: `AUTOSAVE_INTERVAL`
363
+ * 值 (Value) 输入: 自动保存间隔秒数,不填写默认为30秒
364
+ * 点击 "Add secret"。
365
+
366
+ * **(可选) 添加 `AUTOSAVE_TARGET_TAG` Secret**:
367
+ * 再次点击 "New secret"。
368
+ * 名称 (Name) 输入: `AUTOSAVE_TARGET_TAG`
369
+ * 值 (Value) 输入: 自动保存目标标签,不填写默认为空
370
+ * 点击 "Add secret"。
371
+
372
+ 4. **构建与启动**: Hugging Face 会自动检测到 `Dockerfile` 和 Secrets,并开始构建镜像、启动容器。你可以在 Space 的 **Logs** 标签页查看构建和启动过程。
373
+
374
+ 5. **访问**: 构建成功并启动后,通过 Space 提供的公共 URL 访问 SillyTavern 界面。
375
+
376
+ ## 插件访问
377
+
378
+ 如果通过 `PLUGINS` 环境变量安装了插件,你需要根据各个插件的说明文档找到访问其界面的路径。
379
+
380
+ * 对于推荐安装的 `cloud-saves` 插件,其管理界面通常位于:
381
+ `http://<你的SillyTavern访问地址>/api/plugins/cloud-saves/ui`
382
+ 例如,如果是本地部署,则为 `http://127.0.0.1:8000/api/plugins/cloud-saves/ui`。如果是 Hugging Face Space,则将 `<你的SillyTavern访问地址>` 替换为你的 Space 公共 URL。
383
+
384
+ 其他插件的访问路径请参考其各自的文档。