@@ -106,8 +106,8 @@ final class VertexAIAPITests: XCTestCase {
106
106
_ = try await genAI. generateContent ( [ str, UIImage ( ) , TextPart ( str) ] )
107
107
_ = try await genAI. generateContent ( str, UIImage ( ) , " def " , UIImage ( ) )
108
108
_ = 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 ( ) ) ] )
111
111
#elseif canImport(AppKit)
112
112
_ = try await genAI. generateContent ( NSImage ( ) )
113
113
_ = try await genAI. generateContent ( [ NSImage ( ) ] )
@@ -121,37 +121,25 @@ final class VertexAIAPITests: XCTestCase {
121
121
let _ = ModelContent ( parts: " Constant String " )
122
122
let _ = ModelContent ( parts: str)
123
123
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 " ) ] )
131
125
#if canImport(UIKit)
132
126
_ = ModelContent ( role: " user " , parts: UIImage ( ) )
133
127
_ = 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]`.
139
131
let representable2 : [ any PartsRepresentable ] = [ str, UIImage ( ) ]
140
132
_ = ModelContent ( parts: representable2)
141
- _ =
142
- ModelContent ( parts: [ str, UIImage ( ) , TextPart ( str) ] as [ any PartsRepresentable ] )
133
+ _ = ModelContent ( parts: [ str, UIImage ( ) , TextPart ( str) ] )
143
134
#elseif canImport(AppKit)
144
135
_ = ModelContent ( role: " user " , parts: NSImage ( ) )
145
136
_ = 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]`.
151
140
let representable2 : [ any PartsRepresentable ] = [ str, NSImage ( ) ]
152
141
_ = ModelContent ( parts: representable2)
153
- _ =
154
- ModelContent ( parts: [ str, NSImage ( ) , TextPart ( str) ] as [ any PartsRepresentable ] )
142
+ _ = ModelContent ( parts: [ str, NSImage ( ) , TextPart ( str) ] )
155
143
#endif
156
144
157
145
// countTokens API
@@ -160,8 +148,8 @@ final class VertexAIAPITests: XCTestCase {
160
148
let _: CountTokensResponse = try await genAI. countTokens ( " What color is the Sky? " ,
161
149
UIImage ( ) )
162
150
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 ( ) ) ,
165
153
] )
166
154
#endif
167
155
0 commit comments