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

Make text() accessor handle mixed-parts responses #8229

Merged
merged 1 commit into from
May 8, 2024

Conversation

hsubox76
Copy link
Contributor

@hsubox76 hsubox76 commented May 7, 2024

response.text() only works when the first Part in the candidate has text, and fails if it's mixed in with FunctionCallParts. Modified to look for text on any Part and added some tests.

We also need to port this fix to GoogleAI.

Internal reference: b/338296397

Copy link

changeset-bot bot commented May 7, 2024

⚠️ No Changeset found

Latest commit: 8e0fef7

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

Size Report 1

Affected Products

  • @firebase/vertexai-preview

    TypeBase (4c83b34)Merge (700023e)Diff
    browser25.1 kB25.2 kB+85 B (+0.3%)
    main25.7 kB25.8 kB+85 B (+0.3%)
    module25.1 kB25.2 kB+85 B (+0.3%)
  • firebase

    TypeBase (4c83b34)Merge (700023e)Diff
    firebase-vertexai-preview.js19.2 kB19.3 kB+35 B (+0.2%)

Test Logs

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

@hsubox76 hsubox76 marked this pull request as ready for review May 7, 2024 21:50
@hsubox76 hsubox76 requested a review from a team as a code owner May 7, 2024 21:50
@google-oss-bot
Copy link
Contributor

Size Analysis Report 1

Affected Products

  • @firebase/vertexai-preview

    • ChatSession

      Size

      TypeBase (4c83b34)Merge (700023e)Diff
      size14.4 kB14.4 kB+42 B (+0.3%)
      size-with-ext-deps32.8 kB32.8 kB+42 B (+0.1%)
    • GenerativeModel

      Size

      TypeBase (4c83b34)Merge (700023e)Diff
      size16.6 kB16.7 kB+42 B (+0.3%)
      size-with-ext-deps35.0 kB35.1 kB+42 B (+0.1%)
    • getGenerativeModel

      Size

      TypeBase (4c83b34)Merge (700023e)Diff
      size16.7 kB16.7 kB+42 B (+0.3%)
      size-with-ext-deps35.1 kB35.2 kB+42 B (+0.1%)

Test Logs

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

Comment on lines +99 to 103
if (textStrings.length > 0) {
return textStrings.join('');
} else {
return '';
}
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 remove the conditional and just return textStrings.join(''), since [].join('') === ''? Or do we prefer to make the return result more explicit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Andrew brought up that we're not 100% sure we want the delimiter to be '' when there's multiple text Parts and this is a placeholder for now until we find out, so maybe in the future we might make it a space, or a comma, which could cause some unintended output if we forgot we meant to return '' when there's no Parts.

@hsubox76 hsubox76 merged commit d79a131 into ch-vertex-feature May 8, 2024
37 of 41 checks passed
@hsubox76 hsubox76 deleted the ch-vertex-fc-handling branch May 8, 2024 17:18
@firebase firebase locked and limited conversation to collaborators Jun 8, 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.

None yet

4 participants