Skip to content

Vertex AI - generateContentStream aggregated output undefined #8566

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

Closed
andrewheard opened this issue Oct 11, 2024 · 1 comment
Closed

Vertex AI - generateContentStream aggregated output undefined #8566

andrewheard opened this issue Oct 11, 2024 · 1 comment
Assignees

Comments

@andrewheard
Copy link

Operating System

macOS Sonoma 14.1

Environment (if applicable)

NodeJS

Firebase SDK Version

main

Firebase SDK Product(s)

VertexAI

Project Tooling

N/A - @dlarocque may have more details

Detailed Problem Description

Vertex AI omits default values (index == 0) when serializing its responses as JSON but the SDK assumes the index value will always be there in aggregateResponses(). See FirebaseExtended/vertexai-sdk-test-data#21 for more details (test failure).

Steps and code to reproduce issue

The following snippet demonstrates the issue:

async function run() {
  const prompt = "Write a story about a magic backpack."

  const result = await model.generateContentStream(prompt);
  for await (const chunk of result.stream) {
    const chunkText = chunk.text();

    // No issues - WAI
    console.log(chunkText);
  }

  // Not working because of the undefined index
  console.log('aggregated response: ', await result.response);
}

run()
@hsubox76
Copy link
Contributor

hsubox76 commented Oct 18, 2024

Not sure why the Fixes didn't autoclose this.
Edit: Oh because the PR wasn't merged to main.

@firebase firebase locked and limited conversation to collaborators Nov 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants