Skip to content

Commit 1de1eae

Browse files
authored
Merge fad0613 into 97f80a8
2 parents 97f80a8 + fad0613 commit 1de1eae

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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)