Make some improvements as suggested by clippy

This commit is contained in:
Slavi Pantaleev
2025-05-10 09:33:44 +03:00
parent 3ffa50b7b9
commit ac4f2080ce
4 changed files with 10 additions and 10 deletions

View File

@@ -53,11 +53,11 @@ impl ImageSource {
} }
} }
impl Into<async_openai::types::ImageInput> for ImageSource { impl From<ImageSource> for async_openai::types::ImageInput {
fn into(self) -> async_openai::types::ImageInput { fn from(value: ImageSource) -> Self {
async_openai::types::ImageInput::from_vec_u8( async_openai::types::ImageInput::from_vec_u8(
self.filename, value.filename,
self.bytes, value.bytes,
) )
} }
} }

View File

@@ -6,11 +6,11 @@ pub fn determine_controller(
) -> ControllerType { ) -> ControllerType {
let text = text.trim(); 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()); 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()); return ControllerType::ImageEdit(prompt.trim().to_owned());
} }

View File

@@ -71,7 +71,7 @@ pub async fn handle(
let image_sources: Vec<ImageSource> = conversation.messages.iter().filter_map(|message| { let image_sources: Vec<ImageSource> = conversation.messages.iter().filter_map(|message| {
if let crate::conversation::llm::MessageContent::Image(image_content) = &message.content { if let crate::conversation::llm::MessageContent::Image(image_content) = &message.content {
Some(image_content.into()) Some(image_content.clone().into())
} else { } else {
None None
} }

View File

@@ -35,9 +35,9 @@ impl ImageDetails {
} }
} }
impl Into<ImageSource> for &ImageDetails { impl From<ImageDetails> for ImageSource {
fn into(self) -> ImageSource { fn from(value: ImageDetails) -> Self {
ImageSource::new(self.filename(), self.data.clone(), self.mime.clone()) ImageSource::new(value.filename(), value.data.clone(), value.mime.clone())
} }
} }