Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,6 @@ pub struct ChatCompletionDeleted {
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[serde(tag = "type")]
#[serde(rename_all = "snake_case")]

pub enum ContentPart {
Text(ChatCompletionRequestMessageContentPartText),
ImageUrl(ChatCompletionRequestMessageContentPartImage),
Expand Down
4 changes: 2 additions & 2 deletions async-openai/src/types/chat/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
mod chat;
mod chat_types;

pub use chat::*;
pub use chat_types::*;
4 changes: 2 additions & 2 deletions async-openai/src/types/containers/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
mod containers;
mod container;

pub use containers::*;
pub use container::*;
3 changes: 2 additions & 1 deletion async-openai/src/types/finetuning/fine_tuning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ pub enum FineTuneMethod {
dpo: FineTuneDPOMethod,
},
Reinforcement {
reinforcement: FineTuneReinforcementMethod,
// Boxed because https://rust-lang.github.io/rust-clippy/rust-1.91.0/index.html#large_enum_variant
reinforcement: Box<FineTuneReinforcementMethod>,
},
}

Expand Down
27 changes: 10 additions & 17 deletions async-openai/src/types/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ use crate::{
ChatCompletionRequestSystemMessageContent, ChatCompletionRequestToolMessage,
ChatCompletionRequestToolMessageContent, ChatCompletionRequestUserMessage,
ChatCompletionRequestUserMessageContent, ChatCompletionRequestUserMessageContentPart,
ChatCompletionToolChoiceOption, FunctionName, ImageUrl, Prompt, Role,
StopConfiguration,
FunctionName, ImageUrl, Prompt, Role, StopConfiguration,
},
containers::CreateContainerFileRequest,
embeddings::EmbeddingInput,
Expand All @@ -38,7 +37,7 @@ use crate::{
},
images::{ImageBackground, ImageEditInput, ImageOutputFormat, ImageQuality, InputFidelity},
moderations::ModerationInput,
responses::{EasyInputContent, Role as ResponsesRole},
responses::EasyInputContent,
uploads::AddUploadPartRequest,
videos::{CreateVideoRequest, VideoSize},
CreateMessageRequestContent, InputSource,
Expand Down Expand Up @@ -223,50 +222,50 @@ impl From<PathBuf> for ImageEditInput {
// Arrays of path-like values
impl<const N: usize> From<[&str; N]> for ImageEditInput {
fn from(value: [&str; N]) -> Self {
Self::Images(value.into_iter().map(|v| ImageInput::from(v)).collect())
Self::Images(value.into_iter().map(ImageInput::from).collect())
}
}

impl<const N: usize> From<[String; N]> for ImageEditInput {
fn from(value: [String; N]) -> Self {
Self::Images(value.into_iter().map(|v| ImageInput::from(v)).collect())
Self::Images(value.into_iter().map(ImageInput::from).collect())
}
}

impl<const N: usize> From<[&Path; N]> for ImageEditInput {
fn from(value: [&Path; N]) -> Self {
Self::Images(value.into_iter().map(|v| ImageInput::from(v)).collect())
Self::Images(value.into_iter().map(ImageInput::from).collect())
}
}

impl<const N: usize> From<[PathBuf; N]> for ImageEditInput {
fn from(value: [PathBuf; N]) -> Self {
Self::Images(value.into_iter().map(|v| ImageInput::from(v)).collect())
Self::Images(value.into_iter().map(ImageInput::from).collect())
}
}

// Vectors of path-like values
impl<'a> From<Vec<&'a str>> for ImageEditInput {
fn from(value: Vec<&'a str>) -> Self {
Self::Images(value.into_iter().map(|v| ImageInput::from(v)).collect())
Self::Images(value.into_iter().map(ImageInput::from).collect())
}
}

impl From<Vec<String>> for ImageEditInput {
fn from(value: Vec<String>) -> Self {
Self::Images(value.into_iter().map(|v| ImageInput::from(v)).collect())
Self::Images(value.into_iter().map(ImageInput::from).collect())
}
}

impl From<Vec<&Path>> for ImageEditInput {
fn from(value: Vec<&Path>) -> Self {
Self::Images(value.into_iter().map(|v| ImageInput::from(v)).collect())
Self::Images(value.into_iter().map(ImageInput::from).collect())
}
}

impl From<Vec<PathBuf>> for ImageEditInput {
fn from(value: Vec<PathBuf>) -> Self {
Self::Images(value.into_iter().map(|v| ImageInput::from(v)).collect())
Self::Images(value.into_iter().map(ImageInput::from).collect())
}
}

Expand Down Expand Up @@ -1327,12 +1326,6 @@ impl Default for EasyInputContent {
}
}

impl Default for ResponsesRole {
fn default() -> Self {
Self::User
}
}

impl From<String> for EasyInputContent {
fn from(value: String) -> Self {
Self::Text(value)
Expand Down
3 changes: 2 additions & 1 deletion async-openai/src/types/responses/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ use serde::{Deserialize, Serialize};
use std::collections::HashMap;

/// Role of messages in the API.
#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Default)]
#[serde(rename_all = "lowercase")]
pub enum Role {
#[default]
User,
Assistant,
System,
Expand Down
Loading