diff options
| author | sigoden <sigoden@gmail.com> | 2024-07-09 11:17:13 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-09 11:17:13 +0800 |
| commit | 138c90b58bf90be84de3fedbbdf8e05bf0820a11 (patch) | |
| tree | 697e57184dce5844e10309a4a524b466493d323f /src/config | |
| parent | 10a4c23c83b2101b049e3d94458310a9511eb18e (diff) | |
| download | aichat-138c90b58bf90be84de3fedbbdf8e05bf0820a11.tar.gz | |
feat: set model with env AICHAT_MODEL (#691)
Diffstat (limited to 'src/config')
| -rw-r--r-- | src/config/mod.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs index eeffc87..a243a83 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -1517,15 +1517,16 @@ impl Config { } fn setup_model(&mut self) -> Result<()> { - let model_id = if self.model_id.is_empty() { + let mut model_id = match env::var(get_env_name("model")) { + Ok(v) => v, + Err(_) => self.model_id.clone(), + }; + if model_id.is_empty() { let models = list_chat_models(self); if models.is_empty() { bail!("No available model"); } - - models[0].id() - } else { - self.model_id.clone() + model_id = models[0].id() }; self.set_model(&model_id)?; self.model_id = model_id; |
