diff options
| author | sigoden <sigoden@gmail.com> | 2024-07-30 21:38:25 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-30 21:38:25 +0800 |
| commit | 3ab489ebac3ebb1ac20ca56a4716785e203212e4 (patch) | |
| tree | c06ae751403a140430c3de91b343ca072d36bab9 /src/config/mod.rs | |
| parent | 0ad97f2ec46bc93c199c9575c2c296c882dce19f (diff) | |
| download | aichat-3ab489ebac3ebb1ac20ca56a4716785e203212e4.tar.gz | |
refactor: do not abandon AICHAT_PLATFORM (#768)
Diffstat (limited to 'src/config/mod.rs')
| -rw-r--r-- | src/config/mod.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs index 81fa6f8..bd02ec3 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -211,12 +211,12 @@ impl Default for Config { pub type GlobalConfig = Arc<RwLock<Config>>; impl Config { - pub fn init(working_mode: WorkingMode, model_id: Option<&str>) -> Result<Self> { + pub fn init(working_mode: WorkingMode) -> Result<Self> { let config_path = Self::config_file()?; let mut config = if !config_path.exists() { - match model_id { - Some(v) => Self::load_dynamic(v)?, - None => { + match env::var(get_env_name("platform")) { + Ok(v) => Self::load_dynamic(&v)?, + Err(_) => { if *IS_STDOUT_TERMINAL { create_config_file(&config_path)?; } @@ -1563,6 +1563,9 @@ impl Config { } fn load_envs(&mut self) { + if let Ok(v) = env::var(get_env_name("model")) { + self.model_id = v; + } if let Some(v) = read_env_value::<f64>("temperature") { self.temperature = v; } |
