From 3f1fefbfa1a3436d0a973810b8e96b2645a418c1 Mon Sep 17 00:00:00 2001 From: Meng Zhang Date: Tue, 26 Dec 2023 15:38:53 +0800 Subject: [PATCH] =?UTF-8?q?feat(core):=20add=20TABBY=5FMODEL=5FCACHE=5FROO?= =?UTF-8?q?T=20to=20allow=20individually=20set=20tabb=E2=80=A6=20(#1121)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(core): add TABBY_MODEL_CACHE_ROOT to allow individually set tabby model cache dir * docs: update changelog * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- CHANGELOG.md | 1 + crates/tabby-common/src/path.rs | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44792bca161c..c4999ea24006 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * Add windows cpu binary distribution. * Add linux rocm (AMD GPU) binary distribution. * Fix cached permanent redirection on certain browsers(e.g chrome) when `--webserver` is not enabled. +* Add environment variable `TABBY_MODEL_CACHE_ROOT` to override models cache directory individually. # v0.7.0 (12/15/2023) diff --git a/crates/tabby-common/src/path.rs b/crates/tabby-common/src/path.rs index 2dc5305fe542..823d64f91ce4 100644 --- a/crates/tabby-common/src/path.rs +++ b/crates/tabby-common/src/path.rs @@ -9,6 +9,8 @@ lazy_static! { Err(_) => home::home_dir().unwrap().join(".tabby"), })) }; + static ref TABBY_MODEL_CACHE_ROOT: Option = + env::var("TABBY_MODEL_CACHE_ROOT").ok().map(PathBuf::from); } #[cfg(feature = "testutils")] @@ -48,7 +50,11 @@ pub fn dataset_dir() -> PathBuf { } pub fn models_dir() -> PathBuf { - tabby_root().join("models") + if let Some(cache_root) = &*TABBY_MODEL_CACHE_ROOT { + cache_root.clone() + } else { + tabby_root().join("models") + } } pub fn events_dir() -> PathBuf {