-
Notifications
You must be signed in to change notification settings - Fork 988
feat(ai): Add support for AbortSignal
#8890
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
dlarocque
wants to merge
32
commits into
main
Choose a base branch
from
dl/abort-signal
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
c616128
feat(vertexai): Add support for `AbortSignal`
dlarocque 54589ad
Run formatter
dlarocque b4ae062
Merge branch 'main' into dl/abort-signal
dlarocque a82a809
Fix docs
dlarocque f690611
Update changeset to use `@firebase/ai`
dlarocque 821e580
remove ghost changeset
dlarocque 15239fb
update example in docs
dlarocque 0096b9a
Docs review
dlarocque 931972d
Merge branch 'main' into dl/abort-signal
dlarocque 3a5ce74
Merge branch 'main' into dl/abort-signal
dlarocque 62552a2
do not log abort errors during chat message stream
dlarocque d4d62a2
Merge branch 'main' into dl/abort-signal
dlarocque 9f31324
remove old vertex ai docs
dlarocque 1633e80
clean up and add tests
dlarocque a5b0848
revert launch json change
dlarocque 5ab789f
Merge branch 'main' into dl/abort-signal
dlarocque 472b40c
revert chrome adapter change
dlarocque dbb11a9
fix external signal listener leak
dlarocque 3557b15
fix sendMessageStream abort signal tests
dlarocque 4a3af45
format and fix generative-model tests
dlarocque b016952
remove console log in tests
dlarocque 40ce3c5
fix imagen test request options assertion
dlarocque bf1b031
throw AbortError if timeout is invoked on request
dlarocque 49461e1
assert chatSessionStream throws the request error
dlarocque 8b3baac
format and docs
dlarocque 2988c61
fix lint err
dlarocque 2cbd4c4
fix issue where externalSignal event listener is cleared during stream
dlarocque 1477de1
documentation
dlarocque 60f5c56
Fix unit tests
dlarocque f73e401
add unit tests for chat internal errors
dlarocque 1190ec4
add integration tests
dlarocque 247c666
format
dlarocque File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| 'firebase': minor | ||
| '@firebase/vertexai': minor | ||
| --- | ||
|
|
||
| Add support for `AbortSignal`, allowing requests to be aborted. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| Project: /docs/reference/js/_project.yaml | ||
| Book: /docs/reference/_book.yaml | ||
| page_type: reference | ||
|
|
||
| {% comment %} | ||
| DO NOT EDIT THIS FILE! | ||
| This is generated by the JS SDK team, and any local changes will be | ||
| overwritten. Changes should be made in the source code at | ||
| https://github.com/firebase/firebase-js-sdk | ||
| {% endcomment %} | ||
|
|
||
| # SingleRequestOptions interface | ||
| Options that can be provided per-request. Extends the base [RequestOptions](./vertexai.requestoptions.md#requestoptions_interface) (like `timeout` and `baseUrl`<!-- -->) with request-specific controls like cancellation via `AbortSignal`<!-- -->. | ||
|
|
||
| Options specified here will override any default [RequestOptions](./vertexai.requestoptions.md#requestoptions_interface) configured on a model (e.g. [GenerativeModel](./vertexai.generativemodel.md#generativemodel_class)<!-- -->). | ||
|
|
||
| <b>Signature:</b> | ||
|
|
||
| ```typescript | ||
| export interface SingleRequestOptions extends RequestOptions | ||
| ``` | ||
| <b>Extends:</b> [RequestOptions](./vertexai.requestoptions.md#requestoptions_interface) | ||
| ## Properties | ||
| | Property | Type | Description | | ||
| | --- | --- | --- | | ||
| | [signal](./vertexai.singlerequestoptions.md#singlerequestoptionssignal) | AbortSignal | An <code>AbortSignal</code> instance that allows cancelling ongoing requests (like <code>generateContent</code> or <code>generateImages</code>).<!-- -->If provided, calling <code>abort()</code> on the corresponding <code>AbortController</code> will attempt to cancel the underlying HTTP request. An <code>AbortError</code> will be thrown if cancellation is successful.<!-- -->Note that this will not cancel the request in the backend, so billing will still be applied despite cancellation. | | ||
| ## SingleRequestOptions.signal | ||
| An `AbortSignal` instance that allows cancelling ongoing requests (like `generateContent` or `generateImages`<!-- -->). | ||
| If provided, calling `abort()` on the corresponding `AbortController` will attempt to cancel the underlying HTTP request. An `AbortError` will be thrown if cancellation is successful. | ||
| Note that this will not cancel the request in the backend, so billing will still be applied despite cancellation. | ||
|
||
| <b>Signature:</b> | ||
| ```typescript | ||
| signal?: AbortSignal; | ||
| ``` | ||
| ### Example | ||
| ```javascript | ||
| const controller = new AbortController(); | ||
| const model = getGenerativeModel({ | ||
| // ... | ||
| }); | ||
|
|
||
| // To cancel request: | ||
| controller.abort(); | ||
|
|
||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.