From 9357fc162aa4d628839309d563e07ed3091ecde3 Mon Sep 17 00:00:00 2001 From: Nicolas Patry Date: Tue, 30 Jul 2024 18:21:11 +0200 Subject: [PATCH] Backporting 457fb0a1 --- router/src/server.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/router/src/server.rs b/router/src/server.rs index 24c92873..ccbd1535 100644 --- a/router/src/server.rs +++ b/router/src/server.rs @@ -1553,7 +1553,10 @@ pub async fn run( } let api = if use_api { if std::env::var("HF_HUB_OFFLINE") == Ok("1".to_string()) { - let cache = Cache::default(); + let cache = std::env::var("HUGGINGFACE_HUB_CACHE") + .map_err(|_| ()) + .map(|cache_dir| Cache::new(cache_dir.into())) + .unwrap_or_else(|_| Cache::default()); tracing::warn!("Offline mode active using cache defaults"); Type::Cache(cache) } else {