Skip to content

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

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
vclong2003 opened this issue Mar 22, 2025 · 1 comment
Open

Comments

@vclong2003
Copy link

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.

@vclong2003 vclong2003 added new A new issue that hasn't be categoirzed as question, bug or feature request question labels Mar 22, 2025
@jbalidiong jbalidiong added api: vertexai and removed question new A new issue that hasn't be categoirzed as question, bug or feature request labels Mar 24, 2025
@mh-longvc
Copy link

Nice, I also need this feature 🐈

@dlarocque dlarocque self-assigned this Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants