Skip to content

[JS] GenerateStreamResponse.stream() should give me GenerateResponseChunks #772

@kevinthecheung

Description

@kevinthecheung

Describe the bug
I get an iterable of GenerateResponseChunkData from generateStream but GenerateResponseChunk would be better.

To Reproduce

    const llmResponseStream: GenerateStreamResponse = await generateStream({
      prompt: `Suggest a complete menu for a ${subject} themed restaurant`,
      model: gemini15Flash,
    });

    for await (const responseChunk of llmResponseStream.stream()) {
      console.log(responseChunk.text()); // compiler error
    }

But if I add @ts-ignore before the line it compiles and works

Expected behavior

I want to use all of GenerateResponseChunk's useful methods. In fact I think it's required for partial structured output

Screenshots
If applicable, add screenshots to help explain your problem.

Runtime (please complete the following information):

  • OS: [e.g. Linux, MacOS]
  • Version [e.g. 22]

** Node version

  • run node --version at paste here

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingjs

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions