feat: set model with env AICHAT_MODEL (#691)

pull/692/head
sigoden 3 months ago committed by GitHub
parent 10a4c23c83
commit 138c90b58b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1517,15 +1517,16 @@ impl Config {
} }
fn setup_model(&mut self) -> Result<()> { 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); let models = list_chat_models(self);
if models.is_empty() { if models.is_empty() {
bail!("No available model"); bail!("No available model");
} }
model_id = models[0].id()
models[0].id()
} else {
self.model_id.clone()
}; };
self.set_model(&model_id)?; self.set_model(&model_id)?;
self.model_id = model_id; self.model_id = model_id;

Loading…
Cancel
Save