@@ -106,8 +106,8 @@ final class VertexAIAPITests: XCTestCase {
106106 _ = try await genAI. generateContent ( [ str, UIImage ( ) , TextPart ( str) ] )
107107 _ = try await genAI. generateContent ( str, UIImage ( ) , " def " , UIImage ( ) )
108108 _ = try await genAI. generateContent ( [ str, UIImage ( ) , " def " , UIImage ( ) ] )
109- _ = try await genAI. generateContent ( [ ModelContent ( " def " , UIImage ( ) ) ,
110- ModelContent ( " def " , UIImage ( ) ) ] )
109+ _ = try await genAI. generateContent ( [ ModelContent ( parts : " def " , UIImage ( ) ) ,
110+ ModelContent ( parts : " def " , UIImage ( ) ) ] )
111111 #elseif canImport(AppKit)
112112 _ = try await genAI. generateContent ( NSImage ( ) )
113113 _ = try await genAI. generateContent ( [ NSImage ( ) ] )
@@ -121,37 +121,31 @@ final class VertexAIAPITests: XCTestCase {
121121 let _ = ModelContent ( parts: " Constant String " )
122122 let _ = ModelContent ( parts: str)
123123 let _ = ModelContent ( parts: [ str] )
124- // Note: without `as [any PartsRepresentable]` this will fail to compile with "Cannot
125- // convert value of type 'String' to expected element type
126- // 'Array<Part>.ArrayLiteralElement'. Not sure if there's a way we can get it to
127- // work.
128124 let _ = ModelContent (
129- parts: [ str, InlineDataPart ( data: Data ( ) , mimeType: " foo " ) ] as [ any PartsRepresentable ]
125+ parts: [ str, InlineDataPart ( inlineData: InlineData (
126+ mimeType: " foo " ,
127+ data: Data ( )
128+ ) ) ]
130129 )
131130 #if canImport(UIKit)
132131 _ = ModelContent ( role: " user " , parts: UIImage ( ) )
133132 _ = ModelContent ( role: " user " , parts: [ UIImage ( ) ] )
134- // Note: without `as [any PartsRepresentable]` this will fail to compile with "Cannot convert
135- // value of type `[Any]` to expected type `[any PartsRepresentable]`. Not sure if there's a
136- // way we can get it to work.
137- _ = ModelContent ( parts: [ str, UIImage ( ) ] as [ any PartsRepresentable ] )
138- // Alternatively, you can explicitly declare the type in a variable and pass it in.
133+ _ = ModelContent ( parts: [ str, UIImage ( ) ] )
134+ // Note: without explicitly specifying`: [any PartsRepresentable]` this will fail to compile
135+ // below with "Cannot convert value of type `[Any]` to expected type `[any Part]`.
139136 let representable2 : [ any PartsRepresentable ] = [ str, UIImage ( ) ]
140137 _ = ModelContent ( parts: representable2)
141- _ =
142- ModelContent ( parts: [ str, UIImage ( ) , TextPart ( str) ] as [ any PartsRepresentable ] )
138+ _ = ModelContent ( parts: [ str, UIImage ( ) , TextPart ( str) ] )
143139 #elseif canImport(AppKit)
144140 _ = ModelContent ( role: " user " , parts: NSImage ( ) )
145141 _ = ModelContent ( role: " user " , parts: [ NSImage ( ) ] )
146- // Note: without `as [any PartsRepresentable]` this will fail to compile with "Cannot convert
147- // value of type `[Any]` to expected type `[any PartsRepresentable]`. Not sure if there's a
148- // way we can get it to work.
149- _ = ModelContent ( parts: [ str, NSImage ( ) ] as [ any PartsRepresentable ] )
150- // Alternatively, you can explicitly declare the type in a variable and pass it in.
142+ _ = ModelContent ( parts: [ str, NSImage ( ) ] )
143+ // Note: without explicitly specifying`: [any PartsRepresentable]` this will fail to compile
144+ // below with "Cannot convert value of type `[Any]` to expected type `[any Part]`.
151145 let representable2 : [ any PartsRepresentable ] = [ str, NSImage ( ) ]
152146 _ = ModelContent ( parts: representable2)
153147 _ =
154- ModelContent ( parts: [ str, NSImage ( ) , TextPart ( str) ] as [ any PartsRepresentable ] )
148+ ModelContent ( parts: [ str, NSImage ( ) , TextPart ( str) ] )
155149 #endif
156150
157151 // countTokens API
@@ -160,8 +154,8 @@ final class VertexAIAPITests: XCTestCase {
160154 let _: CountTokensResponse = try await genAI. countTokens ( " What color is the Sky? " ,
161155 UIImage ( ) )
162156 let _: CountTokensResponse = try await genAI. countTokens ( [
163- ModelContent ( " What color is the Sky? " , UIImage ( ) ) ,
164- ModelContent ( UIImage ( ) , " What color is the Sky? " , UIImage ( ) ) ,
157+ ModelContent ( parts : " What color is the Sky? " , UIImage ( ) ) ,
158+ ModelContent ( parts : UIImage ( ) , " What color is the Sky? " , UIImage ( ) ) ,
165159 ] )
166160 #endif
167161
0 commit comments