File tree Expand file tree Collapse file tree 2 files changed +51
-2
lines changed Expand file tree Collapse file tree 2 files changed +51
-2
lines changed Original file line number Diff line number Diff line change @@ -170,6 +170,33 @@ describe('request formatting methods', () => {
170
170
] ,
171
171
systemInstruction : { role : 'system' , parts : [ { text : 'be excited' } ] }
172
172
} ) ;
173
- } ) ;
173
+ } ) ,
174
+ it ( 'formats fileData as part if provided as part' , ( ) => {
175
+ const result = formatGenerateContentInput ( [
176
+ 'What is this?' ,
177
+ {
178
+ fileData : {
179
+ mimeType : 'image/jpeg' ,
180
+ fileUri : 'gs://sample.appspot.com/image.jpeg'
181
+ }
182
+ }
183
+ ] ) ;
184
+ expect ( result ) . to . be . deep . equal ( {
185
+ contents : [
186
+ {
187
+ role : 'user' ,
188
+ parts : [
189
+ {
190
+ fileData : {
191
+ mimeType : 'image/jpeg' ,
192
+ fileUri : 'gs://sample.appspot.com/image.jpeg'
193
+ }
194
+ } ,
195
+ { text : 'What is this?' }
196
+ ]
197
+ }
198
+ ]
199
+ } ) ;
200
+ } ) ;
174
201
} ) ;
175
202
} ) ;
Original file line number Diff line number Diff line change @@ -34,7 +34,8 @@ export type Part =
34
34
| TextPart
35
35
| InlineDataPart
36
36
| FunctionCallPart
37
- | FunctionResponsePart ;
37
+ | FunctionResponsePart
38
+ | FileDataPart ;
38
39
39
40
/**
40
41
* Content part interface if the part represents a text string.
@@ -101,6 +102,18 @@ export interface FunctionResponsePart {
101
102
functionResponse : FunctionResponse ;
102
103
}
103
104
105
+ /**
106
+ * Content part interface if the part represents {@link FileData}
107
+ * @public
108
+ */
109
+ export interface FileDataPart {
110
+ text ?: never ;
111
+ inlineData ?: never ;
112
+ functionCall ?: never ;
113
+ functionResponse ?: never ;
114
+ fileData : FileData ;
115
+ }
116
+
104
117
/**
105
118
* A predicted [FunctionCall] returned from the model
106
119
* that contains a string representing the [FunctionDeclaration.name]
@@ -137,3 +150,12 @@ export interface GenerativeContentBlob {
137
150
*/
138
151
data : string ;
139
152
}
153
+
154
+ /**
155
+ * Data pointing to a file uploaded on Google Cloud Storage.
156
+ * @public
157
+ */
158
+ export interface FileData {
159
+ mimeType : string ;
160
+ fileUri : string ;
161
+ }
You can’t perform that action at this time.
0 commit comments