Skip to content

Commit de472c3

Browse files
committed
add input_fidelity to image generation tool
1 parent 6561832 commit de472c3

File tree

1 file changed

+40
-5
lines changed

1 file changed

+40
-5
lines changed

src/Models/Tool.swift

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,12 @@ import MetaCodable
498498
case transparent, opaque, auto
499499
}
500500

501+
/// Control how much effort the model will exert to match the style and features, especially facial features, of input images.
502+
public enum InputFidelity: String, CaseIterable, Equatable, Hashable, Codable, Sendable {
503+
case low, high
504+
}
505+
506+
/// Optional mask for inpainting.
501507
public enum ImageMask: Equatable, Hashable, Sendable {
502508
case image(Data)
503509
case file(id: String)
@@ -513,7 +519,7 @@ import MetaCodable
513519
case low, medium, high, auto
514520
}
515521

516-
/// The size of the generated image.
522+
/// The aspect ratio of the generated image.
517523
public enum AspectRatio: String, CaseIterable, Equatable, Hashable, Codable, Sendable {
518524
case auto
519525
case square = "1024x1024"
@@ -524,6 +530,9 @@ import MetaCodable
524530
/// Background type for the generated image.
525531
public var background: Background?
526532

533+
/// Control how much effort the model will exert to match the style and features, especially facial features, of input images.
534+
public var inputFidelity: InputFidelity?
535+
527536
/// Optional mask for inpainting.
528537
@CodedAt("input_image_mask") public var imageMask: ImageMask?
529538

@@ -541,18 +550,41 @@ import MetaCodable
541550
/// The output format of the generated image.
542551
///
543552
/// Defaults to `png`.
544-
public var format: Format?
553+
@CodedAt("output_format") public var format: Format?
545554

546555
/// Number of partial images to generate in streaming mode, from 0 (default value) to 3.
547556
public var partialImages: UInt?
548557

549558
/// The quality of the generated image.
550559
public var quality: Quality?
551560

552-
/// The size of the generated image.
561+
/// The aspect ratio of the generated image.
553562
@CodedAt("size") public var aspectRatio: AspectRatio?
554563

555-
public init(background: Background? = nil, imageMask: ImageMask? = nil, model: Model.Image? = nil, moderation: String? = nil, compression: UInt? = nil, format: Format? = nil, partialImages: UInt? = nil, quality: Quality? = nil, aspectRatio: AspectRatio? = nil) {
564+
/// Create a new `ImageGeneration` instance.
565+
///
566+
/// - Parameter background: Background type for the generated image.
567+
/// - Parameter inputFidelity: Control how much effort the model will exert to match the style and features, especially facial features, of input images.
568+
/// - Parameter imageMask: Optional mask for inpainting.
569+
/// - Parameter model: The image generation model to use.
570+
/// - Parameter moderation: Moderation level for the generated image.
571+
/// - Parameter compression: Compression level for the output image.
572+
/// - Parameter format: The output format of the generated image.
573+
/// - Parameter partialImages: Number of partial images to generate in streaming mode, from 0 (default value) to 3.
574+
/// - Parameter quality: The quality of the generated image.
575+
/// - Parameter aspectRatio: The aspect ratio of the generated image.
576+
public init(
577+
background: Background? = nil,
578+
inputFidelity: InputFidelity? = nil,
579+
imageMask: ImageMask? = nil,
580+
model: Model.Image? = nil,
581+
moderation: String? = nil,
582+
compression: UInt? = nil,
583+
format: Format? = nil,
584+
partialImages: UInt? = nil,
585+
quality: Quality? = nil,
586+
aspectRatio: AspectRatio? = nil
587+
) {
556588
self.model = model
557589
self.format = format
558590
self.quality = quality
@@ -562,6 +594,7 @@ import MetaCodable
562594
self.aspectRatio = aspectRatio
563595
self.compression = compression
564596
self.partialImages = partialImages
597+
self.inputFidelity = inputFidelity
565598
}
566599
}
567600

@@ -677,6 +710,7 @@ public extension Tool {
677710
///
678711
/// Learn more about the [image generation tool](https://platform.openai.com/docs/guides/tools-image-generation).
679712
/// - Parameter background: Background type for the generated image.
713+
/// - Parameter inputFidelity: Control how much effort the model will exert to match the style and features, especially facial features, of input images.
680714
/// - Parameter imageMask: Optional mask for inpainting.
681715
/// - Parameter model: The image generation model to use.
682716
/// - Parameter moderation: Moderation level for the generated image.
@@ -687,6 +721,7 @@ public extension Tool {
687721
/// - Parameter aspectRatio: The aspect ratio of the generated image.
688722
static func imageGeneration(
689723
background: ImageGeneration.Background? = nil,
724+
inputFidelity: ImageGeneration.InputFidelity? = nil,
690725
imageMask: ImageGeneration.ImageMask? = nil,
691726
model: Model.Image? = nil,
692727
moderation: String? = nil,
@@ -696,7 +731,7 @@ public extension Tool {
696731
quality: ImageGeneration.Quality? = nil,
697732
aspectRatio: ImageGeneration.AspectRatio? = nil
698733
) -> Self {
699-
.imageGeneration(ImageGeneration(background: background, imageMask: imageMask, model: model, moderation: moderation, compression: compression, format: format, partialImages: partialImages, quality: quality, aspectRatio: aspectRatio))
734+
.imageGeneration(ImageGeneration(background: background, inputFidelity: inputFidelity, imageMask: imageMask, model: model, moderation: moderation, compression: compression, format: format, partialImages: partialImages, quality: quality, aspectRatio: aspectRatio))
700735
}
701736
}
702737

0 commit comments

Comments
 (0)