@@ -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
@@ -72,6 +91,13 @@ public struct ModelContent: Codable, Equatable {
72
91
)
73
92
try inlineDataContainer. encode ( mimetype, forKey: . mimeType)
74
93
try inlineDataContainer. encode ( bytes, forKey: . bytes)
94
+ case let . fileData( mimetype: mimetype, url) :
95
+ var fileDataContainer = container. nestedContainer (
96
+ keyedBy: FileDataKeys . self,
97
+ forKey: . fileData
98
+ )
99
+ try fileDataContainer. encode ( mimetype, forKey: . mimeType)
100
+ try fileDataContainer. encode ( url, forKey: . url)
75
101
case let . functionCall( functionCall) :
76
102
try container. encode ( functionCall, forKey: . functionCall)
77
103
case let . functionResponse( functionResponse) :
0 commit comments