summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-07-09 11:17:13 +0800
committerGitHub <noreply@github.com>2024-07-09 11:17:13 +0800
commit138c90b58bf90be84de3fedbbdf8e05bf0820a11 (patch)
tree697e57184dce5844e10309a4a524b466493d323f /src
parent10a4c23c83b2101b049e3d94458310a9511eb18e (diff)
downloadaichat-138c90b58bf90be84de3fedbbdf8e05bf0820a11.tar.gz
feat: set model with env AICHAT_MODEL (#691)
Diffstat (limited to 'src')
-rw-r--r--src/config/mod.rs11
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;