|
| 1 | +// |
| 2 | +// FalFluxSchnellInputSchema.swift |
| 3 | +// |
| 4 | +// |
| 5 | +// Created by Hunor Zoltáni on 01.03.2025. |
| 6 | +// |
| 7 | + |
| 8 | +import Foundation |
| 9 | + |
| 10 | +/// Docstrings taken from the tooltips here: https://fal.ai/models/fal-ai/flux/schnell |
| 11 | +public struct FalFluxSchnellInputSchema: Encodable { |
| 12 | + // Required |
| 13 | + |
| 14 | + /// The prompt to generate an image from. |
| 15 | + public let prompt: String |
| 16 | + |
| 17 | + // Optional |
| 18 | + |
| 19 | + /// If set to true, the safety checker will be enabled. Default value: true |
| 20 | + public let enableSafetyChecker: Bool? |
| 21 | + |
| 22 | + /// The size of the generated image. |
| 23 | + /// Default value: `.landscape4x3` |
| 24 | + public let imageSize: ImageSize? |
| 25 | + |
| 26 | + /// The number of images to generate. |
| 27 | + /// Default value: `1` |
| 28 | + public let numImages: Int? |
| 29 | + |
| 30 | + /// The number of inference steps to perform. |
| 31 | + /// Default value: `4` |
| 32 | + public let numInferenceSteps: Int? |
| 33 | + |
| 34 | + /// The same seed and the same prompt given to the same version of the model will output the same image every time. |
| 35 | + public let seed: Int? |
| 36 | + |
| 37 | + /// If set to true, the function will wait for the image to be generated and uploaded |
| 38 | + /// before returning the response. This will increase the latency of the function but it |
| 39 | + /// allows you to get the image directly in the response without going through the CDN. |
| 40 | + public let syncMode: Bool? |
| 41 | + |
| 42 | + private enum CodingKeys: String, CodingKey { |
| 43 | + case enableSafetyChecker = "enable_safety_checker" |
| 44 | + case imageSize = "image_size" |
| 45 | + case numImages = "num_images" |
| 46 | + case numInferenceSteps = "num_inference_steps" |
| 47 | + case prompt |
| 48 | + case seed |
| 49 | + case syncMode = "sync_mode" |
| 50 | + } |
| 51 | + |
| 52 | + // This memberwise initializer is autogenerated. |
| 53 | + // To regenerate, use `cmd-shift-a` > Generate Memberwise Initializer |
| 54 | + // To format, place the cursor in the initializer's parameter list and use `ctrl-m` |
| 55 | + public init( |
| 56 | + prompt: String, |
| 57 | + enableSafetyChecker: Bool? = nil, |
| 58 | + imageSize: FalFluxSchnellInputSchema.ImageSize? = nil, |
| 59 | + numImages: Int? = nil, |
| 60 | + numInferenceSteps: Int? = nil, |
| 61 | + seed: Int? = nil, |
| 62 | + syncMode: Bool? = nil |
| 63 | + ) { |
| 64 | + self.prompt = prompt |
| 65 | + self.enableSafetyChecker = enableSafetyChecker |
| 66 | + self.imageSize = imageSize |
| 67 | + self.numImages = numImages |
| 68 | + self.numInferenceSteps = numInferenceSteps |
| 69 | + self.seed = seed |
| 70 | + self.syncMode = syncMode |
| 71 | + } |
| 72 | + |
| 73 | +} |
| 74 | + |
| 75 | +// MARK: - InputSchema.ImageSize |
| 76 | +extension FalFluxSchnellInputSchema { |
| 77 | + public enum ImageSize: String, Encodable { |
| 78 | + case landscape16x9 = "landscape_16_9" |
| 79 | + case landscape4x3 = "landscape_4_3" |
| 80 | + case portrait16x9 = "portrait_16_9" |
| 81 | + case portrait4x3 = "portrait_4_3" |
| 82 | + case square |
| 83 | + case squareHD = "square_hd" |
| 84 | + } |
| 85 | +} |
0 commit comments