colabllm 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- colabllm-0.1.0/CHANGELOG.md +16 -0
- colabllm-0.1.0/MANIFEST.in +15 -0
- colabllm-0.1.0/PKG-INFO +519 -0
- colabllm-0.1.0/README.md +505 -0
- colabllm-0.1.0/colabllm +9 -0
- colabllm-0.1.0/docs/comfyui.md +57 -0
- colabllm-0.1.0/docs/frp.md +132 -0
- colabllm-0.1.0/docs/indextts.md +92 -0
- colabllm-0.1.0/docs/longcat-avatar.md +69 -0
- colabllm-0.1.0/docs/longcat-video.md +56 -0
- colabllm-0.1.0/docs/nemotron-transcribe.md +88 -0
- colabllm-0.1.0/docs/ollama.md +55 -0
- colabllm-0.1.0/docs/qwen-flash.md +72 -0
- colabllm-0.1.0/docs/qwen3-tts.md +103 -0
- colabllm-0.1.0/docs/runtime-common.md +63 -0
- colabllm-0.1.0/docs/unlimited-ocr.md +78 -0
- colabllm-0.1.0/docs/unsloth-studio.md +53 -0
- colabllm-0.1.0/pyproject.toml +37 -0
- colabllm-0.1.0/setup.cfg +4 -0
- colabllm-0.1.0/skills/colabllm/SKILL.md +108 -0
- colabllm-0.1.0/skills/colabllm/references/comfyui.md +59 -0
- colabllm-0.1.0/skills/colabllm/references/indextts.md +94 -0
- colabllm-0.1.0/skills/colabllm/references/inference.md +7 -0
- colabllm-0.1.0/skills/colabllm/references/longcat-avatar.md +71 -0
- colabllm-0.1.0/skills/colabllm/references/longcat-video.md +58 -0
- colabllm-0.1.0/skills/colabllm/references/media.md +8 -0
- colabllm-0.1.0/skills/colabllm/references/nemotron-transcribe.md +90 -0
- colabllm-0.1.0/skills/colabllm/references/ocr.md +5 -0
- colabllm-0.1.0/skills/colabllm/references/ollama.md +57 -0
- colabllm-0.1.0/skills/colabllm/references/operations.md +66 -0
- colabllm-0.1.0/skills/colabllm/references/qwen-flash.md +74 -0
- colabllm-0.1.0/skills/colabllm/references/qwen3-tts.md +105 -0
- colabllm-0.1.0/skills/colabllm/references/runtime-common.md +65 -0
- colabllm-0.1.0/skills/colabllm/references/speech.md +7 -0
- colabllm-0.1.0/skills/colabllm/references/unlimited-ocr.md +80 -0
- colabllm-0.1.0/skills/colabllm/references/unsloth-studio.md +55 -0
- colabllm-0.1.0/src/colabllm/__init__.py +1 -0
- colabllm-0.1.0/src/colabllm/__main__.py +3 -0
- colabllm-0.1.0/src/colabllm/cli.py +77 -0
- colabllm-0.1.0/src/colabllm/control.py +52 -0
- colabllm-0.1.0/src/colabllm/lib/avatar_sampling.py +28 -0
- colabllm-0.1.0/src/colabllm/lib/cli_support.py +158 -0
- colabllm-0.1.0/src/colabllm/lib/colabsvc.py +930 -0
- colabllm-0.1.0/src/colabllm/lib/completion.py +128 -0
- colabllm-0.1.0/src/colabllm/lib/doctor.py +73 -0
- colabllm-0.1.0/src/colabllm/lib/frp_backend.py +164 -0
- colabllm-0.1.0/src/colabllm/lib/frp_server.py +580 -0
- colabllm-0.1.0/src/colabllm/lib/ocr_parameters.py +90 -0
- colabllm-0.1.0/src/colabllm/lib/paths.py +13 -0
- colabllm-0.1.0/src/colabllm/lib/processes.py +66 -0
- colabllm-0.1.0/src/colabllm/lib/protocol.py +42 -0
- colabllm-0.1.0/src/colabllm/lib/skill_bundle.py +40 -0
- colabllm-0.1.0/src/colabllm/services/comfyui.ipynb +70 -0
- colabllm-0.1.0/src/colabllm/services/comfyui.py +225 -0
- colabllm-0.1.0/src/colabllm/services/indextts.ipynb +70 -0
- colabllm-0.1.0/src/colabllm/services/indextts.py +477 -0
- colabllm-0.1.0/src/colabllm/services/longcat-avatar.ipynb +70 -0
- colabllm-0.1.0/src/colabllm/services/longcat-avatar.py +249 -0
- colabllm-0.1.0/src/colabllm/services/longcat-video.ipynb +70 -0
- colabllm-0.1.0/src/colabllm/services/longcat-video.py +26 -0
- colabllm-0.1.0/src/colabllm/services/nemotron-transcribe.ipynb +70 -0
- colabllm-0.1.0/src/colabllm/services/nemotron-transcribe.py +1627 -0
- colabllm-0.1.0/src/colabllm/services/ollama.ipynb +70 -0
- colabllm-0.1.0/src/colabllm/services/ollama.py +42 -0
- colabllm-0.1.0/src/colabllm/services/qwen-flash.ipynb +70 -0
- colabllm-0.1.0/src/colabllm/services/qwen-flash.py +55 -0
- colabllm-0.1.0/src/colabllm/services/qwen3-tts.ipynb +70 -0
- colabllm-0.1.0/src/colabllm/services/qwen3-tts.py +496 -0
- colabllm-0.1.0/src/colabllm/services/unlimited-ocr.ipynb +70 -0
- colabllm-0.1.0/src/colabllm/services/unlimited-ocr.py +262 -0
- colabllm-0.1.0/src/colabllm/services/unsloth-studio.ipynb +70 -0
- colabllm-0.1.0/src/colabllm/services/unsloth-studio.py +26 -0
- colabllm-0.1.0/src/colabllm/utility.py +59 -0
- colabllm-0.1.0/src/colabllm.egg-info/PKG-INFO +519 -0
- colabllm-0.1.0/src/colabllm.egg-info/SOURCES.txt +116 -0
- colabllm-0.1.0/src/colabllm.egg-info/dependency_links.txt +1 -0
- colabllm-0.1.0/src/colabllm.egg-info/entry_points.txt +2 -0
- colabllm-0.1.0/src/colabllm.egg-info/top_level.txt +1 -0
- colabllm-0.1.0/templates/build_notebooks.py +5860 -0
- colabllm-0.1.0/templates/colab_cache.py +130 -0
- colabllm-0.1.0/templates/longcat_avatar_app.py +435 -0
- colabllm-0.1.0/templates/longcat_avatar_drive.py +47 -0
- colabllm-0.1.0/templates/longcat_avatar_jobs.py +108 -0
- colabllm-0.1.0/templates/longcat_video_app.py +221 -0
- colabllm-0.1.0/templates/service.ipynb +70 -0
- colabllm-0.1.0/templates/service.py +25 -0
- colabllm-0.1.0/templates/tunnel_client.py +170 -0
- colabllm-0.1.0/templates/unlimited_ocr_app.py +483 -0
- colabllm-0.1.0/templates/unlimited_ocr_setup.py +41 -0
- colabllm-0.1.0/tests/test_avatar_sampling.py +38 -0
- colabllm-0.1.0/tests/test_cli_regressions.py +143 -0
- colabllm-0.1.0/tests/test_colab_cache.py +97 -0
- colabllm-0.1.0/tests/test_colabllm.py +49 -0
- colabllm-0.1.0/tests/test_completion.py +70 -0
- colabllm-0.1.0/tests/test_doctor.py +57 -0
- colabllm-0.1.0/tests/test_endpoint_binding.py +38 -0
- colabllm-0.1.0/tests/test_frp_backend.py +331 -0
- colabllm-0.1.0/tests/test_frp_transport.py +197 -0
- colabllm-0.1.0/tests/test_http_safety.py +78 -0
- colabllm-0.1.0/tests/test_lifecycle_safety.py +122 -0
- colabllm-0.1.0/tests/test_longcat_avatar_cli.py +149 -0
- colabllm-0.1.0/tests/test_longcat_avatar_drive.py +32 -0
- colabllm-0.1.0/tests/test_longcat_avatar_jobs.py +54 -0
- colabllm-0.1.0/tests/test_notebook_protocol.py +34 -0
- colabllm-0.1.0/tests/test_release.py +45 -0
- colabllm-0.1.0/tests/test_runner_lifecycle.py +152 -0
- colabllm-0.1.0/tests/test_runtime_docs.py +78 -0
- colabllm-0.1.0/tests/test_skill_bundle.py +44 -0
- colabllm-0.1.0/tests/test_timeouts.py +63 -0
- colabllm-0.1.0/tests/test_tunnel_config.py +127 -0
- colabllm-0.1.0/tests/test_unlimited_ocr.py +330 -0
- colabllm-0.1.0/tests/test_user_state.py +72 -0
- colabllm-0.1.0/tests_colab/test_longcat_attention.py +63 -0
- colabllm-0.1.0/tests_colab/test_longcat_avatar_attention.py +53 -0
- colabllm-0.1.0/tests_colab/test_longcat_avatar_duration.py +29 -0
- colabllm-0.1.0/tools/check_distribution.py +100 -0
- colabllm-0.1.0/tools/check_release.py +40 -0
- colabllm-0.1.0/tools/sync_runtime_docs.py +45 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
版本号以 `pyproject.toml` 为唯一来源,使用 `MAJOR.MINOR.PATCH`;Git 标签为 `vMAJOR.MINOR.PATCH`。
|
|
4
|
+
|
|
5
|
+
## [Unreleased]
|
|
6
|
+
|
|
7
|
+
## [0.1.0] - 2026-11-03
|
|
8
|
+
|
|
9
|
+
首次打包发布。
|
|
10
|
+
|
|
11
|
+
- 提供统一 `colabllm` CLI,通过 `uv tool` 安装和升级,本机无需模型计算依赖。
|
|
12
|
+
- 包含 10 个 Colab 运行时,支持推理、OCR、转写、语音合成、视频生成、ComfyUI 和 Unsloth Studio。
|
|
13
|
+
- 用户配置和状态统一放在 `~/.colabllm/`,支持多实例、Cloudflare Tunnel 和 FRP。
|
|
14
|
+
- 提供认证信息查询、诊断、命令补全、任务恢复及超时控制。
|
|
15
|
+
- 随包分发 Agent skill,提供全部运行时的独立使用指南和同步检查。
|
|
16
|
+
- GitHub Actions 验证 Linux/macOS 与 Python 3.12–3.14,并自动构建和发布 wheel、sdist。
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
include README.md
|
|
2
|
+
include CHANGELOG.md
|
|
3
|
+
include colabllm
|
|
4
|
+
recursive-include src/colabllm *.py *.ipynb
|
|
5
|
+
recursive-include templates *.py *.ipynb
|
|
6
|
+
recursive-include tests *.py
|
|
7
|
+
recursive-include tests_colab *.py
|
|
8
|
+
include tools/check_distribution.py
|
|
9
|
+
include tools/sync_runtime_docs.py
|
|
10
|
+
include tools/check_release.py
|
|
11
|
+
recursive-include docs *.md
|
|
12
|
+
global-exclude *.pyc
|
|
13
|
+
prune .state
|
|
14
|
+
prune .colabllm
|
|
15
|
+
recursive-include skills *.md
|
colabllm-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: colabllm
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Run model services on Google Colab with managed tunnels and authentication
|
|
5
|
+
Project-URL: Homepage, https://github.com/deluxebear/colabllm
|
|
6
|
+
Project-URL: Repository, https://github.com/deluxebear/colabllm
|
|
7
|
+
Project-URL: Issues, https://github.com/deluxebear/colabllm/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/deluxebear/colabllm/blob/master/CHANGELOG.md
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
11
|
+
Classifier: Operating System :: MacOS
|
|
12
|
+
Requires-Python: >=3.12
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# Google Colab 大模型服务
|
|
16
|
+
|
|
17
|
+
在 Google Colab GPU 上运行大模型服务,通过 Cloudflare Tunnel(默认)或 FRP + Caddy 提供公网访问。
|
|
18
|
+
遵循 **“一个服务 = 一个 notebook (`src/colabllm/services/<name>.ipynb`) + 一个执行脚本 (`src/colabllm/services/<name>.py`)”** 的约定。
|
|
19
|
+
|
|
20
|
+
## 统一命令入口
|
|
21
|
+
|
|
22
|
+
用户通过分发包安装,无需克隆源码。从 [GitHub Releases](https://github.com/deluxebear/colabllm/releases) 下载 wheel 后安装(私有仓库需要相应访问权限):
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
uv tool install ./colabllm-0.1.0-py3-none-any.whl
|
|
26
|
+
# 如果命令目录尚未加入 PATH
|
|
27
|
+
uv tool update-shell
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
版本发布到 PyPI 后,也可以直接安装和升级:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
uv tool install colabllm
|
|
34
|
+
uv tool upgrade colabllm
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
之后可以在任意目录使用 `colabllm <运行时名称> <命令> [参数...]`:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
colabllm services # 列出全部运行时
|
|
41
|
+
colabllm unlimited-ocr up # 默认 A100
|
|
42
|
+
colabllm unlimited-ocr ocr ./documents -O ./results
|
|
43
|
+
colabllm unlimited-ocr resume JOB_ID --wait
|
|
44
|
+
colabllm qwen3-tts up -i 2
|
|
45
|
+
colabllm comfyui up
|
|
46
|
+
colabllm ollama up --dry-run
|
|
47
|
+
colabllm unlimited-ocr --help
|
|
48
|
+
|
|
49
|
+
# 项目级配置也使用同一入口
|
|
50
|
+
colabllm tunnel-config
|
|
51
|
+
colabllm frp-config --help
|
|
52
|
+
colabllm frp-status
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
所有运行脚本和 notebook 都包含在安装包中。本地相对输入/输出路径按调用时所在目录解析。
|
|
56
|
+
本项目的配置和运行状态统一写入 `~/.colabllm/`,不读取仓库旧 `.state/`,不提供旧配置迁移。
|
|
57
|
+
可设置 `COLABLLM_HOME=/absolute/path` 使用独立目录。
|
|
58
|
+
|
|
59
|
+
```text
|
|
60
|
+
~/.colabllm/
|
|
61
|
+
├── tunnel-config.json # 全局主域名与 FRP 设置
|
|
62
|
+
├── services/<name>/state.json # 实例凭据、会话、隧道与 runner PID
|
|
63
|
+
├── services/<name>/run.log # 日志;执行用 notebook 也在实例目录
|
|
64
|
+
└── frp/<server-id>.json # FRP 私密凭据
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`colab`、`cf` 和 `ssh` 的授权/配置仍由各自工具管理;Google Drive 数据仍保存在远端。
|
|
68
|
+
卸载使用 `uv tool uninstall colabllm`,用户配置目录保留。
|
|
69
|
+
升级前先停止运行中的服务,升级后重新启动,避免后台 runner 依赖的安装文件被替换。
|
|
70
|
+
|
|
71
|
+
## 运行时使用指南
|
|
72
|
+
|
|
73
|
+
每个运行时的具体命令、API/UI 工作流、输入输出及恢复语义见下方“各运行时使用文档”表。
|
|
74
|
+
共享规则集中在 [运行时通用操作](docs/runtime-common.md),可先阅读以理解认证、Drive 路径、超时和多实例。
|
|
75
|
+
`docs/<运行时>.md` 是用法说明的维护来源,用户技能内的对应参考由同步工具生成:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
python tools/sync_runtime_docs.py
|
|
79
|
+
python tools/sync_runtime_docs.py --check
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
修改用法或新增运行时后需同步;本地测试及 CI 会检查指南完整性、示例参数和技能内容一致。
|
|
83
|
+
|
|
84
|
+
## 安装 Agent Skill
|
|
85
|
+
|
|
86
|
+
根目录 [skills/colabllm](skills/colabllm/SKILL.md) 提供面向使用者的独立技能,覆盖本项目所有运行时。
|
|
87
|
+
它包含按任务加载的 OCR、语音、推理、媒体和排错参考,不依赖源码仓库或个人部署配置。
|
|
88
|
+
|
|
89
|
+
wheel 和源码包均包含完整技能,安装 CLI 后即可导出:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# 查看主技能说明
|
|
93
|
+
colabllm skill
|
|
94
|
+
|
|
95
|
+
# Codex:将完整 colabllm/ 技能目录导出到个人技能目录
|
|
96
|
+
colabllm skill --output "${CODEX_HOME:-$HOME/.codex}/skills"
|
|
97
|
+
|
|
98
|
+
# 支持 ~/.agents/skills 的 Agent
|
|
99
|
+
colabllm skill --output ~/.agents/skills
|
|
100
|
+
|
|
101
|
+
# 其他 Agent:指定其实际技能目录
|
|
102
|
+
colabllm skill --output /path/to/agent/skills
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
`--output` 是技能父目录,实际生成 `<目录>/colabllm/SKILL.md` 和 `references/`。
|
|
106
|
+
目标已存在时返回错误,不覆盖用户修改。更新时先导出到新目录,比较后替换;CLI 升级不会自动覆盖已安装的技能。
|
|
107
|
+
也可以直接从源码复制整个 `skills/colabllm/` 目录。安装后按 Agent 的方式重新加载技能或开启新会话,
|
|
108
|
+
再请求“使用 colabllm 将本地 PDF 转为 Markdown”等任务。
|
|
109
|
+
|
|
110
|
+
仓库内 `.agents/skills/colab-llm-service/` 是维护者技能;分发给使用者的是 `skills/colabllm/`。
|
|
111
|
+
|
|
112
|
+
## 开发、构建与发布
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# 开发安装:修改源码立即生效,源码目录需要保留
|
|
116
|
+
uv tool install --editable .
|
|
117
|
+
|
|
118
|
+
# 普通本地安装 / 更新
|
|
119
|
+
uv tool install --force .
|
|
120
|
+
|
|
121
|
+
# 构建 wheel 和源码分发包(dist/)
|
|
122
|
+
uv build --no-sources
|
|
123
|
+
|
|
124
|
+
# 验证 wheel 在隔离环境中的安装与运行
|
|
125
|
+
python tools/check_distribution.py dist/colabllm-0.1.0-py3-none-any.whl
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
版本号以 `pyproject.toml` 为唯一来源,CLI 从已安装包元数据读取版本。
|
|
129
|
+
采用 `MAJOR.MINOR.PATCH`:修复递增 PATCH、新功能递增 MINOR、不兼容变更递增 MAJOR;
|
|
130
|
+
在 `0.x` 开发阶段,不兼容变更递增 MINOR,并在 [CHANGELOG.md](CHANGELOG.md) 中说明。
|
|
131
|
+
当前首发版本为 `0.1.0`,对应 Git 标签 `v0.1.0`;后续发布示例:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
uv version --bump patch
|
|
135
|
+
# 将 CHANGELOG.md 的 Unreleased 内容整理到本次版本的日期条目
|
|
136
|
+
python tools/check_release.py --tag v0.1.1
|
|
137
|
+
git add pyproject.toml CHANGELOG.md
|
|
138
|
+
git commit -m "chore: release 0.1.1"
|
|
139
|
+
git tag -a v0.1.1 -m "Release 0.1.1"
|
|
140
|
+
git push origin master
|
|
141
|
+
git push origin v0.1.1
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
推送 `v*` 标签触发 [release.yml](.github/workflows/release.yml):
|
|
145
|
+
|
|
146
|
+
1. 验证标签、包版本和变更记录一致,复用 Linux/macOS × Python 3.12–3.14 CI。
|
|
147
|
+
2. 构建 wheel 和 sdist,验证隔离安装,生成 SHA256SUMS 并保存 Actions artifact。
|
|
148
|
+
3. 发布 GitHub Release,附带安装包及校验文件,发布说明取自当前版本的 CHANGELOG 条目。
|
|
149
|
+
4. 将同一组已验证的包通过 Trusted Publishing 上传 PyPI。
|
|
150
|
+
|
|
151
|
+
首次启用 PyPI 需要项目所有者在 [PyPI Publishing](https://pypi.org/manage/account/publishing/)
|
|
152
|
+
添加 Pending Publisher:项目 `colabllm`、Owner `deluxebear`、Repository `colabllm`、
|
|
153
|
+
Workflow `release.yml`、Environment `pypi`。已有 PyPI 项目则在项目 Publishing 设置添加同样的发布者。
|
|
154
|
+
Actions 使用 `pypi` environment 和 OIDC,无需配置长期 PyPI API Token。
|
|
155
|
+
参考 [PyPI Trusted Publisher 说明](https://docs.pypi.org/trusted-publishers/creating-a-project-through-oidc/)。
|
|
156
|
+
|
|
157
|
+
PyPI 上传失败时,GitHub Release 仍可下载;修复身份配置后在 Actions 选择 **Re-run failed jobs**。
|
|
158
|
+
也可以针对已有标签手动运行 release workflow;已发布的 GitHub Release 会拒绝被覆盖,应优先只重跑失败任务。
|
|
159
|
+
已发布版本不移动标签或替换安装包,修复后发布新版本。
|
|
160
|
+
通过本地 wheel 安装的用户可安装新 wheel 更新;通过 PyPI 安装的用户使用 `uv tool upgrade colabllm`。
|
|
161
|
+
|
|
162
|
+
## CLI 行为约定
|
|
163
|
+
|
|
164
|
+
- `colabllm <服务> --help` 列出生命周期和服务专用命令;`colabllm help <服务> <命令>` 查看详细帮助。
|
|
165
|
+
- `-i/--instance` 可放在服务参数的任意位置,`--` 之后按字面解析;实例 ID 必须为 1–64 位字母、数字、下划线或连字符,且不能以连字符开头。
|
|
166
|
+
- 普通结果写入 stdout,进度和告警写入 stderr;`--json` 的 stdout 只包含 JSON。
|
|
167
|
+
- `info`、`ps`、`list`、`status` 支持 `--json`,默认隐藏凭据;需要时显式加 `--show-secrets`。
|
|
168
|
+
- `--quiet` 抑制诊断进度,错误仍然显示;`--no-color` 或 `NO_COLOR` 关闭诊断颜色。非终端输出自动关闭诊断颜色。
|
|
169
|
+
- 常见网络、文件和配置错误默认给出简洁提示;`--debug` 显示异常堆栈。
|
|
170
|
+
- 成功退出码为 0;操作失败为非零,参数用法错误为 2;外部 Colab 命令失败时保留其正退出码;Ctrl+C 为 130。
|
|
171
|
+
- 就绪标记只接受完整的 `CT_READY` 协议行;日志中的普通文字提及不会被视为就绪。
|
|
172
|
+
- `up` 默认等待 `CT_READY`;等待超时返回失败,但后台 runner 保留。`up --detach` 仅启动后台 runner,立即返回;`up --foreground` 在当前终端保持连接。
|
|
173
|
+
- 同一实例的启动和停止互斥;状态事务使用文件锁和原子替换。前台/后台 runner 都记录进程启动身份,停止前校验身份并等待退出。
|
|
174
|
+
- `down` 先确认远端停止成功,再停止本地连接并清理运行状态;远端停止失败时保留连接和追踪信息,便于重试。
|
|
175
|
+
- 携带认证信息的 HTTP 请求拒绝跨来源重定向。`--url` 或服务 URL 环境变量切换来源时,需要显式提供 Token,不能自动借用原服务的凭据。来源按协议、主机和有效端口比较。
|
|
176
|
+
|
|
177
|
+
## 超时与环境诊断
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
# 外部命令上限:可放在服务名前后,也可设置 COLABLLM_COMMAND_TIMEOUT
|
|
181
|
+
colabllm --command-timeout 60 ollama status
|
|
182
|
+
|
|
183
|
+
# 默认模式超时只停止等待,后台 runner 保留;前台模式超时会断开本地连接
|
|
184
|
+
colabllm ollama up --ready-timeout 600
|
|
185
|
+
colabllm ollama up --foreground --ready-timeout 600
|
|
186
|
+
|
|
187
|
+
# 轮询等待上限:0 保留不限时行为;每次请求也会受剩余时间约束
|
|
188
|
+
colabllm unlimited-ocr job JOB_ID --wait --timeout 300
|
|
189
|
+
colabllm comfyui pull-workflow TEMPLATE --timeout 300 --poll 2
|
|
190
|
+
colabllm longcat-avatar job JOB_ID --wait --timeout 300
|
|
191
|
+
|
|
192
|
+
# 默认只检查本机依赖、Drive 扩展、授权文件存在性和用户配置
|
|
193
|
+
colabllm doctor
|
|
194
|
+
colabllm doctor --json --transport quick --no-drive
|
|
195
|
+
|
|
196
|
+
# 额外验证 Colab、Cloudflare、SSH 授权,按选中的后端执行限时只读检查
|
|
197
|
+
colabllm doctor --online --timeout 10
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
超时退出码为 `124`。长驻的 `colab exec` 保活连接不受通用外部命令上限影响。
|
|
201
|
+
未指定 `--command-timeout` 时,共享外部命令默认 300 秒,个别下载或 SSH 操作保留专属默认上限。
|
|
202
|
+
`doctor` 不创建 GPU 会话、不挂载 Drive、不修改隧道,也不显示凭据或外部命令的原始输出。
|
|
203
|
+
离线检查不会证明授权仍有效;需要时使用 `--online`,该模式禁用浏览器交互并限制每项检查时间。
|
|
204
|
+
|
|
205
|
+
## Shell 补全
|
|
206
|
+
|
|
207
|
+
命令、选项和枚举值来自实际解析器;实例 ID 从 `~/.colabllm/services/` 的目录名读取,补全过程不读取凭据、不联网。
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
# Bash:在当前 Shell 加载
|
|
211
|
+
source <(colabllm completion bash)
|
|
212
|
+
|
|
213
|
+
# Zsh:先启用补全系统,再加载
|
|
214
|
+
# autoload -Uz compinit && compinit
|
|
215
|
+
source <(colabllm completion zsh)
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Fish 中执行 `colabllm completion fish | source`。需要持久启用时,将相应加载命令加入自己的 Shell 初始化文件,
|
|
219
|
+
或将脚本保存在 `~/.colabllm/completions/` 后从初始化文件加载。
|
|
220
|
+
|
|
221
|
+
## 测试
|
|
222
|
+
|
|
223
|
+
本地 CLI 与控制逻辑使用 Python 标准库,默认测试无需 Torch、NumPy 或 GPU:
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
python -m unittest discover -s tests
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
`tests_colab/` 单独保存 Colab 端模型代码的回归测试(如 LongCat attention 和音频分段)。
|
|
230
|
+
它们会导入模型运行代码,仅在对应的 Colab 服务环境中运行;attention 测试还需要 CUDA 和上游 LongCat 源码。
|
|
231
|
+
在该环境中,将项目源码放入 VM 后执行:
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
PYTHONPATH=/content/longcat-video/repo python -m unittest discover -s tests_colab
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
GitHub Actions 在 Linux/macOS、Python 3.12/3.13/3.14 上运行本地测试、三种 Shell 补全测试、构建和隔离 wheel 安装验证。工作流不执行模型测试、不启动 Colab、不自动发布包。
|
|
238
|
+
|
|
239
|
+
本地缺少 Zsh/Fish 时跳过对应 Shell 集成测试;CI 会安装这些 Shell。
|
|
240
|
+
本地测试中的真实 FRP 集成测试需额外指定 `COLABSVC_FRP_TEST_BIN`,默认跳过。
|
|
241
|
+
|
|
242
|
+
## 架构与职责
|
|
243
|
+
|
|
244
|
+
| 阶段 / 职责 | 执行位置 | 说明 |
|
|
245
|
+
| --- | --- | --- |
|
|
246
|
+
| 创建/复用 Colab 会话 (`colab new`) | 本地脚本 `src/colabllm/services/<name>.py` | 会话名与服务名一致 |
|
|
247
|
+
| 免浏览器挂载网盘 (`colab dfs mount`) | 本地脚本 `src/colabllm/services/<name>.py` | 挂载到 `/content/drive`;自动跳过 notebook 里的 `drive.mount()` |
|
|
248
|
+
| Cloudflare 固定域名 | 本地脚本 (`cf` CLI) | 创建/复用 named tunnel、配置 ingress 和 DNS CNAME;未配置主域名时使用动态 URL |
|
|
249
|
+
| FRP 固定域名 | 本地脚本 (`ssh` + `cf` CLI) | SSH 安装或复用服务端 frps/Caddy,通过 Cloudflare DNS 将域名指向服务器 IP |
|
|
250
|
+
| 密钥生成与注入 | 本地脚本 -> `--env` | 自动生成账号密码与 Bearer Token,保存在 `~/.colabllm/services/<name>/state.json` (0600) |
|
|
251
|
+
| 安装与启动服务 | 远端 `src/colabllm/services/<name>.ipynb` | 幂等安装,服务仅监听 `127.0.0.1` |
|
|
252
|
+
| 安全认证层 (Caddy) | 远端 `src/colabllm/services/<name>.ipynb` | 对无自带认证的服务(如 Ollama)前置 Caddy:浏览器走 Basic Auth,API 走 `Authorization: Bearer <token>` |
|
|
253
|
+
| 启动 `cloudflared` / `frpc` 与保活 | 远端 `src/colabllm/services/<name>.ipynb` | 最后一个 cell 持续阻塞并监控子进程;本地后台进程保持 `colab exec` 连接以防 Colab 回收会话 |
|
|
254
|
+
|
|
255
|
+
## 各运行时使用文档
|
|
256
|
+
|
|
257
|
+
| 服务名称 | 默认 GPU | 认证方式 | 固定域名示例(主域名配置为 `443998.xyz`) | 详细使用说明 |
|
|
258
|
+
| --- | --- | --- | --- | --- |
|
|
259
|
+
| **NVIDIA-Nemotron-3.5-Transcribe-30B-A4B** | `G4` | `vLLM` Bearer API Key (`builtin`) | `https://transcribe.443998.xyz` | [docs/nemotron-transcribe.md](docs/nemotron-transcribe.md) |
|
|
260
|
+
| **Qwen3-TTS** | `L4` | Bearer API Key (`builtin`) | `https://qwen3-tts.443998.xyz` | [docs/qwen3-tts.md](docs/qwen3-tts.md) |
|
|
261
|
+
| **IndexTTS-2.5** | `L4` | Bearer API Key (`builtin`) | `https://indextts.443998.xyz` | [docs/indextts.md](docs/indextts.md) |
|
|
262
|
+
| **Unlimited-OCR 2** | `A100` | Caddy (Basic Auth + Bearer) | `https://unlimited-ocr.443998.xyz` | [docs/unlimited-ocr.md](docs/unlimited-ocr.md) |
|
|
263
|
+
| **LongCat-Video-Avatar 1.5** | `G4` | Caddy (Basic Auth + Bearer) | `https://longcat-avatar.443998.xyz` | [docs/longcat-avatar.md](docs/longcat-avatar.md) |
|
|
264
|
+
| **LongCat-Video** | `G4` | Caddy (Basic Auth + Bearer) | `https://longcat-video.443998.xyz` | [docs/longcat-video.md](docs/longcat-video.md) |
|
|
265
|
+
| **ComfyUI + ComfyUI-Manager** | `L4` | Caddy (Basic Auth + Bearer) | `https://comfyui.443998.xyz` | [docs/comfyui.md](docs/comfyui.md) |
|
|
266
|
+
| **Qwen3.8-Flash-Next (800K + Vision)** | `G4` | `llama-server` Bearer API Key | `https://qwen.443998.xyz` | [docs/qwen-flash.md](docs/qwen-flash.md) |
|
|
267
|
+
| **Ollama** | `T4` | Caddy (Basic Auth + Bearer) | `https://ollama.443998.xyz` | [docs/ollama.md](docs/ollama.md) |
|
|
268
|
+
| **Unsloth Studio** | `L4` | 内置 Web 登录 (`builtin`) | `https://unsloth-studio.443998.xyz` | [docs/unsloth-studio.md](docs/unsloth-studio.md) |
|
|
269
|
+
|
|
270
|
+
## 目录结构
|
|
271
|
+
|
|
272
|
+
```text
|
|
273
|
+
pyproject.toml # 包元数据、版本、colabllm 命令入口
|
|
274
|
+
src/colabllm/
|
|
275
|
+
├── cli.py # 统一命令分发
|
|
276
|
+
├── control.py # 全局域名与 FRP 管理
|
|
277
|
+
├── lib/ # 本地共享 runner、状态与 FRP 实现
|
|
278
|
+
└── services/ # <name>.py + <name>.ipynb;随包安装
|
|
279
|
+
templates/ # 开发用 notebook 生成器与模板
|
|
280
|
+
tests/ # 本地测试(Python 标准库)
|
|
281
|
+
tests_colab/ # 仅在 Colab 模型环境运行的回归测试
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
## 本地环境与前置准备
|
|
285
|
+
|
|
286
|
+
本机负责创建 Colab 会话、配置隧道、挂载网盘和维持后台连接;模型在远端运行,**本机无需 GPU、CUDA、PyTorch 或模型权重**。
|
|
287
|
+
|
|
288
|
+
### 必需与可选依赖
|
|
289
|
+
|
|
290
|
+
| 本机环境 / 工具 | 何时需要 | 说明 |
|
|
291
|
+
| --- | --- | --- |
|
|
292
|
+
| Linux 或 macOS | 必需 | Colab CLI 当前支持的平台;本项目后台进程管理也使用 Unix 进程组 |
|
|
293
|
+
| Python 3.12+ | 必需 | 执行 `src/colabllm/services/*.py`、`src/colabllm/control.py`,满足 `google-colab-cli` 的 Python 要求 |
|
|
294
|
+
| `uv` | 包安装与升级 | 隔离安装 colabllm 和 Colab CLI;Git 仅开发时需要 |
|
|
295
|
+
| `colab` CLI | 必需 | PyPI 包 `google-colab-cli`,用于会话、文件操作及执行 Notebook |
|
|
296
|
+
| `colab dfs` 扩展 | 默认网盘流程必需 | [colab-dfs-ext](https://github.com/deluxebear/colab-dfs-ext),提供 `consent`、`mount`、`doctor`;需单独安装 |
|
|
297
|
+
| Node.js、npm、Cloudflare `cf` CLI | 固定域名或 FRP 模式 | 本机调用 Cloudflare API 管理 DNS;Cloudflare named tunnel 也由它配置。Quick Tunnel 不需要它 |
|
|
298
|
+
| OpenSSH 客户端 `ssh` | FRP 模式;或 Colab SSH 排错 | 用于连接 FRP 服务器,复用 `~/.ssh/config` 的密钥、端口和跳板配置 |
|
|
299
|
+
|
|
300
|
+
准备可使用所需 GPU 运行时的 Google/Colab 账号,以及有可用空间的 Google Drive。GPU 配额、计算单元余额和机型可用性以账号当前状态为准。首次 Google、Drive 和 Cloudflare 授权需要浏览器完成。
|
|
301
|
+
|
|
302
|
+
### 1. 安装 Colab CLI
|
|
303
|
+
|
|
304
|
+
先按 [uv 官方说明](https://docs.astral.sh/uv/getting-started/installation/) 安装 `uv`,并准备 Python 3.12+。使用独立工具环境安装:
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
uv tool install google-colab-cli
|
|
308
|
+
uv tool update-shell
|
|
309
|
+
# 重新打开终端,或按 update-shell 的提示加载 PATH
|
|
310
|
+
colab version
|
|
311
|
+
colab --help
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
安装来源:[google-colab-cli](https://github.com/googlecolab/google-colab-cli)。首次运行 `colab sessions` 时,按 CLI 的提示完成 Google 认证;需要自行提供 OAuth 客户端配置的环境,应按上游说明放在默认的 `~/.colab-cli-oauth-config.json`。本项目后台调用 `colab`,因此应先在同一用户环境中完成授权。
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
colab sessions # 确认可访问 Colab;不创建新 VM
|
|
318
|
+
colab usage # 查看账号计算单元用量/余额
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### 2. 安装并授权 `colab dfs` 扩展
|
|
322
|
+
|
|
323
|
+
本项目启动时默认调用 `colab dfs mount`,不依赖 Notebook 内交互式的 `drive.mount()`。扩展来自 [deluxebear/colab-dfs-ext](https://github.com/deluxebear/colab-dfs-ext),需在安装 Colab CLI 后单独安装:
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
curl -fsSL https://raw.githubusercontent.com/deluxebear/colab-dfs-ext/main/install.sh | sh
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
也可以克隆扩展仓库后运行 `python3 install.py`。安装器将源码保存到 `~/.colab-dfs-ext/`,并自动接入提供 `colab` 命令的 Python 环境;详细选项见[扩展中文说明](https://github.com/deluxebear/colab-dfs-ext/blob/main/README.zh-CN.md)。安装后检查并进行一次性 Drive 授权:
|
|
330
|
+
|
|
331
|
+
```bash
|
|
332
|
+
colab dfs --help
|
|
333
|
+
colab dfs version
|
|
334
|
+
colab dfs doctor
|
|
335
|
+
colab dfs consent # 浏览器完成一次授权,后续挂载无需再次交互
|
|
336
|
+
colab dfs show # 查看授权摘要,不打印 refresh token
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
Drive 授权与 Colab 会话认证分别进行。扩展凭据保存在 `~/.config/colab-cli/dfs_credentials.json`。正常使用时,服务脚本自动挂载远端 `/content/drive`,无需手工调用 `mount`;已有空闲会话可用 `colab dfs mount -s <会话名>` 验证。
|
|
340
|
+
|
|
341
|
+
升级 Colab CLI 后,可执行 `colab dfs --help` 检查扩展是否仍在;命令可用时可运行 `colab dfs install` 重新接入。若出现 `No such command: dfs`,且扩展仍在 `~/.colab-dfs-ext/`,可重新运行安装器修复:
|
|
342
|
+
|
|
343
|
+
```bash
|
|
344
|
+
python3 "$HOME/.colab-dfs-ext/install.py"
|
|
345
|
+
colab dfs --help
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
若扩展目录缺失,重新运行上面的安装命令。`up --no-drive` 可跳过自动挂载,但需要网盘音色、任务持久化和输出保存的功能仍依赖 Drive,不适合作为这些功能的替代配置。
|
|
349
|
+
|
|
350
|
+
### 3. 安装 Cloudflare `cf` CLI
|
|
351
|
+
|
|
352
|
+
使用固定域名时,无论选择 Cloudflare Tunnel 还是 FRP,都需要在**本机**安装并授权 `cf`。这里的 `cf` 是 Cloudflare CLI,不是 Cloud Foundry CLI,也不是远端运行的 `cloudflared`。
|
|
353
|
+
|
|
354
|
+
准备符合所安装 `cf` 版本要求的 Node.js/npm,然后安装:
|
|
355
|
+
|
|
356
|
+
```bash
|
|
357
|
+
node --version
|
|
358
|
+
npm --version
|
|
359
|
+
npm install --global cf
|
|
360
|
+
cf --version
|
|
361
|
+
cf auth login
|
|
362
|
+
cf auth whoami
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
安装和认证说明见 [Cloudflare 官方文档](https://developers.cloudflare.com/cf/get-started/)。账号需有目标域名的 Zone/DNS 管理权限;使用 named tunnel 时还需有隧道管理权限。`cf zones list` 可检查域名是否在当前账号中。只使用 Cloudflare 动态 URL 时,可跳过本节。
|
|
366
|
+
|
|
367
|
+
本机已验证的组合为 `google-colab-cli 0.7.5`、`colab dfs 0.1.0`、`cf 1.0.0-beta.26` 和 Node.js `26.13.0`。其中该 `cf` 版本的 Node.js 要求为 `^22.23.0 || ^24.22.0 || ^26.12.0`;升级版本时以 npm 包的 `engines` 声明为准,避免仅按大版本判断兼容性。
|
|
368
|
+
|
|
369
|
+
### 4. FRP 模式额外要求
|
|
370
|
+
|
|
371
|
+
本机需要 OpenSSH,以及能够非交互连接服务器的密钥配置:
|
|
372
|
+
|
|
373
|
+
```bash
|
|
374
|
+
ssh -V
|
|
375
|
+
ssh -o BatchMode=yes root@frpip 'id -u'
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
`root@frpip` 是示例,替换为实际 SSH 目标;首次连接应先核实服务器主机指纹。服务器需要 Linux、systemd、Python 3,以及 root 或免密 sudo;读取既有 FRP TOML 配置需要服务器 Python 3.11+。服务端需允许公网 TCP 7000、80 和 443。配置命令会安装或复用服务器上的 frps/Caddy,本机不需要预先安装它们,详见 [FRP 操作说明](docs/frp.md)。
|
|
379
|
+
|
|
380
|
+
### 启动前自检
|
|
381
|
+
|
|
382
|
+
在项目根目录、实际用于运行服务的终端中执行:
|
|
383
|
+
|
|
384
|
+
```bash
|
|
385
|
+
python3 --version
|
|
386
|
+
command -v colab
|
|
387
|
+
colab version
|
|
388
|
+
colab dfs --help
|
|
389
|
+
colab dfs show
|
|
390
|
+
colabllm tunnel-config
|
|
391
|
+
# 固定域名 / FRP 模式还需检查
|
|
392
|
+
command -v cf
|
|
393
|
+
cf --version
|
|
394
|
+
cf auth whoami
|
|
395
|
+
# FRP 模式还需检查
|
|
396
|
+
ssh -V
|
|
397
|
+
colabllm frp-status
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
认证文件保存在本机用户目录,运行时状态保存在用户目录 `~/.colabllm/services/`。执行脚本的本机需要持续在线且避免休眠:后台 runner 维持 `colab exec` 连接,断开可能导致 Colab 会话被回收。远端所需模型依赖、`cloudflared`/`frpc` 和认证 Caddy 由 Notebook 安装,不需要在本机重复安装。
|
|
401
|
+
|
|
402
|
+
## Cloudflare Tunnel 配置
|
|
403
|
+
|
|
404
|
+
通过 `colabllm tunnel-config` 统一配置;所有现有及新增运行时、所有实例均读取同一份主域名配置,保存在本机 `~/.colabllm/tunnel-config.json`。未启用 FRP 且配置为空时,`up`(包括不带 HOST 的 `up --domain`)使用 Cloudflare Quick Tunnel 的随机 `https://*.trycloudflare.com` URL,无需 `cf` 登录;每次启动 URL 可能变化。代码中的历史 `443998.xyz` 后缀不再自动启用。
|
|
405
|
+
|
|
406
|
+
```bash
|
|
407
|
+
# 查看 / 设置 / 清除全局主域名(项目根目录统一入口)
|
|
408
|
+
colabllm tunnel-config
|
|
409
|
+
colabllm tunnel-config --base-domain example.com
|
|
410
|
+
colabllm tunnel-config --clear
|
|
411
|
+
|
|
412
|
+
# 只为本次启动指定主域名,不写入配置
|
|
413
|
+
colabllm longcat-avatar up --base-domain example.com
|
|
414
|
+
# -> https://longcat-avatar.example.com
|
|
415
|
+
colabllm qwen-flash up -i 2 --base-domain example.com
|
|
416
|
+
# -> https://qwen-2.example.com(保留服务别名与实例后缀)
|
|
417
|
+
|
|
418
|
+
# 已配置主域名后:up 自动使用固定域名;也可以强制动态 URL
|
|
419
|
+
colabllm longcat-avatar up
|
|
420
|
+
colabllm longcat-avatar up --quick-tunnel
|
|
421
|
+
|
|
422
|
+
# 完整域名覆盖自动生成的服务域名
|
|
423
|
+
colabllm longcat-avatar up --domain avatar.example.com
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
可设置环境变量 `COLABSVC_BASE_DOMAIN=example.com`。选择顺序:`--quick-tunnel` 强制动态;完整 `--domain HOST` > `--base-domain` > 环境变量 > 全局配置 > 动态 URL。三个启动选项互斥。域名只填 DNS 名称,不包含 `https://`、端口或路径。
|
|
427
|
+
|
|
428
|
+
Cloudflare 固定域名要求 `cf auth login` 且账户有该域名的 DNS Zone 权限,启动时自动创建/复用 named tunnel、设置 ingress 和 DNS CNAME。配置修改仅影响之后的启动,不会重启运行中的服务;已有服务需自行择机重启。切换动态模式不会删除旧隧道和 DNS,可使用 `down --delete-tunnel` 显式清理。
|
|
429
|
+
|
|
430
|
+
## FRP 后端(项目全局)
|
|
431
|
+
|
|
432
|
+
默认使用 Cloudflare Tunnel;全局配置 FRP 后,所有运行时的新启动自动使用 FRP + 服务端 Caddy HTTPS。
|
|
433
|
+
|
|
434
|
+
```bash
|
|
435
|
+
# 配置并通过 SSH 自动安装服务端(替换示例 IP、SSH 目标和域名)
|
|
436
|
+
colabllm frp-config --server-ip 203.0.113.10 --ssh root@frpip --base-domain example.com
|
|
437
|
+
colabllm frp-status
|
|
438
|
+
colabllm indextts up
|
|
439
|
+
|
|
440
|
+
# 本次覆盖 / 关闭全局 FRP
|
|
441
|
+
colabllm indextts up --transport cloudflare
|
|
442
|
+
colabllm indextts up --quick-tunnel
|
|
443
|
+
colabllm frp-config --disable
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
FRP 服务端默认 TCP 7000,Caddy 使用 80/443;DNS 经本机 `cf` 自动配置为 DNS only。配置、自动安装、认证及清理说明见 [FRP 操作说明](docs/frp.md)。现有运行时不会自动切换。
|
|
447
|
+
|
|
448
|
+
## 常用命令
|
|
449
|
+
|
|
450
|
+
以 `unsloth-studio` 和 `ollama` 为例:
|
|
451
|
+
|
|
452
|
+
```bash
|
|
453
|
+
# 1. 启动服务(未配置主域名时使用随机 *.trycloudflare.com 临时链接)
|
|
454
|
+
colabllm unsloth-studio up
|
|
455
|
+
|
|
456
|
+
# 2. 配置所有服务共享的主域名,再启动固定域名服务
|
|
457
|
+
colabllm tunnel-config --base-domain 443998.xyz
|
|
458
|
+
colabllm ollama up --domain
|
|
459
|
+
colabllm qwen-flash up --domain # 绑定 https://qwen.443998.xyz(G4 GPU,800K 上下文 + 视觉)
|
|
460
|
+
|
|
461
|
+
# 3. 查看访问 URL、登录密码与 API Token
|
|
462
|
+
colabllm ollama info --show-secrets
|
|
463
|
+
|
|
464
|
+
# 4. 查看实时日志 / 检查状态与公网连通性
|
|
465
|
+
colabllm ollama logs -f
|
|
466
|
+
colabllm ollama status
|
|
467
|
+
|
|
468
|
+
# 5. 停止服务并释放 Colab VM(加 --delete-tunnel 同时删除 Cloudflare 隧道和 DNS 记录)
|
|
469
|
+
colabllm ollama down
|
|
470
|
+
colabllm ollama down --delete-tunnel
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
## 多实例(多会话)并发支持(所有运行时通用)
|
|
474
|
+
|
|
475
|
+
所有运行时脚本(`nemotron-transcribe.py`、`comfyui.py`、`qwen-flash.py`、`ollama.py`、`unsloth-studio.py` 以及 `templates/service.py`)均原生支持通过 **`-i <ID>` / `--instance <ID>`**(或环境变量 `CT_INSTANCE=<ID>`)创建和管理多个独立的 Colab GPU 会话与隧道:
|
|
476
|
+
|
|
477
|
+
| 实例参数 | Colab 会话名 (`-s`) | 状态目录 (`~/.colabllm/services/`) | 隧道名 (`--domain`) | 默认域名 (`--domain`) | 网盘共享目录 (`CT_DATA_DIR`) |
|
|
478
|
+
| --- | --- | --- | --- | --- | --- |
|
|
479
|
+
| 默认(不传 `-i`) | `<name>` | `~/.colabllm/services/<name>/` | `colab-<name>` | `<host>.443998.xyz` | `/content/drive/MyDrive/colab-llm/<name>` |
|
|
480
|
+
| `-i 1` | `<name>-1` | `~/.colabllm/services/<name>-1/` | `colab-<name>-1` | `<host>-1.443998.xyz` | `/content/drive/MyDrive/colab-llm/<name>`(共享缓存与数据) |
|
|
481
|
+
| `-i 2` | `<name>-2` | `~/.colabllm/services/<name>-2/` | `colab-<name>-2` | `<host>-2.443998.xyz` | `/content/drive/MyDrive/colab-llm/<name>`(共享缓存与数据) |
|
|
482
|
+
|
|
483
|
+
```bash
|
|
484
|
+
# 启动任意运行时的多个并发实例(各自拥有独立的 Colab GPU VM、Cloudflare 隧道与域名)
|
|
485
|
+
colabllm comfyui up -i 1 --domain # -> https://comfyui-1.443998.xyz
|
|
486
|
+
colabllm comfyui up -i 2 --domain # -> https://comfyui-2.443998.xyz
|
|
487
|
+
colabllm qwen-flash up -i 2 --domain # -> https://qwen-2.443998.xyz
|
|
488
|
+
colabllm ollama up -i 2 --domain # -> https://ollama-2.443998.xyz
|
|
489
|
+
colabllm unsloth-studio up -i 2 --domain # -> https://unsloth-studio-2.443998.xyz
|
|
490
|
+
colabllm nemotron-transcribe up -i 2 --domain # -> https://transcribe-2.443998.xyz
|
|
491
|
+
|
|
492
|
+
# 列出某个服务的所有实例状态、URL 与 API Token
|
|
493
|
+
colabllm <name> ps
|
|
494
|
+
|
|
495
|
+
# 查看指定实例的详情 / 日志 / 状态
|
|
496
|
+
colabllm <name> info --show-secrets -i 2
|
|
497
|
+
colabllm <name> logs -i 2 -f
|
|
498
|
+
colabllm <name> status -i 2
|
|
499
|
+
|
|
500
|
+
# 停止指定实例,或使用 --all 一键停止该服务的所有实例
|
|
501
|
+
colabllm <name> down -i 2
|
|
502
|
+
colabllm <name> down --all
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
## 新增一个大模型服务
|
|
506
|
+
|
|
507
|
+
1. 复制模板:
|
|
508
|
+
```bash
|
|
509
|
+
cp templates/service.py src/colabllm/services/<name>.py
|
|
510
|
+
cp templates/service.ipynb src/colabllm/services/<name>.ipynb
|
|
511
|
+
chmod +x src/colabllm/services/<name>.py
|
|
512
|
+
```
|
|
513
|
+
2. 修改 `src/colabllm/services/<name>.py` 中的 `Service(...)` 配置(端口、`auth="caddy"` 或 `"builtin"`、GPU 类型)。
|
|
514
|
+
3. 修改 `src/colabllm/services/<name>.ipynb` 的 **Cell 1(安装)** 和 **Cell 2(启动服务,绑定 `127.0.0.1`)**。
|
|
515
|
+
4. 先运行 `colabllm <name> up --dry-run` 检查执行计划,再正式运行 `up`。
|
|
516
|
+
5. 同一变更中更新 `docs/<name>.md`,运行 `python tools/sync_runtime_docs.py` 生成对应的技能参考文档,并更新 `skills/colabllm/SKILL.md` 的运行时索引,覆盖启动、调用、输入输出、认证和任务恢复。新增、删除运行时或修改命令行为都需要同步维护用户技能。
|
|
517
|
+
6. 核对技能示例与实际 CLI 参数一致,构建分发包,并用 `tools/check_distribution.py` 验证安装、运行时发现和完整技能导出;新增文件类型时同步调整打包规则。运行时及其用户技能均可从安装包使用后,才算完成新增流程。
|
|
518
|
+
|
|
519
|
+
详细规范与排错指南见 [`.agents/skills/colab-llm-service/SKILL.md`](.agents/skills/colab-llm-service/SKILL.md)。
|