Skip to content

Commit 627f679

Browse files
committed
Add support for GCS FileData upload in inference
1 parent dddb566 commit 627f679

File tree

3 files changed

+57
-8
lines changed

3 files changed

+57
-8
lines changed

packages/rules-unit-testing/functions/yarn.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
dependencies:
7979
tslib "^2.1.0"
8080

81-
"@google-cloud/firestore@^6.6.0":
81+
"@google-cloud/firestore@^6.8.0":
8282
version "6.8.0"
8383
resolved "https://registry.npmjs.org/@google-cloud/firestore/-/firestore-6.8.0.tgz#d8c852844c381afaf62592796606c10e178400b5"
8484
integrity sha512-JRpk06SmZXLGz0pNx1x7yU3YhkUXheKgH5hbDZ4kMsdhtfV5qPLJLRI4wv69K0cZorIk+zTMOwptue7hizo0eA==
@@ -803,10 +803,10 @@ finalhandler@~1.1.2:
803803
statuses "~1.5.0"
804804
unpipe "~1.0.0"
805805

806-
firebase-admin@11.10.1:
807-
version "11.10.1"
808-
resolved "https://registry.npmjs.org/firebase-admin/-/firebase-admin-11.10.1.tgz#5f0f83a44627e89938d350c5e4bbac76596c963e"
809-
integrity sha512-atv1E6GbuvcvWaD3eHwrjeP5dAVs+EaHEJhu9CThMzPY6In8QYDiUR6tq5SwGl4SdA/GcAU0nhwWc/FSJsAzfQ==
806+
firebase-admin@11.11.1:
807+
version "11.11.1"
808+
resolved "https://registry.npmjs.org/firebase-admin/-/firebase-admin-11.11.1.tgz#6712923de70d218c9f514d73005d976d03339605"
809+
integrity sha512-UyEbq+3u6jWzCYbUntv/HuJiTixwh36G1R9j0v71mSvGAx/YZEWEW7uSGLYxBYE6ckVRQoKMr40PYUEzrm/4dg==
810810
dependencies:
811811
"@fastify/busboy" "^1.2.1"
812812
"@firebase/database-compat" "^0.3.4"
@@ -817,7 +817,7 @@ [email protected]:
817817
node-forge "^1.3.1"
818818
uuid "^9.0.0"
819819
optionalDependencies:
820-
"@google-cloud/firestore" "^6.6.0"
820+
"@google-cloud/firestore" "^6.8.0"
821821
"@google-cloud/storage" "^6.9.5"
822822

823823

packages/vertexai/src/requests/request-helpers.test.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,33 @@ describe('request formatting methods', () => {
170170
],
171171
systemInstruction: { role: 'system', parts: [{ text: 'be excited' }] }
172172
});
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+
});
174201
});
175202
});

packages/vertexai/src/types/content.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export type Part =
3434
| TextPart
3535
| InlineDataPart
3636
| FunctionCallPart
37-
| FunctionResponsePart;
37+
| FunctionResponsePart
38+
| FileDataPart;
3839

3940
/**
4041
* Content part interface if the part represents a text string.
@@ -101,6 +102,18 @@ export interface FunctionResponsePart {
101102
functionResponse: FunctionResponse;
102103
}
103104

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+
104117
/**
105118
* A predicted [FunctionCall] returned from the model
106119
* that contains a string representing the [FunctionDeclaration.name]
@@ -137,3 +150,12 @@ export interface GenerativeContentBlob {
137150
*/
138151
data: string;
139152
}
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+
}

0 commit comments

Comments
 (0)