Skip to content

Commit

Permalink
Upgrade Vertex Mock Responses to V5 (#8579)
Browse files Browse the repository at this point in the history
* Upgrade to mock responses v4

* Upgrade from v4 to v5 mock responses
  • Loading branch information
dlarocque authored Oct 16, 2024
1 parent 97f80a8 commit b5392d9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/vertexai/src/requests/response-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export function createEnhancedContentResponse(
* The Vertex AI backend omits default values.
* This causes the `index` property to be omitted from the first candidate in the
* response, since it has index 0, and 0 is a default value.
* See: https://github.com/firebase/firebase-js-sdk/issues/8566
*/
if (response.candidates && !response.candidates[0].hasOwnProperty('index')) {
response.candidates[0].index = 0;
Expand Down
4 changes: 3 additions & 1 deletion packages/vertexai/src/requests/stream-reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ export function aggregateResponses(
for (const response of responses) {
if (response.candidates) {
for (const candidate of response.candidates) {
const i = candidate.index;
// Index will be undefined if it's the first index (0), so we should use 0 if it's undefined.
// See: https://github.com/firebase/firebase-js-sdk/issues/8566
const i = candidate.index || 0;
if (!aggregatedResponse.candidates) {
aggregatedResponse.candidates = [];
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/update_vertexai_responses.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# This script replaces mock response files for Vertex AI unit tests with a fresh
# clone of the shared repository of Vertex AI test data.

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

Expand Down

0 comments on commit b5392d9

Please sign in to comment.