@@ -25,6 +25,7 @@ public struct ModelContent: Codable, Equatable {
25
25
enum CodingKeys : String , CodingKey {
26
26
case text
27
27
case inlineData
28
+ case fileData
28
29
case functionCall
29
30
case functionResponse
30
31
}
@@ -34,12 +35,30 @@ public struct ModelContent: Codable, Equatable {
34
35
case bytes = " data "
35
36
}
36
37
38
+ enum FileDataKeys : String , CodingKey {
39
+ case mimeType = " mime_type "
40
+ case url = " file_uri "
41
+ }
42
+
37
43
/// Text value.
38
44
case text( String )
39
45
40
- /// Data with a specified media type. Not all media types may be supported by the AI model.
46
+ /// Data with a specified media type.
47
+ ///
48
+ /// > Note: Supported media types depends on the model; see
49
+ /// > [supported file
50
+ /// > formats](https://ai.google.dev/tutorials/prompting_with_media#supported_file_formats)
51
+ /// > for details.
41
52
case data( mimetype: String , Data )
42
53
54
+ /// URI-based data with a specified media type.
55
+ ///
56
+ /// > Note: Supported media types depends on the model; see
57
+ /// > [supported file
58
+ /// > formats](https://ai.google.dev/tutorials/prompting_with_media#supported_file_formats)
59
+ /// > for details.
60
+ case fileData( mimetype: String , uri: String )
61
+
43
62
/// A predicted function call returned from the model.
44
63
case functionCall( FunctionCall )
45
64
@@ -71,6 +90,13 @@ public struct ModelContent: Codable, Equatable {
71
90
)
72
91
try inlineDataContainer. encode ( mimetype, forKey: . mimeType)
73
92
try inlineDataContainer. encode ( bytes, forKey: . bytes)
93
+ case let . fileData( mimetype: mimetype, url) :
94
+ var fileDataContainer = container. nestedContainer (
95
+ keyedBy: FileDataKeys . self,
96
+ forKey: . fileData
97
+ )
98
+ try fileDataContainer. encode ( mimetype, forKey: . mimeType)
99
+ try fileDataContainer. encode ( url, forKey: . url)
74
100
case let . functionCall( functionCall) :
75
101
try container. encode ( functionCall, forKey: . functionCall)
76
102
case let . functionResponse( functionResponse) :
0 commit comments