Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Vertex AI] Replace ImagenImage protocol with _ImagenImage struct #14249

Merged
merged 2 commits into from
Dec 12, 2024
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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public struct ImagenFileDataImage {

@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
extension ImagenFileDataImage: ImagenImageRepresentable {
public var imagenImage: any ImagenImage {
InternalImagenImage(mimeType: mimeType, bytesBase64Encoded: nil, gcsURI: gcsURI)
public var _imagenImage: _ImagenImage {
_ImagenImage(mimeType: mimeType, bytesBase64Encoded: nil, gcsURI: gcsURI)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import Foundation

@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
public protocol ImagenImage: ImagenImageRepresentable {
var mimeType: String { get }
var bytesBase64Encoded: String? { get }
var gcsURI: String? { get }
public struct _ImagenImage {
let mimeType: String
let bytesBase64Encoded: String?
let gcsURI: String?
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,5 @@ import Foundation

@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
public protocol ImagenImageRepresentable {
var imagenImage: any ImagenImage { get }
}

@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
public extension ImagenImage {
var imagenImage: any ImagenImage {
return self
}
var _imagenImage: _ImagenImage { get }
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public struct ImagenInlineDataImage {

@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *)
extension ImagenInlineDataImage: ImagenImageRepresentable {
public var imagenImage: any ImagenImage {
InternalImagenImage(
public var _imagenImage: _ImagenImage {
_ImagenImage(
mimeType: mimeType,
bytesBase64Encoded: data.base64EncodedString(),
gcsURI: nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,6 @@ final class IntegrationTests: XCTestCase {
let image = try XCTUnwrap(response.images.first)
XCTAssertEqual(image.mimeType, "image/jpeg")
XCTAssertGreaterThan(image.data.count, 0)
let imagenImage = image.imagenImage
XCTAssertEqual(imagenImage.mimeType, image.mimeType)
XCTAssertEqual(imagenImage.bytesBase64Encoded, image.data.base64EncodedString())
XCTAssertNil(imagenImage.gcsURI)
#if canImport(UIKit)
let uiImage = try XCTUnwrap(UIImage(data: image.data))
XCTAssertEqual(uiImage.size.width, 1408.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ final class ImagenFileDataImageTests: XCTestCase {

XCTAssertEqual(image.mimeType, mimeType)
XCTAssertEqual(image.gcsURI, gcsURI)
XCTAssertEqual(image.imagenImage.mimeType, mimeType)
XCTAssertEqual(image.imagenImage.gcsURI, gcsURI)
XCTAssertNil(image.imagenImage.bytesBase64Encoded)
XCTAssertEqual(image._imagenImage.mimeType, mimeType)
XCTAssertEqual(image._imagenImage.gcsURI, gcsURI)
XCTAssertNil(image._imagenImage.bytesBase64Encoded)
}

func testDecodeImage_missingGCSURI_throws() throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ final class ImagenInlineDataImageTests: XCTestCase {

XCTAssertEqual(image.mimeType, mimeType)
XCTAssertEqual(image.data.base64EncodedString(), bytesBase64Encoded)
XCTAssertEqual(image.imagenImage.mimeType, mimeType)
XCTAssertEqual(image.imagenImage.bytesBase64Encoded, bytesBase64Encoded)
XCTAssertNil(image.imagenImage.gcsURI)
XCTAssertEqual(image._imagenImage.mimeType, mimeType)
XCTAssertEqual(image._imagenImage.bytesBase64Encoded, bytesBase64Encoded)
XCTAssertNil(image._imagenImage.gcsURI)
}

func testDecodeImage_missingBytesBase64Encoded_throws() throws {
Expand Down
Loading