Skip to content

VinF Hybrid Inference #1: Update the API #8874

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

Open
wants to merge 17 commits into
base: vertexai-hybridinference-integration
Choose a base branch
from

Conversation

erikeldridge
Copy link

This change updates the getGenerativeModel getter to accept ModelParams or HybridParams. The HybridParams.mode field indicates whether hybrid inference is intended.

This change just updates the inputs. All existing tests pass, so the diff should be relatively easy to understand. The next change will use the inputs.

@erikeldridge erikeldridge requested a review from hsubox76 March 27, 2025 17:35
@erikeldridge erikeldridge requested a review from a team as a code owner March 27, 2025 17:35
Copy link

changeset-bot bot commented Mar 27, 2025

⚠️ No Changeset found

Latest commit: 3ec2857

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

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Mar 27, 2025

Size Report 1

Affected Products

  • @firebase/vertexai

    TypeBase (dcc62c0)Merge (a63dbe4)Diff
    browser34.7 kB35.0 kB+272 B (+0.8%)
    main35.7 kB36.0 kB+272 B (+0.8%)
    module34.7 kB35.0 kB+272 B (+0.8%)
  • firebase

    TypeBase (dcc62c0)Merge (a63dbe4)Diff
    firebase-vertexai.js28.3 kB28.4 kB+168 B (+0.6%)

Test Logs

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

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Mar 27, 2025

Size Analysis Report 1

Affected Products

  • @firebase/vertexai

    • GenerativeModel

      Size

      TypeBase (dcc62c0)Merge (a63dbe4)Diff
      size18.9 kB19.0 kB+57 B (+0.3%)
      size-with-ext-deps37.9 kB37.9 kB+57 B (+0.2%)
    • ImagenModel

      Size

      TypeBase (dcc62c0)Merge (a63dbe4)Diff
      size10.1 kB20.7 kB+10.6 kB (+105.8%)
      size-with-ext-deps28.1 kB39.7 kB+11.6 kB (+41.5%)

      Dependency

      TypeBase (dcc62c0)Merge (a63dbe4)Diff
      functions

      constructRequest
      createPredictRequestBody
      getClientHeaders
      getHeaders
      handlePredictResponse
      makeRequest
      registerVertex

      26 dependencies

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

      19 dependency diffs

      + addHelpers
      + aggregateResponses
      + assignRoleToPartsAndValidateSendMessageRequest
      + countTokens
      + createEnhancedContentResponse
      + formatBlockErrorMessage
      + formatGenerateContentInput
      + formatNewContent
      + formatSystemInstruction
      + generateContent
      + generateContentStream
      + generateResponseSequence
      + getFunctionCalls
      + getResponsePromise
      + getResponseStream
      + getText
      + hadBadFinishReason
      + processStream
      + validateChatHistory

      classes

      ImagenModel
      RequestUrl
      VertexAIError
      VertexAIModel
      VertexAIService

      ChatSession
      GenerativeModel
      ImagenModel
      RequestUrl
      VertexAIError
      VertexAIModel
      VertexAIService

      + ChatSession
      + GenerativeModel

      variables

      24 dependencies

      BlockReason
      DEFAULT_API_VERSION
      DEFAULT_BASE_URL
      DEFAULT_FETCH_TIMEOUT_MS
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      ImagenAspectRatio
      ImagenPersonFilterLevel
      ImagenSafetyFilterLevel
      LANGUAGE_TAG
      Modality
      PACKAGE_VERSION
      SchemaType
      Task
      VERTEX_TYPE
      logger
      name
      version

      31 dependencies

      BlockReason
      DEFAULT_API_VERSION
      DEFAULT_BASE_URL
      DEFAULT_FETCH_TIMEOUT_MS
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      ImagenAspectRatio
      ImagenPersonFilterLevel
      ImagenSafetyFilterLevel
      LANGUAGE_TAG
      Modality
      PACKAGE_VERSION
      POSSIBLE_ROLES
      SILENT_ERROR
      SchemaType
      Task
      VALID_PARTS_PER_ROLE
      VALID_PART_FIELDS
      VALID_PREVIOUS_CONTENT_ROLES
      VERTEX_TYPE
      badFinishReasons
      logger
      name
      responseLineRE
      version

      + POSSIBLE_ROLES
      + SILENT_ERROR
      + VALID_PARTS_PER_ROLE
      + VALID_PART_FIELDS
      + VALID_PREVIOUS_CONTENT_ROLES
      + badFinishReasons
      + responseLineRE

      External Dependency

      ModuleBase (dcc62c0)Merge (a63dbe4)Diff
      tslib

      __asyncGenerator
      __await

      + __asyncGenerator
      + __await

    • VertexAIModel

      Size

      TypeBase (dcc62c0)Merge (a63dbe4)Diff
      size5.23 kB19.0 kB+13.7 kB (+262.6%)
      size-with-ext-deps23.2 kB37.9 kB+14.8 kB (+63.7%)

      Dependency

      TypeBase (dcc62c0)Merge (a63dbe4)Diff
      functions

      registerVertex

      24 dependencies

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

      23 dependency diffs

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

      classes

      VertexAIError
      VertexAIModel
      VertexAIService

      ChatSession
      GenerativeModel
      RequestUrl
      VertexAIError
      VertexAIModel
      VertexAIService

      + ChatSession
      + GenerativeModel
      + RequestUrl

      variables

      18 dependencies

      BlockReason
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      ImagenAspectRatio
      ImagenPersonFilterLevel
      ImagenSafetyFilterLevel
      Modality
      SchemaType
      Task
      VERTEX_TYPE
      name
      version

      31 dependencies

      BlockReason
      DEFAULT_API_VERSION
      DEFAULT_BASE_URL
      DEFAULT_FETCH_TIMEOUT_MS
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      ImagenAspectRatio
      ImagenPersonFilterLevel
      ImagenSafetyFilterLevel
      LANGUAGE_TAG
      Modality
      PACKAGE_VERSION
      POSSIBLE_ROLES
      SILENT_ERROR
      SchemaType
      Task
      VALID_PARTS_PER_ROLE
      VALID_PART_FIELDS
      VALID_PREVIOUS_CONTENT_ROLES
      VERTEX_TYPE
      badFinishReasons
      logger
      name
      responseLineRE
      version

      13 dependency diffs

      + DEFAULT_API_VERSION
      + DEFAULT_BASE_URL
      + DEFAULT_FETCH_TIMEOUT_MS
      + LANGUAGE_TAG
      + PACKAGE_VERSION
      + POSSIBLE_ROLES
      + SILENT_ERROR
      + VALID_PARTS_PER_ROLE
      + VALID_PART_FIELDS
      + VALID_PREVIOUS_CONTENT_ROLES
      + badFinishReasons
      + logger
      + responseLineRE

      External Dependency

      ModuleBase (dcc62c0)Merge (a63dbe4)Diff
      tslib

      __asyncGenerator
      __await

      + __asyncGenerator
      + __await

    • getGenerativeModel

      Size

      TypeBase (dcc62c0)Merge (a63dbe4)Diff
      size19.1 kB19.2 kB+153 B (+0.8%)
      size-with-ext-deps38.1 kB38.2 kB+153 B (+0.4%)
    • getImagenModel

      Size

      TypeBase (dcc62c0)Merge (a63dbe4)Diff
      size10.2 kB20.9 kB+10.7 kB (+104.1%)
      size-with-ext-deps28.2 kB39.9 kB+11.6 kB (+41.3%)

      Dependency

      TypeBase (dcc62c0)Merge (a63dbe4)Diff
      functions

      constructRequest
      createPredictRequestBody
      getClientHeaders
      getHeaders
      getImagenModel
      handlePredictResponse
      makeRequest
      registerVertex

      27 dependencies

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

      19 dependency diffs

      + addHelpers
      + aggregateResponses
      + assignRoleToPartsAndValidateSendMessageRequest
      + countTokens
      + createEnhancedContentResponse
      + formatBlockErrorMessage
      + formatGenerateContentInput
      + formatNewContent
      + formatSystemInstruction
      + generateContent
      + generateContentStream
      + generateResponseSequence
      + getFunctionCalls
      + getResponsePromise
      + getResponseStream
      + getText
      + hadBadFinishReason
      + processStream
      + validateChatHistory

      classes

      ImagenModel
      RequestUrl
      VertexAIError
      VertexAIModel
      VertexAIService

      ChatSession
      GenerativeModel
      ImagenModel
      RequestUrl
      VertexAIError
      VertexAIModel
      VertexAIService

      + ChatSession
      + GenerativeModel

      variables

      24 dependencies

      BlockReason
      DEFAULT_API_VERSION
      DEFAULT_BASE_URL
      DEFAULT_FETCH_TIMEOUT_MS
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      ImagenAspectRatio
      ImagenPersonFilterLevel
      ImagenSafetyFilterLevel
      LANGUAGE_TAG
      Modality
      PACKAGE_VERSION
      SchemaType
      Task
      VERTEX_TYPE
      logger
      name
      version

      31 dependencies

      BlockReason
      DEFAULT_API_VERSION
      DEFAULT_BASE_URL
      DEFAULT_FETCH_TIMEOUT_MS
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      ImagenAspectRatio
      ImagenPersonFilterLevel
      ImagenSafetyFilterLevel
      LANGUAGE_TAG
      Modality
      PACKAGE_VERSION
      POSSIBLE_ROLES
      SILENT_ERROR
      SchemaType
      Task
      VALID_PARTS_PER_ROLE
      VALID_PART_FIELDS
      VALID_PREVIOUS_CONTENT_ROLES
      VERTEX_TYPE
      badFinishReasons
      logger
      name
      responseLineRE
      version

      + POSSIBLE_ROLES
      + SILENT_ERROR
      + VALID_PARTS_PER_ROLE
      + VALID_PART_FIELDS
      + VALID_PREVIOUS_CONTENT_ROLES
      + badFinishReasons
      + responseLineRE

      External Dependency

      ModuleBase (dcc62c0)Merge (a63dbe4)Diff
      tslib

      __asyncGenerator
      __await

      + __asyncGenerator
      + __await

Test Logs

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

Copy link
Contributor

github-actions bot commented Apr 3, 2025

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: v8.0

@@ -3,7 +3,8 @@
"strict": true,
"outDir": "dist",
"lib": [
"ESNext"
"ESNext",
"dom"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this file changed?

Copy link
Author

Choose a reason for hiding this comment

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

Without this, adding the @types/dom-chromium-ai dependency causes the postsubmit script to fail. I'll try reproing the issue on a stand-alone branch.

Copy link
Author

Choose a reason for hiding this comment

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

Created PR #8916 to repro in CI env.

@@ -213,3 +213,28 @@ export interface FunctionCallingConfig {
mode?: FunctionCallingMode;
allowedFunctionNames?: string[];
}

/**
* Toggles hybrid inference.
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add the @public tag here and in other JSDoc comments for public APIs?

/**
* Defines the name of the default in-cloud model to use for hybrid inference.
*/
static DEFAULT_HYBRID_IN_CLOUD_MODEL = 'gemini-2.0-flash-lite';
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we avoid defining a default model? If this model string is deprecated in the future, and a user is using an old version of the SDK, would using this default result in an error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants