From 08cdfae79bbbfe9328712321545548dd096cdd07 Mon Sep 17 00:00:00 2001 From: sigoden Date: Fri, 1 Aug 2025 09:58:09 +0800 Subject: refactor: update RoleLike trait (#1370) --- src/config/role.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'src/config/role.rs') 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 = pub trait RoleLike { fn to_role(&self) -> Role; fn model(&self) -> &Model; - fn model_mut(&mut self) -> &mut Model; fn temperature(&self) -> Option; fn top_p(&self) -> Option; fn use_tools(&self) -> Option; - fn set_model(&mut self, model: &Model); + fn set_model(&mut self, model: Model); fn set_temperature(&mut self, value: Option); fn set_top_p(&mut self, value: Option); fn set_use_tools(&mut self, value: Option); @@ -176,7 +175,7 @@ impl Role { top_p: Option, use_tools: Option, ) { - 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 { 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) { -- cgit v1.2.3