diff options
author | Laurent Mazare <laurent.mazare@gmail.com> | 2024-12-31 10:55:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-31 10:55:45 +0100 |
commit | 7354afc6735ae387cd2d86c18d902fbd24439b78 (patch) | |
tree | 100f9aec016caca38c74ef68d1a8d6a63b2cd84f | |
parent | 2a705e6f3739cd43b40139b1ee58141b733bcfc1 (diff) | |
download | candle-7354afc6735ae387cd2d86c18d902fbd24439b78.tar.gz candle-7354afc6735ae387cd2d86c18d902fbd24439b78.tar.bz2 candle-7354afc6735ae387cd2d86c18d902fbd24439b78.zip |
Use the default hf-hub cache for glm. (#2695)
-rw-r--r-- | candle-examples/examples/glm4/main.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/candle-examples/examples/glm4/main.rs b/candle-examples/examples/glm4/main.rs index ced3841d..a6ba7c72 100644 --- a/candle-examples/examples/glm4/main.rs +++ b/candle-examples/examples/glm4/main.rs @@ -109,10 +109,10 @@ impl TextGeneration { #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] struct Args { - /// Run on CPU rather than on GPU. #[arg(name = "cache", short, long, default_value = ".")] - cache_path: String, + cache_path: Option<String>, + /// Run on CPU rather than on GPU. #[arg(long)] cpu: bool, @@ -178,11 +178,14 @@ fn main() -> anyhow::Result<()> { ); let start = std::time::Instant::now(); - let api = hf_hub::api::sync::ApiBuilder::from_cache(hf_hub::Cache::new( - args.cache_path.to_string().into(), - )) - .build() - .map_err(anyhow::Error::msg)?; + let api = match args.cache_path.as_ref() { + None => hf_hub::api::sync::Api::new()?, + Some(path) => { + hf_hub::api::sync::ApiBuilder::from_cache(hf_hub::Cache::new(path.to_string().into())) + .build() + .map_err(anyhow::Error::msg)? + } + }; let model_id = match args.model_id.as_ref() { Some(model_id) => model_id.to_string(), |