Skip to content

Commit 8c57078

Browse files
committed
Add support for multiple image files in CreateImageEditRequest
Fixes 64bit#363
1 parent aeb6d1f commit 8c57078

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

async-openai/src/types/image.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ pub struct ImageInput {
146146
#[builder(build_fn(error = "OpenAIError"))]
147147
pub struct CreateImageEditRequest {
148148
/// The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask.
149-
pub image: ImageInput,
149+
pub image: Vec<ImageInput>,
150150

151151
/// A text description of the desired image(s). The maximum length is 1000 characters.
152152
pub prompt: String,

async-openai/src/types/impls.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -893,12 +893,14 @@ impl AsyncTryFrom<CreateImageEditRequest> for reqwest::multipart::Form {
893893
type Error = OpenAIError;
894894

895895
async fn try_from(request: CreateImageEditRequest) -> Result<Self, Self::Error> {
896-
let image_part = create_file_part(request.image.source).await?;
897-
898896
let mut form = reqwest::multipart::Form::new()
899-
.part("image", image_part)
900897
.text("prompt", request.prompt);
901898

899+
for image in request.image {
900+
let image_part = create_file_part(image.source).await?;
901+
form = form.part("image[]", image_part);
902+
}
903+
902904
if let Some(mask) = request.mask {
903905
let mask_part = create_file_part(mask.source).await?;
904906
form = form.part("mask", mask_part);

0 commit comments

Comments
 (0)