@@ -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,25 @@ 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.
128- let _ = ModelContent (
129- parts: [ str, InlineDataPart ( data: Data ( ) , mimeType: " foo " ) ] as [ any PartsRepresentable ]
130- )
124+ let _ = ModelContent ( parts: [ str, InlineDataPart ( data: Data ( ) , mimeType: " foo " ) ] )
131125 #if canImport(UIKit)
132126 _ = ModelContent ( role: " user " , parts: UIImage ( ) )
133127 _ = 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.
128+ _ = ModelContent ( parts: [ str, UIImage ( ) ] )
129+ // Note: without explicitly specifying`: [any PartsRepresentable]` this will fail to compile
130+ // below with "Cannot convert value of type `[Any]` to expected type `[any Part]`.
139131 let representable2 : [ any PartsRepresentable ] = [ str, UIImage ( ) ]
140132 _ = ModelContent ( parts: representable2)
141- _ =
142- ModelContent ( parts: [ str, UIImage ( ) , TextPart ( str) ] as [ any PartsRepresentable ] )
133+ _ = ModelContent ( parts: [ str, UIImage ( ) , TextPart ( str) ] )
143134 #elseif canImport(AppKit)
144135 _ = ModelContent ( role: " user " , parts: NSImage ( ) )
145136 _ = 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.
137+ _ = ModelContent ( parts: [ str, NSImage ( ) ] )
138+ // Note: without explicitly specifying`: [any PartsRepresentable]` this will fail to compile
139+ // below with "Cannot convert value of type `[Any]` to expected type `[any Part]`.
151140 let representable2 : [ any PartsRepresentable ] = [ str, NSImage ( ) ]
152141 _ = ModelContent ( parts: representable2)
153- _ =
154- ModelContent ( parts: [ str, NSImage ( ) , TextPart ( str) ] as [ any PartsRepresentable ] )
142+ _ = ModelContent ( parts: [ str, NSImage ( ) , TextPart ( str) ] )
155143 #endif
156144
157145 // countTokens API
@@ -160,8 +148,8 @@ final class VertexAIAPITests: XCTestCase {
160148 let _: CountTokensResponse = try await genAI. countTokens ( " What color is the Sky? " ,
161149 UIImage ( ) )
162150 let _: CountTokensResponse = try await genAI. countTokens ( [
163- ModelContent ( " What color is the Sky? " , UIImage ( ) ) ,
164- ModelContent ( UIImage ( ) , " What color is the Sky? " , UIImage ( ) ) ,
151+ ModelContent ( parts : " What color is the Sky? " , UIImage ( ) ) ,
152+ ModelContent ( parts : UIImage ( ) , " What color is the Sky? " , UIImage ( ) ) ,
165153 ] )
166154 #endif
167155
0 commit comments