From 686e35a88f3562a9ac6cec5c6ede5799847226e9 Mon Sep 17 00:00:00 2001 From: Mikachu2333 Date: Mon, 26 Oct 2026 23:35:48 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0Hugging=20Face=E6=8D=A2?= =?UTF-8?q?=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chsrc-main.c | 2 +- src/recipe/menu.c | 3 ++ src/recipe/ware/Huggingface.c | 99 +++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 src/recipe/ware/Huggingface.c diff --git a/src/chsrc-main.c b/src/chsrc-main.c index ec9679edf..8d9c615ec 100644 --- a/src/chsrc-main.c +++ b/src/chsrc-main.c @@ -96,7 +96,7 @@ chsrc_register_chefs_and_sauciers () /** * AI贡献者: * - * ChatGPT、GitHub Copilot、DeepSeek、Claude + * ChatGPT、GitHub Copilot、DeepSeek、Claude、Qwen * * 这几位是贡献者显式说明的,也许还有隐式使用的一些AI并没有被记录下来,可以添加在这里 */ diff --git a/src/recipe/menu.c b/src/recipe/menu.c index af9804eb5..00f5fe07e 100644 --- a/src/recipe/menu.c +++ b/src/recipe/menu.c @@ -113,6 +113,7 @@ #include "ware/Flatpak.c" #include "ware/Docker/Docker.c" #include "ware/Anaconda/Anaconda.c" +#include "ware/Huggingface.c" void @@ -154,6 +155,7 @@ chsrc_init_menu () add(RubyChina); // Ruby China 镜像站实际上已于2026年7月21日停用,但由于其是持续数十年的由社区维护驱动的镜像站,我们保留表示致敬 add(EmacsChina); add(NpmMirror); add(GoProxyIO); add(GoProxyCN); add(RsProxyCN); add(FlutterCN); + add(HFMirror); /* 暂不支持 &NugetOrg */ @@ -245,6 +247,7 @@ chsrc_init_menu () add (emacs); add (tex); add (anaconda); + add (huggingface_cli); #undef add chef_set_preparefn_for_sources_only_dish (pl_pypi); diff --git a/src/recipe/ware/Huggingface.c b/src/recipe/ware/Huggingface.c new file mode 100644 index 000000000..4e91a4055 --- /dev/null +++ b/src/recipe/ware/Huggingface.c @@ -0,0 +1,99 @@ +/** ------------------------------------------------------------ + * SPDX-License-Identifier: GPL-3.0-or-later + * ------------------------------------------------------------*/ + +def_dish(wr_huggingface_cli, "huggingface-cli/huggingface/hf"); + + + +static MirrorSite_t +HFMirror = { + IS_DedicatedMirrorSite, + "hfmirror", "HF-Mirror", "HuggingFace 镜像站", "https://hf-mirror.com/" +}; + + + +void +wr_huggingface_cli_prepare () +{ + chef_prep_this_dish (wr_huggingface_cli, gsr); + + chef_set_recipe_created_on (this, "2026-10-26"); + chef_set_recipe_last_updated (this, "2026-10-26"); + + chef_set_chefs (this, 1, "@Mikachu2333"); + chef_set_sauciers (this, 1, "@Mikachu2333"); + + chef_set_scope_cap (this, ProjectScope, ScopeCap_Unable); + chef_set_scope_cap (this, UserScope, ScopeCap_Able_And_Implemented); + chef_set_scope_cap (this, SystemScope, ScopeCap_Unable); + chef_set_default_scope (this, UserScope); + + chef_deny_english(this); + chef_allow_user_define(this); + + def_sources_begin() + {&UpstreamProvider, "https://huggingface.co", "https://huggingface.co/deepseek-ai/DeepSeek-V4.1-Flash-1017/resolve/main/model.safetensors.index.json"}, + {&HFMirror, "https://hf-mirror.com", "https://hf-mirror.com/api/resolve-cache/models/deepseek-ai/DeepSeek-V4.1-Flash-1017/1bae0e1088993b9b82de08f59de5be5a34e42170/model.safetensors.index.json?download=true"} + def_sources_end() +} + + + +void +wr_huggingface_cli_getsrc (char *option) +{ + chsrc_view_env ("HF_ENDPOINT", NULL); +} + + + +void +wr_huggingface_cli_setsrc (char *option) +{ + chsrc_use_this_source (wr_huggingface_cli); + +#ifdef XY_Build_On_Windows + + char *cmd = xy_strcat (3, "setx HF_ENDPOINT \"", source.url, "\""); + chsrc_run (cmd, RunOpt_Dont_Notify_On_Success|RunOpt_No_Last_New_Line); + +#else + + char *w = xy_strcat (3, "export HF_ENDPOINT=\"", source.url, "\"\n"); + + char *bashrc = xy_bashrc; + if (xy_file_exist (bashrc)) + { + chsrc_backup (bashrc); + chsrc_append_to_file (w, bashrc); + } + + char *zshrc = xy_zshrc; + if (xy_file_exist (zshrc)) + { + chsrc_backup (zshrc); + chsrc_append_to_file (w, zshrc); + } + + char *fishrc = xy_fishrc; + if (xy_file_exist (fishrc)) + { + char *w = xy_strcat (3, "set -x HF_ENDPOINT ", source.url, "\n"); + + chsrc_backup (fishrc); + chsrc_append_to_file (w, fishrc); + } +#endif + + chsrc_determine_chgtype (ChgType_Auto); + chsrc_conclude (&source); + chsrc_alert2 ("请重启终端使huggingface-cli环境变量生效"); +} + +void +wr_huggingface_cli_resetsrc (char *option) +{ + wr_huggingface_cli_setsrc (option); +} From 1dbdffe57e4a07972f3b407226ea1271c902e043 Mon Sep 17 00:00:00 2001 From: Mikachu2333 Date: Wed, 28 Oct 2026 15:43:38 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BB=85=E4=BB=A5=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E6=8D=A2=E6=BA=90=20Hugging=20Face?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/recipe/menu.c | 1 - src/recipe/ware/Huggingface.c | 60 +++++++---------------------------- 2 files changed, 12 insertions(+), 49 deletions(-) diff --git a/src/recipe/menu.c b/src/recipe/menu.c index 00f5fe07e..b1b71de25 100644 --- a/src/recipe/menu.c +++ b/src/recipe/menu.c @@ -155,7 +155,6 @@ chsrc_init_menu () add(RubyChina); // Ruby China 镜像站实际上已于2026年7月21日停用,但由于其是持续数十年的由社区维护驱动的镜像站,我们保留表示致敬 add(EmacsChina); add(NpmMirror); add(GoProxyIO); add(GoProxyCN); add(RsProxyCN); add(FlutterCN); - add(HFMirror); /* 暂不支持 &NugetOrg */ diff --git a/src/recipe/ware/Huggingface.c b/src/recipe/ware/Huggingface.c index 4e91a4055..11259f7fd 100644 --- a/src/recipe/ware/Huggingface.c +++ b/src/recipe/ware/Huggingface.c @@ -6,36 +6,27 @@ def_dish(wr_huggingface_cli, "huggingface-cli/huggingface/hf"); -static MirrorSite_t -HFMirror = { - IS_DedicatedMirrorSite, - "hfmirror", "HF-Mirror", "HuggingFace 镜像站", "https://hf-mirror.com/" -}; - - - void wr_huggingface_cli_prepare () { chef_prep_this_dish (wr_huggingface_cli, gsr); chef_set_recipe_created_on (this, "2026-10-26"); - chef_set_recipe_last_updated (this, "2026-10-26"); + chef_set_recipe_last_updated (this, "2026-10-28"); chef_set_chefs (this, 1, "@Mikachu2333"); chef_set_sauciers (this, 1, "@Mikachu2333"); chef_set_scope_cap (this, ProjectScope, ScopeCap_Unable); chef_set_scope_cap (this, UserScope, ScopeCap_Able_And_Implemented); - chef_set_scope_cap (this, SystemScope, ScopeCap_Unable); + chef_set_scope_cap (this, SystemScope, ScopeCap_Able_And_Implemented); chef_set_default_scope (this, UserScope); chef_deny_english(this); chef_allow_user_define(this); def_sources_begin() - {&UpstreamProvider, "https://huggingface.co", "https://huggingface.co/deepseek-ai/DeepSeek-V4.1-Flash-1017/resolve/main/model.safetensors.index.json"}, - {&HFMirror, "https://hf-mirror.com", "https://hf-mirror.com/api/resolve-cache/models/deepseek-ai/DeepSeek-V4.1-Flash-1017/1bae0e1088993b9b82de08f59de5be5a34e42170/model.safetensors.index.json?download=true"} + {&UpstreamProvider, "https://huggingface.co", "https://huggingface.co/deepseek-ai/DeepSeek-V4.1-Flash-1017/resolve/main/model.safetensors.index.json"} def_sources_end() } @@ -52,48 +43,21 @@ wr_huggingface_cli_getsrc (char *option) void wr_huggingface_cli_setsrc (char *option) { - chsrc_use_this_source (wr_huggingface_cli); - -#ifdef XY_Build_On_Windows - - char *cmd = xy_strcat (3, "setx HF_ENDPOINT \"", source.url, "\""); - chsrc_run (cmd, RunOpt_Dont_Notify_On_Success|RunOpt_No_Last_New_Line); - -#else - - char *w = xy_strcat (3, "export HF_ENDPOINT=\"", source.url, "\"\n"); - - char *bashrc = xy_bashrc; - if (xy_file_exist (bashrc)) - { - chsrc_backup (bashrc); - chsrc_append_to_file (w, bashrc); - } - - char *zshrc = xy_zshrc; - if (xy_file_exist (zshrc)) - { - chsrc_backup (zshrc); - chsrc_append_to_file (w, zshrc); - } + char *repo_note = "请手动设置环境变量 HF_ENDPOINT 到您希望换源的站点,例如:\n"; + char *site_note = "HF_ENDPOINT=\"https://huggingface.co\"\n"; + char *end_note = "由于 Hugging Face 的体量极大,现有的镜像站点规模小、不保证运行及质量,因此不提供具体镜像站点,以上仅为示例。"; - char *fishrc = xy_fishrc; - if (xy_file_exist (fishrc)) - { - char *w = xy_strcat (3, "set -x HF_ENDPOINT ", source.url, "\n"); - chsrc_backup (fishrc); - chsrc_append_to_file (w, fishrc); - } -#endif + char *w = xy_strcat (3, repo_note, site_note, end_note); + say (w); - chsrc_determine_chgtype (ChgType_Auto); - chsrc_conclude (&source); - chsrc_alert2 ("请重启终端使huggingface-cli环境变量生效"); + chsrc_determine_chgtype (ChgType_Manual); + chsrc_alert2 ("请重启终端使 HF_ENDPOINT 环境变量生效。"); } void wr_huggingface_cli_resetsrc (char *option) { - wr_huggingface_cli_setsrc (option); + char *w = "请手动删除环境变量 HF_ENDPOINT,并重启终端。\n"; + say (w); }