-
Notifications
You must be signed in to change notification settings - Fork 962
Firebase AI Hybrid Inference Implementation #9029
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
Merged
+2,444
−122
Merged
Changes from 17 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
55c05a0
Hybrid inference code changes
dlarocque c16cbf1
Adding docs
gsiddh 50f142a
VinF Hybrid Inference: Document exported LanguageModel types (#9035)
erikeldridge 72cd626
AI Hybrid Inference: guard against undefined mode (#9045)
erikeldridge 177f546
AI Hybrid Inference: migrate to LanguageModelMessage (#9027)
erikeldridge 58d92df
AI Hybrid Inference: flatten initial prompts type (#9066)
erikeldridge 2a33a07
Merge branch 'main' into firebase-ai-hybridinference
hsubox76 e5e8c36
rerun docgen
hsubox76 e9dc43e
Make ChromeAdapter optional, fix doc comments
hsubox76 9e4e910
Ensure EXPERIMENTAL added to doc comments, fill out doc comments
hsubox76 f9f641d
Fill out chrome-adapter doc comments
hsubox76 5df0f21
add experimental tag to ChromeAdapter
hsubox76 ca3fc07
change back to private
hsubox76 4f469cf
update docs
hsubox76 d32c661
add some tests for on-device availability cases
hsubox76 0efb0d0
Address doc comments
hsubox76 a27968c
Put countTokens back in the interface but mark it internal
hsubox76 c2d7bae
Fix stream comment
hsubox76 254b257
Add changeset
hsubox76 2d81e00
Add changeset
hsubox76 67ad283
Add firebase to changeset
hsubox76 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
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,94 @@ | ||
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 %} | ||
|
||
# ChromeAdapter interface | ||
<b>(EXPERIMENTAL)</b> Defines an inference "backend" that uses Chrome's on-device model, and encapsulates logic for detecting when on-device inference is possible. | ||
|
||
These methods should not be called directly by the user. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
export interface ChromeAdapter | ||
``` | ||
|
||
## Methods | ||
|
||
| Method | Description | | ||
| --- | --- | | ||
| [generateContent(request)](./ai.chromeadapter.md#chromeadaptergeneratecontent) | Generates content using on-device inference.<p>This is comparable to [GenerativeModel.generateContent()](./ai.generativemodel.md#generativemodelgeneratecontent) for generating content using in-cloud inference.</p> | | ||
| [generateContentStream(request)](./ai.chromeadapter.md#chromeadaptergeneratecontentstream) | Generates a content stream using on-device inference.<p>This is comparable to [GenerativeModel.generateContentStream()](./ai.generativemodel.md#generativemodelgeneratecontentstream) for generating content using in-cloud inference.</p> | | ||
| [isAvailable(request)](./ai.chromeadapter.md#chromeadapterisavailable) | Checks if the on-device model is capable of handling a given request. | | ||
|
||
## ChromeAdapter.generateContent() | ||
|
||
Generates content using on-device inference. | ||
|
||
<p>This is comparable to [GenerativeModel.generateContent()](./ai.generativemodel.md#generativemodelgeneratecontent) for generating content using in-cloud inference.</p> | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
generateContent(request: GenerateContentRequest): Promise<Response>; | ||
``` | ||
|
||
#### Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| request | [GenerateContentRequest](./ai.generatecontentrequest.md#generatecontentrequest_interface) | a standard Firebase AI [GenerateContentRequest](./ai.generatecontentrequest.md#generatecontentrequest_interface) | | ||
|
||
<b>Returns:</b> | ||
|
||
Promise<Response> | ||
|
||
## ChromeAdapter.generateContentStream() | ||
|
||
Generates a content stream using on-device inference. | ||
|
||
<p>This is comparable to [GenerativeModel.generateContentStream()](./ai.generativemodel.md#generativemodelgeneratecontentstream) for generating content using in-cloud inference.</p> | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
generateContentStream(request: GenerateContentRequest): Promise<Response>; | ||
``` | ||
|
||
#### Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| request | [GenerateContentRequest](./ai.generatecontentrequest.md#generatecontentrequest_interface) | a standard Firebase AI [GenerateContentRequest](./ai.generatecontentrequest.md#generatecontentrequest_interface) | | ||
|
||
<b>Returns:</b> | ||
|
||
Promise<Response> | ||
|
||
## ChromeAdapter.isAvailable() | ||
|
||
Checks if the on-device model is capable of handling a given request. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
isAvailable(request: GenerateContentRequest): Promise<boolean>; | ||
``` | ||
|
||
#### Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| request | [GenerateContentRequest](./ai.generatecontentrequest.md#generatecontentrequest_interface) | A potential request to be passed to the model. | | ||
|
||
<b>Returns:</b> | ||
|
||
Promise<boolean> | ||
|
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.