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 {