Skip to content

FR: Support AbortSignal in generateContent() for firebase/vertexai #8859

Open
@vclong2003

Description

@vclong2003

Operating System

macOS 15.3.2

Environment (if applicable)

ReactJS

Firebase SDK Version

11.5.0

Firebase SDK Product(s)

VertexAI

Project Tooling

ReactJS App with Vite

Detailed Problem Description

  • I want to be able to cancel an ongoing request when using generateContent() in firebase/vertexai by passing an AbortSignal as an option.
  • Currently, generateContent() only accepts a single parameter (the prompt). There is no way to pass an AbortSignal to cancel a request.
  • No errors are thrown, but there is no way to stop an ongoing request, leading to unnecessary API calls continuing even when they are no longer needed.

Steps and code to reproduce issue

`

// ...
if (this.controller) this.controller.abort();

this.controller = new AbortController();

const signal = this.controller.signal;
try {
  const result = await this.getModel().generateContent(prompt, { signal });  // Passing abort signal here
  return result;
} catch (error) {
  console.error("Request aborted or failed:", error);
}
// ...

`

Expected Behavior

I would like generateContent() to accept a second parameter, such as an options object, where we can pass an AbortSignal to cancel the request when needed.

Feature Request

Please add support for an options object in generateContent() that allows passing an AbortSignal to cancel requests. This would align with best practices for handling long-running network requests and improve app responsiveness.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions