diff options
| -rw-r--r-- | src/config/agent.rs | 8 | ||||
| -rw-r--r-- | src/config/mod.rs | 18 | ||||
| -rw-r--r-- | src/config/role.rs | 13 | ||||
| -rw-r--r-- | src/config/session.rs | 8 |
4 files changed, 20 insertions, 27 deletions
diff --git a/src/config/agent.rs b/src/config/agent.rs index fada1f7..7c50523 100644 --- a/src/config/agent.rs +++ b/src/config/agent.rs @@ -336,10 +336,6 @@ impl RoleLike for Agent { &self.model } - fn model_mut(&mut self) -> &mut Model { - &mut self.model - } - fn temperature(&self) -> Option<f64> { self.config.temperature } @@ -352,9 +348,9 @@ impl RoleLike for Agent { self.config.use_tools.clone() } - fn set_model(&mut self, model: &Model) { + fn set_model(&mut self, model: Model) { self.config.model_id = Some(model.id()); - self.model = model.clone(); + self.model = model; } fn set_temperature(&mut self, value: Option<f64>) { diff --git a/src/config/mod.rs b/src/config/mod.rs index 242826b..10718df 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -843,15 +843,21 @@ impl Config { pub fn set_max_output_tokens(&mut self, value: Option<isize>) { match self.role_like_mut() { - Some(role_like) => role_like.model_mut().set_max_tokens(value, true), - None => self.model.set_max_tokens(value, true), + Some(role_like) => { + let mut model = role_like.model().clone(); + model.set_max_tokens(value, true); + role_like.set_model(model); + } + None => { + self.model.set_max_tokens(value, true); + } }; } pub fn set_model(&mut self, model_id: &str) -> Result<()> { let model = Model::retrieve_model(self, model_id, ModelType::Chat)?; match self.role_like_mut() { - Some(role_like) => role_like.set_model(&model), + Some(role_like) => role_like.set_model(model), None => { self.model = model; } @@ -861,7 +867,7 @@ impl Config { pub fn use_prompt(&mut self, prompt: &str) -> Result<()> { let mut role = Role::new(TEMP_ROLE_NAME, prompt); - role.set_model(self.current_model()); + role.set_model(self.current_model().clone()); self.use_role_obj(role) } @@ -917,12 +923,12 @@ impl Config { } else { Role::builtin(name)? }; - let current_model = self.current_model(); + let current_model = self.current_model().clone(); match role.model_id() { Some(model_id) => { if current_model.id() != model_id { let model = Model::retrieve_model(self, model_id, ModelType::Chat)?; - role.set_model(&model); + role.set_model(model); } else { role.set_model(current_model); } diff --git a/src/config/role.rs b/src/config/role.rs index 829c0d1..fedcb1e 100644 --- a/src/config/role.rs +++ b/src/config/role.rs @@ -26,11 +26,10 @@ static RE_METADATA: LazyLock<Regex> = pub trait RoleLike { fn to_role(&self) -> Role; fn model(&self) -> &Model; - fn model_mut(&mut self) -> &mut Model; fn temperature(&self) -> Option<f64>; fn top_p(&self) -> Option<f64>; fn use_tools(&self) -> Option<String>; - fn set_model(&mut self, model: &Model); + fn set_model(&mut self, model: Model); fn set_temperature(&mut self, value: Option<f64>); fn set_top_p(&mut self, value: Option<f64>); fn set_use_tools(&mut self, value: Option<String>); @@ -176,7 +175,7 @@ impl Role { top_p: Option<f64>, use_tools: Option<String>, ) { - self.set_model(model); + self.set_model(model.clone()); if temperature.is_some() { self.set_temperature(temperature); } @@ -269,10 +268,6 @@ impl RoleLike for Role { &self.model } - fn model_mut(&mut self) -> &mut Model { - &mut self.model - } - fn temperature(&self) -> Option<f64> { self.temperature } @@ -285,11 +280,11 @@ impl RoleLike for Role { self.use_tools.clone() } - fn set_model(&mut self, model: &Model) { + fn set_model(&mut self, model: Model) { if !self.model().id().is_empty() { self.model_id = Some(model.id().to_string()); } - self.model = model.clone(); + self.model = model; } fn set_temperature(&mut self, value: Option<f64>) { diff --git a/src/config/session.rs b/src/config/session.rs index a1a9317..d6c53f4 100644 --- a/src/config/session.rs +++ b/src/config/session.rs @@ -569,10 +569,6 @@ impl RoleLike for Session { &self.model } - fn model_mut(&mut self) -> &mut Model { - &mut self.model - } - fn temperature(&self) -> Option<f64> { self.temperature } @@ -585,10 +581,10 @@ impl RoleLike for Session { self.use_tools.clone() } - fn set_model(&mut self, model: &Model) { + fn set_model(&mut self, model: Model) { if self.model().id() != model.id() { self.model_id = model.id(); - self.model = model.clone(); + self.model = model; self.dirty = true; self.update_tokens(); } |
