Skip to content

Commit b5392d9

Browse files
authored
Upgrade Vertex Mock Responses to V5 (#8579)
* Upgrade to mock responses v4 * Upgrade from v4 to v5 mock responses
1 parent 97f80a8 commit b5392d9

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

packages/vertexai/src/requests/response-helpers.ts

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export function createEnhancedContentResponse(
3636
* The Vertex AI backend omits default values.
3737
* This causes the `index` property to be omitted from the first candidate in the
3838
* response, since it has index 0, and 0 is a default value.
39+
* See: https://github.com/firebase/firebase-js-sdk/issues/8566
3940
*/
4041
if (response.candidates && !response.candidates[0].hasOwnProperty('index')) {
4142
response.candidates[0].index = 0;

packages/vertexai/src/requests/stream-reader.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ export function aggregateResponses(
151151
for (const response of responses) {
152152
if (response.candidates) {
153153
for (const candidate of response.candidates) {
154-
const i = candidate.index;
154+
// Index will be undefined if it's the first index (0), so we should use 0 if it's undefined.
155+
// See: https://github.com/firebase/firebase-js-sdk/issues/8566
156+
const i = candidate.index || 0;
155157
if (!aggregatedResponse.candidates) {
156158
aggregatedResponse.candidates = [];
157159
}

scripts/update_vertexai_responses.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# This script replaces mock response files for Vertex AI unit tests with a fresh
1818
# clone of the shared repository of Vertex AI test data.
1919

20-
RESPONSES_VERSION='v3.*' # The major version of mock responses to use
20+
RESPONSES_VERSION='v5.*' # The major version of mock responses to use
2121
REPO_NAME="vertexai-sdk-test-data"
2222
REPO_LINK="https://github.com/FirebaseExtended/$REPO_NAME.git"
2323

0 commit comments

Comments
 (0)