diff --git a/docs/gai.md b/docs/gai.md deleted file mode 100644 index 43306cfbd505e2d8633780e2a3ca33541d7e20e3..0000000000000000000000000000000000000000 --- a/docs/gai.md +++ /dev/null @@ -1,71 +0,0 @@ -# 使用 Gitee AI 命令行工具上传模型 - -#### 介绍 -Gitee AI 命令行工具是一款专为开发者设计的高效工具,帮助用户轻松地将模型和数据集上传到 Gitee AI 平台。 - - -#### 安装教程 - -安装 Git LFS 和 Gitee AI CLI 以及配置 Gitee AI CLI -```bash -# 前往 https://git-lfs.com 下载 git-lfs,然后安装 Git LFS -git lfs install - -# 安装 Gitee AI CLI -/bin/bash -c "$(curl -fsSL https://gitee.com/gitee-ai/cli/raw/master/install.sh)" - -# 检查 Gitee AI CLI 版本 -gai version - -# 访问 https://gitee.com/profile/personal_access_tokens 获取 Gitee 私人令牌 -# 创建 Gitee AI 访问令牌详见: https://ai.gitee.com/docs/organization/access-token -# 全局配置 Gitee AI 和 Gitee 访问令牌 -gai config --global gitee-token -gai config --global gitee-ai-token - - -# 要为本地 Gitee 仓库配置令牌,请使用以下命令: -cd - -# 配置 Gitee token -gai config gitee-token -# 配置 Gitee AI token -gai config gitee-ai-token -``` - - - -#### 使用说明 - -推送大文件到 Gitee AI 模型、数据集仓库 -```bash - -# 在 Gitee AI 上创建模型、数据集仓库并 Clone 到本地 -git clone https://ai.gitee.com// -cd - -# 为本地仓库初始化 Gitee AI Cli 配置 -gai config init - -# 配置需要上传到 Git LFS 的文件类型, 比如 *.bin 文件 -git lfs track "*.bin" - -# 拷贝大文件到当前目录并提交 -cp ~//model.safetensors . -git add . && git commit -m 'Add model.safetensors file' - -# 将更新推送到 Gitee AI 模型、数据集仓库 -git push origin master -``` - -##### Windows 系统下使用说明 - -**建议在 WSL Ubuntu 22.04 LTS 或更高版本系统下使用**, 如果在执行 `gai config gitee-token ` 命令时遇到卡住问题, 请尝试执行以下命令, 然后继续配置您的 token: - - -```bash -dbus-run-session -- bash --noprofile --norc -# 如有需要,提前备份您的密钥环 -rm -rf ~/.local/share/keyrings -echo -n 'db' | gnome-keyring-daemon --unlock -``` diff --git a/docs/gai/gai.md b/docs/gai/gai.md new file mode 100644 index 0000000000000000000000000000000000000000..5c6e20e0b7bca74dbdd0a3910bee7fdd385913c2 --- /dev/null +++ b/docs/gai/gai.md @@ -0,0 +1,89 @@ +# 使用 Gitee AI 命令行工具上传模型 + +#### 介绍 +Gitee AI 命令行工具(`gai`)是一款专为开发者设计的高效工具,帮助用户轻松地将模型和数据集上传到 Gitee AI 平台。 + + +#### 安装和配置 + +1. 安装 Git LFS 和 + +```bash +# 前往 https://git-lfs.com 下载 git-lfs,然后安装 Git LFS +git lfs install +``` + +2. 安装 `gai` + +```bash +# 下载并安装 gai +/bin/bash -c "$(curl -fsSL https://gitee.com/gitee-ai/cli/raw/master/install.sh)" + +# 检查 Gitee AI CLI 版本 +gai version +``` + +3. 配置 `gai` +- 创建 Gitee 私人令牌:https://gitee.com/profile/personal_access_tokens ,创建令牌时请勾选 `projects` 权限 +- 创建 Gitee AI 访问令牌,请参考帮助文档:https://ai.gitee.com/docs/organization/access-token ,创建时「资源授权」请选择「全部资源」 +- 在 `gai` 中配置令牌 + ```bash + # 全局配置 Gitee AI 和 Gitee 访问令牌 + gai config gitee-token + gai config gitee-ai-token + ``` + +如果希望为**不同仓库**设置不同令牌,可参考如下命令进行配置: + +```bash +cd <仓库地址> + +# 配置 Gitee 私人令牌 +gai config --local gitee-token +# 配置 Gitee AI 访问令牌 +gai config --local gitee-ai-token +``` + +#### 使用 + +将本地的大模型文件推送到 Gitee AI 模型仓库 + +1. 在 Gitee AI [创建模型仓库](https://ai.gitee.com/models/new) + +2. 获取仓库地址并克隆到本地 + + ![输入图片说明](../../static/img/gai/clone.png) + + ```bash + git clone https://ai.gitee.com// + cd + ``` + +3. 初始化仓库配置(使用 `gai` 作为 Git LFS 的[自定义传输代理](https://github.com/git-lfs/git-lfs/blob/main/docs/custom-transfers.md)),每个仓库只需设置一次即可,相关配置将存储在仓库的 `.git/config` 文件中 + + ```bash + # 为本地仓库初始化 Gitee AI Cli 配置 + gai config init + ``` + +4. 提交并推送文件到仓库 + + ```bash + # 拷贝大文件到当前目录并提交 + cp ~//model.safetensors . + git add . && git commit -m 'Add model.safetensors file' + + # 将更新推送到 Gitee AI 模型、数据集仓库 + git push origin master + ``` + +##### Windows 系统下使用说明 + +**建议在 WSL Ubuntu 22.04 LTS 或更高版本系统下使用**, 如果在执行 `gai config gitee-token ` 命令时遇到卡住问题, 请尝试执行以下命令, 然后继续配置您的 token: + +```bash +dbus-run-session -- bash --noprofile --norc +# 如有需要,提前备份您的密钥环 +rm -rf ~/.local/share/keyrings +echo -n 'db' | gnome-keyring-daemon --unlock +``` diff --git a/docusaurus.config.ts b/docusaurus.config.ts index 8c2f69432e17b7c7e07a6ee7dac84e34aa1b062c..f178c4d68995fb8ed707cfdf65592c79d4b682e9 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -257,32 +257,32 @@ const config: Config = { { name: 'gai-readme', sourceBaseUrl: 'https://gitee.com/gitee-ai/cli/raw/master/', - outDir: 'docs', + outDir: 'docs/gai', documents: ['README.md'], modifyContent: (filename, content) => { if (filename === 'README.md') { - const lines = content.split('\n'); + let lines = content.split('\n'); // 修改标题 - const titleIndex = lines.findIndex(line => line.trim() === '# Gitee AI 命令行工具'); + const titleIndex = lines.findIndex(line => line.trim().includes('# Gitee AI 命令行工具')); if (titleIndex !== -1) { lines[titleIndex] = '# 使用 Gitee AI 命令行工具上传模型'; } + // update img link + lines = lines.map(line => + line.includes('png') ? line.replace('assets/', '../../static/img/gai/') : line + ); + // 参与贡献之后的行都不要 const idx = lines.findIndex(line => line.includes('参与贡献')); - - const fn = 'gai.md'; if (idx !== -1) { - const newContent = lines.slice(0, idx).join('\n'); - return { - filename: fn, - content: newContent, - } + lines = lines.slice(0, idx); } + return { - filename: fn, - content: content, + filename: 'gai.md', + content: lines.join('\n'), } } return undefined diff --git a/sidebars.ts b/sidebars.ts index 9ea2be982cf391ae03e9729effbc274058344495..59fed3ac71da519b751e89eb606a9af8d7d7f158 100644 --- a/sidebars.ts +++ b/sidebars.ts @@ -62,7 +62,7 @@ const sidebars: SidebarsConfig = { }, { type: 'doc', - id: 'gai', + id: 'gai/gai', }, { type: 'doc', diff --git a/static/img/gai/clone.png b/static/img/gai/clone.png new file mode 100644 index 0000000000000000000000000000000000000000..7723e46c009bd29f00f0560ef6af38508967a1ae Binary files /dev/null and b/static/img/gai/clone.png differ