Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overwrite undefined candidate index #8577

Merged
merged 2 commits into from
Oct 16, 2024
Merged

Overwrite undefined candidate index #8577

merged 2 commits into from
Oct 16, 2024

Conversation

dlarocque
Copy link
Contributor

Fixes #8566

The backend omits the index for the first candidate, since 0 is a default value, and protos omit defaults. This causes tests to fail against the v4 mock responses, and aggregated responses will be malformed, since instead of response.candidate[0] = ... it ends up being response.candidate[undefined] = ....

@dlarocque dlarocque requested a review from hsubox76 October 16, 2024 19:06
@dlarocque dlarocque requested a review from a team as a code owner October 16, 2024 19:06
Copy link

changeset-bot bot commented Oct 16, 2024

⚠️ No Changeset found

Latest commit: dcf35e0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

Vertex AI Mock Responses Check ⚠️

A newer major version of the mock responses for Vertex AI unit tests is available. update_vertexai_responses.sh should be updated to clone the latest version of the responses: v5.0

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Oct 16, 2024

Size Report 1

Affected Products

  • @firebase/vertexai

    TypeBase (dc211c6)Merge (7b5ef92)Diff
    browser28.4 kB28.7 kB+364 B (+1.3%)
    main29.2 kB29.6 kB+364 B (+1.2%)
    module28.4 kB28.7 kB+364 B (+1.3%)
  • firebase

    TypeBase (dc211c6)Merge (7b5ef92)Diff
    firebase-vertexai.js22.0 kB22.2 kB+213 B (+1.0%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/jPZEoWTB6R.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Oct 16, 2024

Size Analysis Report 1

Affected Products

  • @firebase/vertexai

    • ChatSession

      Size

      TypeBase (dc211c6)Merge (7b5ef92)Diff
      size14.4 kB14.6 kB+142 B (+1.0%)
      size-with-ext-deps33.0 kB33.1 kB+141 B (+0.4%)

      Dependency

      TypeBase (dc211c6)Merge (7b5ef92)Diff
      functions

      21 dependencies

      addHelpers
      aggregateResponses
      assignRoleToPartsAndValidateSendMessageRequest
      buildFetchOptions
      constructRequest
      formatBlockErrorMessage
      formatNewContent
      generateContent
      generateContentStream
      generateResponseSequence
      getClientHeaders
      getFunctionCalls
      getHeaders
      getResponsePromise
      getResponseStream
      getText
      hadBadFinishReason
      makeRequest
      processStream
      registerVertex
      validateChatHistory

      22 dependencies

      addHelpers
      aggregateResponses
      assignRoleToPartsAndValidateSendMessageRequest
      buildFetchOptions
      constructRequest
      createEnhancedContentResponse
      formatBlockErrorMessage
      formatNewContent
      generateContent
      generateContentStream
      generateResponseSequence
      getClientHeaders
      getFunctionCalls
      getHeaders
      getResponsePromise
      getResponseStream
      getText
      hadBadFinishReason
      makeRequest
      processStream
      registerVertex
      validateChatHistory

      + createEnhancedContentResponse

    • GenerativeModel

      Size

      TypeBase (dc211c6)Merge (7b5ef92)Diff
      size16.9 kB17.1 kB+142 B (+0.8%)
      size-with-ext-deps35.5 kB35.6 kB+141 B (+0.4%)

      Dependency

      TypeBase (dc211c6)Merge (7b5ef92)Diff
      functions

      24 dependencies

      addHelpers
      aggregateResponses
      assignRoleToPartsAndValidateSendMessageRequest
      buildFetchOptions
      constructRequest
      countTokens
      formatBlockErrorMessage
      formatGenerateContentInput
      formatNewContent
      formatSystemInstruction
      generateContent
      generateContentStream
      generateResponseSequence
      getClientHeaders
      getFunctionCalls
      getHeaders
      getResponsePromise
      getResponseStream
      getText
      hadBadFinishReason
      makeRequest
      processStream
      registerVertex
      validateChatHistory

      25 dependencies

      addHelpers
      aggregateResponses
      assignRoleToPartsAndValidateSendMessageRequest
      buildFetchOptions
      constructRequest
      countTokens
      createEnhancedContentResponse
      formatBlockErrorMessage
      formatGenerateContentInput
      formatNewContent
      formatSystemInstruction
      generateContent
      generateContentStream
      generateResponseSequence
      getClientHeaders
      getFunctionCalls
      getHeaders
      getResponsePromise
      getResponseStream
      getText
      hadBadFinishReason
      makeRequest
      processStream
      registerVertex
      validateChatHistory

      + createEnhancedContentResponse

    • getGenerativeModel

      Size

      TypeBase (dc211c6)Merge (7b5ef92)Diff
      size17.1 kB17.2 kB+142 B (+0.8%)
      size-with-ext-deps35.6 kB35.8 kB+141 B (+0.4%)

      Dependency

      TypeBase (dc211c6)Merge (7b5ef92)Diff
      functions

      25 dependencies

      addHelpers
      aggregateResponses
      assignRoleToPartsAndValidateSendMessageRequest
      buildFetchOptions
      constructRequest
      countTokens
      formatBlockErrorMessage
      formatGenerateContentInput
      formatNewContent
      formatSystemInstruction
      generateContent
      generateContentStream
      generateResponseSequence
      getClientHeaders
      getFunctionCalls
      getGenerativeModel
      getHeaders
      getResponsePromise
      getResponseStream
      getText
      hadBadFinishReason
      makeRequest
      processStream
      registerVertex
      validateChatHistory

      26 dependencies

      addHelpers
      aggregateResponses
      assignRoleToPartsAndValidateSendMessageRequest
      buildFetchOptions
      constructRequest
      countTokens
      createEnhancedContentResponse
      formatBlockErrorMessage
      formatGenerateContentInput
      formatNewContent
      formatSystemInstruction
      generateContent
      generateContentStream
      generateResponseSequence
      getClientHeaders
      getFunctionCalls
      getGenerativeModel
      getHeaders
      getResponsePromise
      getResponseStream
      getText
      hadBadFinishReason
      makeRequest
      processStream
      registerVertex
      validateChatHistory

      + createEnhancedContentResponse

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/qFoP1Nq9GF.html

Copy link
Contributor

@hsubox76 hsubox76 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, two comments, a nit and a question.

packages/vertexai/src/requests/response-helpers.ts Outdated Show resolved Hide resolved
@@ -59,7 +59,7 @@ export async function generateContent(
requestOptions
);
const responseJson: GenerateContentResponse = await response.json();
const enhancedResponse = addHelpers(responseJson);
const enhancedResponse = createEnhancedContentResponse(responseJson);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you assign it to a named variable first here and in the other places to increase readability? That's fine with me, seems reasonable, just wondering.

Copy link
Contributor Author

@dlarocque dlarocque Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it improves readability only slightly. The main reason I like this style because it makes it easier to debug since I can step over and see the return value before returning to the calling function, and I can log the value before it's returned without having to move stuff around.

@dlarocque dlarocque merged commit 97f80a8 into v11 Oct 16, 2024
44 of 47 checks passed
@dlarocque dlarocque deleted the dl/vertex-undef-index branch October 16, 2024 21:20
hsubox76 added a commit that referenced this pull request Oct 17, 2024
* Add node engines fields specifying a minimum of 18 (#8457)

* Make memory lru gc the default (#8110)

* Make memory lru gc the default

* undo yarn.lock

* Make memory lru gc the default

* Fix tests

* V11 release removal of node-fetch and undici dependencies (#8492)

Our v11 release will require node 18+. Since fetch has been introduced in these node versions, we can remove our dependency on third party fetch implementations.

This change removes our usage of fetch variants undici and node-fetch for our node target builds and our CI tools.

* V11 - Remove functions node bundle (#8507)

With the removal of fetch we no long need to create a node bundle for functions. Instead the sourcebase may become isomorphic, so long as we remove the older node sources. And that's what the PR does!

* Initial changes for Vertex GA packaging (#8498)

* [Vertex GA] Rewrite Schema (#8479)

* [Vertex GA] Add new endpoint and error message. (#8497)

* [Vertex GA] Miscellaneous breaking changes for Vertex GA (#8514)

* Remove ES5 Support (#8509)

* Emit a module package file for functions ESM builds (#8517)

* Update API_NOT_ENABLED error for Vertex (#8549)

* Upgrade cjs bundles for storage and performance (#8557)

These should have been part of the bigger PR, but I missed these.

* Rollup JS files with rollup-typescript-plugin (#8503)

The rollup-typescript-plugin does not transpile JS files using the TS
compiler by default. This means that external dependencies that provide
JS bundles will not be transpiled to the target ES version specified in
the TypeScript config used by the plugin.

This resulted in one of our dependencies (https://github.com/jakearchibald/idb)
being included in the CDN bundles without being transpiled to
ES5 (the target ES version). Since this dependencies bundle uses
ES2018 syntax (object spread operator `{ ...x }`), this upgraded our CDN
bundles' minimum ES version requirement to ES2018 which isn't compatible with older browser versions.
To see the ES2018 syntax in one of the CDN bundles, see
https://www.gstatic.com/firebasejs/10.13.1/firebase-app.js and search for `...oldTraps`.

* Fix tsc errors in vertex tests (#8562)

* Make SafetySettings.method optional (#8567)

* Make SafetySettings.method optional

* Update API reports

---------

Co-authored-by: hsubox76 <[email protected]>

* [Vertex GA] Regenerate docs after Vertex GA changes (#8505)

* Close emulator file after download is complete (#8572)

* close file

* Add test:ci to end of test command in CI

* revert workflow file changes

* format

* rename vertexai package reference in a changeset (#8573)

* Missed one doc change from a PR (#8575)

* Overwrite undefined candidate index (#8577)

* Overwrite undefined candidate index

* Fix index overwrite condition to only be true when index is not a property

* Upgrade Vertex Mock Responses to V5 (#8579)

* Upgrade to mock responses v4

* Upgrade from v4 to v5 mock responses

---------

Co-authored-by: wu-hui <[email protected]>
Co-authored-by: DellaBitta <[email protected]>
Co-authored-by: Daniel La Rocque <[email protected]>
Co-authored-by: hsubox76 <[email protected]>
@firebase firebase locked and limited conversation to collaborators Nov 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants