diff --git a/src/agent/provider/entity/image.rs b/src/agent/provider/entity/image.rs index e3a57af..f85e367 100644 --- a/src/agent/provider/entity/image.rs +++ b/src/agent/provider/entity/image.rs @@ -53,11 +53,11 @@ impl ImageSource { } } -impl Into for ImageSource { - fn into(self) -> async_openai::types::ImageInput { +impl From for async_openai::types::ImageInput { + fn from(value: ImageSource) -> Self { async_openai::types::ImageInput::from_vec_u8( - self.filename, - self.bytes, + value.filename, + value.bytes, ) } } diff --git a/src/controller/image/determination/mod.rs b/src/controller/image/determination/mod.rs index 3192486..c450785 100644 --- a/src/controller/image/determination/mod.rs +++ b/src/controller/image/determination/mod.rs @@ -6,11 +6,11 @@ pub fn determine_controller( ) -> ControllerType { let text = text.trim(); - if let Some(prompt) = text.strip_prefix(&format!("create")) { + if let Some(prompt) = text.strip_prefix("create") { return ControllerType::ImageGeneration(prompt.trim().to_owned()); } - if let Some(prompt) = text.strip_prefix(&format!("edit")) { + if let Some(prompt) = text.strip_prefix("edit") { return ControllerType::ImageEdit(prompt.trim().to_owned()); } diff --git a/src/controller/image/edit.rs b/src/controller/image/edit.rs index 884db17..69f8566 100644 --- a/src/controller/image/edit.rs +++ b/src/controller/image/edit.rs @@ -71,7 +71,7 @@ pub async fn handle( let image_sources: Vec = conversation.messages.iter().filter_map(|message| { if let crate::conversation::llm::MessageContent::Image(image_content) = &message.content { - Some(image_content.into()) + Some(image_content.clone().into()) } else { None } diff --git a/src/conversation/llm/entity.rs b/src/conversation/llm/entity.rs index cd3c410..8ce0725 100644 --- a/src/conversation/llm/entity.rs +++ b/src/conversation/llm/entity.rs @@ -35,9 +35,9 @@ impl ImageDetails { } } -impl Into for &ImageDetails { - fn into(self) -> ImageSource { - ImageSource::new(self.filename(), self.data.clone(), self.mime.clone()) +impl From for ImageSource { + fn from(value: ImageDetails) -> Self { + ImageSource::new(value.filename(), value.data.clone(), value.mime.clone()) } }