Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bb4c3e0

Browse files
update
1 parent 86f6523 commit bb4c3e0

File tree

6 files changed

+58
-56
lines changed

6 files changed

+58
-56
lines changed

‎Sources/openai-async-image-swiftui/enum/AsyncImageErrors.swift‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77

88
import Foundation
99

10-
/// Set of errors for ``OpenAIAsyncImage``
10+
/// Enumeration representing the various errors that can occur in `OpenAIAsyncImage`
1111
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
12-
enum AsyncImageErrors: Error, Equatable{
12+
enum AsyncImageErrors: Error, Equatable{
1313

14-
/// Could not create Image from uiImage
14+
/// Error indicating that an image could not be created from a `uiImage`
1515
case imageInit
1616

17-
/// Client not found - the reason url in not valid
17+
/// Error indicating that the client was not found, likely due to an invalid URL
1818
case clientIsNotDefined
1919

20-
/// response returned no images
20+
/// Error indicating that the response returned no images
2121
case returnedNoImages
2222

2323
}

‎Sources/openai-async-image-swiftui/enum/ImageState.swift‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,16 @@
77

88
import SwiftUI
99

10-
/// Set of states for ``OpenAIAsyncImage``
10+
/// Enumeration representing the various states of `OpenAIAsyncImage`
1111
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
12-
public enum ImageState{
12+
public enum ImageState{
1313

14-
/// Loading currently
14+
/// State when the image is currently being loaded
1515
case loading
1616

17-
/// Loaded
17+
/// State when the image has been successfully loaded
1818
case loaded(Image)
1919

20-
/// There's an error happened while fetching
20+
/// State when an error occurred during image fetching
2121
case loadError(Error)
22-
2322
}

‎Sources/openai-async-image-swiftui/model/Output.swift‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,24 @@
77

88
import Foundation
99

10-
/// Output format for OpenAI API
10+
/// Structure representing the output format for the OpenAI API response
1111
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
12-
struct Output: Decodable{
12+
struct Output: Decodable{
1313

14-
/// Date and time
15-
let created: Int
14+
/// The creation date and time of the response in UNIX timestamp format
15+
let created: Int
1616

17-
/// Set of images
17+
/// An array of base64 encoded images
1818
let data: [Base64]
1919

20-
/// Fist image from the received data set
21-
var firstImage: String?{
20+
/// The first image from the received data set, if available
21+
var firstImage: String?{
2222
data.first?.b64_json
2323
}
2424
}
2525

26-
struct Base64: Decodable{
27-
let b64_json : String
26+
/// Structure representing a base64 encoded image
27+
struct Base64: Decodable {
28+
/// The base64 encoded image data in JSON format
29+
let b64_json: String
2830
}

‎Sources/openai-async-image-swiftui/net/OpenAIImageEndpoint.swift‎

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,45 +7,47 @@
77

88
import Foundation
99

10-
/// Set of specs for access to OpenAPI image resource
10+
/// Struct providing specifications for accessing the OpenAI image resource
1111
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
12-
public struct OpenAIImageEndpoint: IOpenAIImageEndpoint{
12+
public struct OpenAIImageEndpoint: IOpenAIImageEndpoint{
1313

14-
// MARK: - Static
14+
// MARK: - Static Properties
1515

16-
/// Base url to OpenAPI image resource
16+
/// Static base URL for the OpenAI image resource
1717
public static var urlString = "https://api.openai.com"
1818

19-
/// Path to the point
19+
/// Static path to the specific endpoint for generating images
2020
public static var path = "/v1/images/generations"
2121

22-
/// - Parameter apiKey: Api key for access
23-
/// - Returns: Endpoint
24-
static public func get(with apiKey: String) -> Self{
22+
/// Creates an instance of `OpenAIImageEndpoint` with the provided API key
23+
/// - Parameter apiKey: API key for accessing the OpenAI API
24+
/// - Returns: Configured instance of `OpenAIImageEndpoint`
25+
public static func get(with apiKey: String) -> Self {
2526
.init(
2627
urlString: Self.urlString,
2728
apiKey: apiKey,
28-
path: Self.path)
29+
path: Self.path
30+
)
2931
}
3032

31-
// MARK: - Config
33+
// MARK: - Instance Properties
3234

33-
/// Base url to OpenAPI image resource
35+
/// Base URL for the OpenAI image resource
3436
public let urlString: String
3537

36-
/// Path to the point
37-
public let path: String
38+
/// Path to the specific endpoint
39+
public let path: String
3840

39-
/// Api key for access
40-
public let apiKey: String
41+
/// API key for authentication and access to the OpenAI API
42+
public let apiKey: String
4143

42-
// MARK: - Life circle
44+
// MARK: - Initializer
4345

46+
/// Initializes a new instance of `OpenAIImageEndpoint`
4447
/// - Parameters:
45-
/// - urlString: Base url to OpenAPI image resource
46-
/// - httpMethod: Http method
47-
/// - apiKey: Api key for access
48-
/// - path: Path to the point
48+
/// - urlString: Base URL for the OpenAI image resource
49+
/// - apiKey: API key for accessing the OpenAI API
50+
/// - path: Path to the specific endpoint
4951
public init(urlString: String, apiKey: String, path: String) {
5052
self.urlString = urlString
5153
self.apiKey = apiKey

‎Sources/openai-async-image-swiftui/protocol/IOpenAIImageEndpoint.swift‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,17 @@
77

88
import Foundation
99

10-
/// Defines access API to OpenAI image API
10+
/// Protocol defining access to the OpenAI image API
1111
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
12-
public protocol IOpenAIImageEndpoint{
12+
public protocol IOpenAIImageEndpoint{
1313

14-
/// Base url to OpenAPI image resource
15-
var urlString: String { get }
14+
/// Base URL for the OpenAI image resource
15+
var urlString: String { get }
1616

17-
/// Path to the point
18-
var path : String { get }
19-
20-
/// Api key for access
21-
var apiKey : String { get }
17+
/// Path to the specific endpoint within the OpenAI API
18+
var path: String { get }
2219

20+
/// API key for authentication and access to the OpenAI API
21+
var apiKey: String { get }
2322

2423
}

‎Sources/openai-async-image-swiftui/protocol/IOpenAILoader.swift‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77

88
import SwiftUI
99

10-
/// Loader for getting images
10+
/// Protocol defining the loader for fetching images from the OpenAI API
1111
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
12-
public protocol IOpenAILoader{
12+
public protocol IOpenAILoader{
1313

14-
/// Load image by text
14+
/// Asynchronously loads an image based on a provided text prompt and size
1515
/// - Parameters:
16-
/// - prompt: Text
17-
/// - size: Image size
18-
/// - Returns: Open AI Image
19-
func load(_ prompt: String, with size: OpenAIImageSize) async throws -> Image
16+
/// - prompt: The text prompt describing the desired image
17+
/// - size: The size of the generated image
18+
/// - Returns: The generated OpenAI image
19+
func load(_ prompt: String, with size: OpenAIImageSize) async throws -> Image
2020
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /