@@ -19,9 +19,27 @@ enum ImageAPIMethod: String {
1919}
2020
2121@available ( iOS 15 . 0 , macOS 12 . 0 , macCatalyst 15 . 0 , tvOS 15 . 0 , watchOS 8 . 0 , * )
22- class TemplateGenerateImagesRequest : @ unchecked Sendable , GenerativeAIRequest {
23- typealias Response = ImagenGenerationResponse < ImagenInlineImage >
22+ struct TemplateImagenGenerationRequest < ImageType : ImagenImageRepresentable > : Sendable {
23+ typealias Response = ImagenGenerationResponse < ImageType >
2424
25+ let template : String
26+ let inputs : [ String : TemplateInput ]
27+ let projectID : String
28+ let apiConfig : APIConfig
29+ let options : RequestOptions
30+
31+ init ( template: String , inputs: [ String : TemplateInput ] , projectID: String ,
32+ apiConfig: APIConfig , options: RequestOptions ) {
33+ self . template = template
34+ self . inputs = inputs
35+ self . projectID = projectID
36+ self . apiConfig = apiConfig
37+ self . options = options
38+ }
39+ }
40+
41+ @available ( iOS 15 . 0 , macOS 12 . 0 , macCatalyst 15 . 0 , tvOS 15 . 0 , watchOS 8 . 0 , * )
42+ extension TemplateImagenGenerationRequest : GenerativeAIRequest where ImageType: Decodable {
2543 func getURL( ) throws -> URL {
2644 var urlString =
2745 " \( apiConfig. service. endpoint. rawValue) / \( apiConfig. version. rawValue) /projects/ \( projectID) "
@@ -34,24 +52,10 @@ class TemplateGenerateImagesRequest: @unchecked Sendable, GenerativeAIRequest {
3452 }
3553 return url
3654 }
55+ }
3756
38- let options : RequestOptions
39-
40- let apiConfig : APIConfig
41-
42- let template : String
43- let inputs : [ String : TemplateInput ]
44- let projectID : String
45-
46- init ( template: String , inputs: [ String : TemplateInput ] , projectID: String ,
47- apiConfig: APIConfig , options: RequestOptions ) {
48- self . apiConfig = apiConfig
49- self . options = options
50- self . template = template
51- self . inputs = inputs
52- self . projectID = projectID
53- }
54-
57+ @available ( iOS 15 . 0 , macOS 12 . 0 , macCatalyst 15 . 0 , tvOS 15 . 0 , watchOS 8 . 0 , * )
58+ extension TemplateImagenGenerationRequest : Encodable {
5559 enum CodingKeys : String , CodingKey {
5660 case inputs
5761 }
0 commit comments