Skip to content

[Firebase AI] Add thought summary and signature support #9192

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 6 commits into
base: main
Choose a base branch
from

Conversation

andrewheard
Copy link

@andrewheard andrewheard commented Aug 1, 2025

Added support for including thought summaries and thought signatures.

Edits by @hsubox76:

  • thoughtSignature is not meant to be exposed publicly but needs to be stored in chat history, so it's marked internal to keep it out of public typings and docs, but still exists in the type so it can be used in chat validation and testing
  • consolidated some duplicate logic in addHelpers()
  • Filled in previously missing description for functionCalls() method

Copy link

changeset-bot bot commented Aug 1, 2025

🦋 Changeset detected

Latest commit: 2a82810

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@firebase/ai Minor
firebase Minor

Not sure what this means? Click here to learn what changesets are.

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

@andrewheard
Copy link
Author

cc: @dlarocque

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Aug 12, 2025

Size Report 1

Affected Products

  • @firebase/ai

    TypeBase (cc605e7)Merge (3534ab4)Diff
    browser45.8 kB45.5 kB-343 B (-0.7%)
    main48.9 kB48.6 kB-343 B (-0.7%)
    module45.8 kB45.5 kB-343 B (-0.7%)
  • @firebase/functions

    TypeBase (cc605e7)Merge (3534ab4)Diff
    browser13.9 kB14.2 kB+297 B (+2.1%)
    main14.4 kB14.7 kB+302 B (+2.1%)
    module13.9 kB14.2 kB+297 B (+2.1%)
  • bundle

    TypeBase (cc605e7)Merge (3534ab4)Diff
    functions (call)38.6 kB38.7 kB+132 B (+0.3%)
  • firebase

    TypeBase (cc605e7)Merge (3534ab4)Diff
    firebase-ai.js35.8 kB35.4 kB-359 B (-1.0%)
    firebase-compat.js800 kB800 kB+130 B (+0.0%)
    firebase-functions-compat.js14.7 kB14.8 kB+126 B (+0.9%)
    firebase-functions.js19.4 kB19.5 kB+182 B (+0.9%)

Test Logs

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

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Aug 12, 2025

Size Analysis Report 1

Affected Products

  • @firebase/ai

    • ChatSession

      Size

      TypeBase (cc605e7)Merge (3534ab4)Diff
      size17.4 kB17.0 kB-370 B (-2.1%)
      size-with-ext-deps35.1 kB34.7 kB-373 B (-1.1%)

      Dependency

      TypeBase (cc605e7)Merge (3534ab4)Diff
      functions

      30 dependencies

      addHelpers
      aggregateResponses
      assignRoleToPartsAndValidateSendMessageRequest
      constructRequest
      createEnhancedContentResponse
      decodeInstanceIdentifier
      formatBlockErrorMessage
      formatNewContent
      generateContent
      generateContentOnCloud
      generateContentStream
      generateContentStreamOnCloud
      generateResponseSequence
      getClientHeaders
      getFunctionCalls
      getHeaders
      getInlineDataParts
      getResponsePromise
      getResponseStream
      getText
      hadBadFinishReason
      makeRequest
      mapGenerateContentCandidates
      mapGenerateContentRequest
      mapGenerateContentResponse
      mapPromptFeedback
      processGenerateContentResponse
      processStream
      registerAI
      validateChatHistory

      31 dependencies

      addHelpers
      aggregateResponses
      assignRoleToPartsAndValidateSendMessageRequest
      constructRequest
      createEnhancedContentResponse
      decodeInstanceIdentifier
      formatBlockErrorMessage
      formatNewContent
      generateContent
      generateContentOnCloud
      generateContentStream
      generateContentStreamOnCloud
      generateResponseSequence
      getClientHeaders
      getFunctionCalls
      getHeaders
      getInlineDataParts
      getResponsePromise
      getResponseStream
      getText
      hadBadFinishReason
      hasValidCandidates
      makeRequest
      mapGenerateContentCandidates
      mapGenerateContentRequest
      mapGenerateContentResponse
      mapPromptFeedback
      processGenerateContentResponse
      processStream
      registerAI
      validateChatHistory

      + hasValidCandidates

    • GenerativeModel

      Size

      TypeBase (cc605e7)Merge (3534ab4)Diff
      size20.9 kB20.6 kB-370 B (-1.8%)
      size-with-ext-deps38.7 kB38.3 kB-373 B (-1.0%)

      Dependency

      TypeBase (cc605e7)Merge (3534ab4)Diff
      functions

      35 dependencies

      addHelpers
      aggregateResponses
      assignRoleToPartsAndValidateSendMessageRequest
      constructRequest
      countTokens
      countTokensOnCloud
      createEnhancedContentResponse
      decodeInstanceIdentifier
      formatBlockErrorMessage
      formatGenerateContentInput
      formatNewContent
      formatSystemInstruction
      generateContent
      generateContentOnCloud
      generateContentStream
      generateContentStreamOnCloud
      generateResponseSequence
      getClientHeaders
      getFunctionCalls
      getHeaders
      getInlineDataParts
      getResponsePromise
      getResponseStream
      getText
      hadBadFinishReason
      makeRequest
      mapCountTokensRequest
      mapGenerateContentCandidates
      mapGenerateContentRequest
      mapGenerateContentResponse
      mapPromptFeedback
      processGenerateContentResponse
      processStream
      registerAI
      validateChatHistory

      36 dependencies

      addHelpers
      aggregateResponses
      assignRoleToPartsAndValidateSendMessageRequest
      constructRequest
      countTokens
      countTokensOnCloud
      createEnhancedContentResponse
      decodeInstanceIdentifier
      formatBlockErrorMessage
      formatGenerateContentInput
      formatNewContent
      formatSystemInstruction
      generateContent
      generateContentOnCloud
      generateContentStream
      generateContentStreamOnCloud
      generateResponseSequence
      getClientHeaders
      getFunctionCalls
      getHeaders
      getInlineDataParts
      getResponsePromise
      getResponseStream
      getText
      hadBadFinishReason
      hasValidCandidates
      makeRequest
      mapCountTokensRequest
      mapGenerateContentCandidates
      mapGenerateContentRequest
      mapGenerateContentResponse
      mapPromptFeedback
      processGenerateContentResponse
      processStream
      registerAI
      validateChatHistory

      + hasValidCandidates

    • getGenerativeModel

      Size

      TypeBase (cc605e7)Merge (3534ab4)Diff
      size25.1 kB24.7 kB-370 B (-1.5%)
      size-with-ext-deps42.9 kB42.5 kB-373 B (-0.9%)

      Dependency

      TypeBase (cc605e7)Merge (3534ab4)Diff
      functions

      36 dependencies

      addHelpers
      aggregateResponses
      assignRoleToPartsAndValidateSendMessageRequest
      constructRequest
      countTokens
      countTokensOnCloud
      createEnhancedContentResponse
      decodeInstanceIdentifier
      formatBlockErrorMessage
      formatGenerateContentInput
      formatNewContent
      formatSystemInstruction
      generateContent
      generateContentOnCloud
      generateContentStream
      generateContentStreamOnCloud
      generateResponseSequence
      getClientHeaders
      getFunctionCalls
      getGenerativeModel
      getHeaders
      getInlineDataParts
      getResponsePromise
      getResponseStream
      getText
      hadBadFinishReason
      makeRequest
      mapCountTokensRequest
      mapGenerateContentCandidates
      mapGenerateContentRequest
      mapGenerateContentResponse
      mapPromptFeedback
      processGenerateContentResponse
      processStream
      registerAI
      validateChatHistory

      37 dependencies

      addHelpers
      aggregateResponses
      assignRoleToPartsAndValidateSendMessageRequest
      constructRequest
      countTokens
      countTokensOnCloud
      createEnhancedContentResponse
      decodeInstanceIdentifier
      formatBlockErrorMessage
      formatGenerateContentInput
      formatNewContent
      formatSystemInstruction
      generateContent
      generateContentOnCloud
      generateContentStream
      generateContentStreamOnCloud
      generateResponseSequence
      getClientHeaders
      getFunctionCalls
      getGenerativeModel
      getHeaders
      getInlineDataParts
      getResponsePromise
      getResponseStream
      getText
      hadBadFinishReason
      hasValidCandidates
      makeRequest
      mapCountTokensRequest
      mapGenerateContentCandidates
      mapGenerateContentRequest
      mapGenerateContentResponse
      mapPromptFeedback
      processGenerateContentResponse
      processStream
      registerAI
      validateChatHistory

      + hasValidCandidates

  • @firebase/functions

    • connectFunctionsEmulator

      Size

      TypeBase (cc605e7)Merge (3534ab4)Diff
      size2.84 kB2.85 kB+12 B (+0.4%)
      size-with-ext-deps25.0 kB25.1 kB+12 B (+0.0%)
    • getFunctions

      Size

      TypeBase (cc605e7)Merge (3534ab4)Diff
      size3.03 kB3.04 kB+12 B (+0.4%)
      size-with-ext-deps32.6 kB32.6 kB+12 B (+0.0%)
    • httpsCallable

      Size

      TypeBase (cc605e7)Merge (3534ab4)Diff
      size8.48 kB8.62 kB+141 B (+1.7%)
      size-with-ext-deps26.2 kB26.5 kB+284 B (+1.1%)

      Dependency

      TypeBase (cc605e7)Merge (3534ab4)Diff
      functions

      16 dependencies

      _errorForResponse
      call
      callAtURL
      codeForHTTPStatus
      createResponseStream
      decode
      encode
      failAfter
      httpsCallable
      httpsCallable$1
      makeAuthHeaders
      mapValues
      postJSON
      registerFunctions
      stream
      streamAtURL

      17 dependencies

      _errorForResponse
      call
      callAtURL
      codeForHTTPStatus
      createResponseStream
      decode
      encode
      failAfter
      getCredentials
      httpsCallable
      httpsCallable$1
      makeAuthHeaders
      mapValues
      postJSON
      registerFunctions
      stream
      streamAtURL

      + getCredentials

      External Dependency

      ModuleBase (cc605e7)Merge (3534ab4)Diff
      @firebase/util

      FirebaseError
      getModularInstance

      FirebaseError
      getModularInstance
      isCloudWorkstation

      + isCloudWorkstation

    • httpsCallableFromURL

      Size

      TypeBase (cc605e7)Merge (3534ab4)Diff
      size8.37 kB8.51 kB+141 B (+1.7%)
      size-with-ext-deps26.1 kB26.4 kB+284 B (+1.1%)

      Dependency

      TypeBase (cc605e7)Merge (3534ab4)Diff
      functions

      14 dependencies

      _errorForResponse
      callAtURL
      codeForHTTPStatus
      createResponseStream
      decode
      encode
      failAfter
      httpsCallableFromURL
      httpsCallableFromURL$1
      makeAuthHeaders
      mapValues
      postJSON
      registerFunctions
      streamAtURL

      15 dependencies

      _errorForResponse
      callAtURL
      codeForHTTPStatus
      createResponseStream
      decode
      encode
      failAfter
      getCredentials
      httpsCallableFromURL
      httpsCallableFromURL$1
      makeAuthHeaders
      mapValues
      postJSON
      registerFunctions
      streamAtURL

      + getCredentials

      External Dependency

      ModuleBase (cc605e7)Merge (3534ab4)Diff
      @firebase/util

      FirebaseError
      getModularInstance

      FirebaseError
      getModularInstance
      isCloudWorkstation

      + isCloudWorkstation

Test Logs

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

@hsubox76 hsubox76 marked this pull request as ready for review August 13, 2025 17:43
@hsubox76 hsubox76 requested review from a team as code owners August 13, 2025 17:43
@@ -23,12 +23,15 @@ export interface EnhancedGenerateContentResponse extends GenerateContentResponse

| Property | Type | Description |
| --- | --- | --- |
| [functionCalls](./ai.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponsefunctioncalls) | () =&gt; [FunctionCall](./ai.functioncall.md#functioncall_interface)<!-- -->\[\] \| undefined | |
| [functionCalls](./ai.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponsefunctioncalls) | () =&gt; [FunctionCall](./ai.functioncall.md#functioncall_interface)<!-- -->\[\] \| undefined | Aggregates and returns all [FunctionCall](./ai.functioncall.md#functioncall_interface)<!-- -->s from the [GenerateContentResponse](./ai.generatecontentresponse.md#generatecontentresponse_interface)<!-- -->'s first candidate. |
Copy link
Contributor

Choose a reason for hiding this comment

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

NOT BLOCKING

...returns all FunctionCalls from...

We shouldn't pluralize like this.

Instead, tweak the sentence so that you're not pluralizing. Something like:
"... returns every FunctionCall from the..."

(same comment for GenerateContentResponse and a couple other similar instances throughout)

Copy link
Contributor

Choose a reason for hiding this comment

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

Did a search for }s and updated all of them.

@dlarocque dlarocque self-requested a review August 14, 2025 16:32
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.

5 participants