2.9 KiB
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
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.
Signature:
export interface ChromeAdapter
Methods
| Method | Description |
|---|---|
| generateContent(request) | Generates content using on-device inference. |
| generateContentStream(request) | Generates a content stream using on-device inference. |
| isAvailable(request) | Checks if the on-device model is capable of handling a given request. |
ChromeAdapter.generateContent()
Generates content using on-device inference.
This is comparable to GenerativeModel.generateContent() for generating content using in-cloud inference.
Signature:
generateContent(request: GenerateContentRequest): Promise<Response>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| request | GenerateContentRequest | a standard Firebase AI GenerateContentRequest |
Returns:
Promise<Response>
ChromeAdapter.generateContentStream()
Generates a content stream using on-device inference.
This is comparable to GenerativeModel.generateContentStream() for generating a content stream using in-cloud inference.
Signature:
generateContentStream(request: GenerateContentRequest): Promise<Response>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| request | GenerateContentRequest | a standard Firebase AI GenerateContentRequest |
Returns:
Promise<Response>
ChromeAdapter.isAvailable()
Checks if the on-device model is capable of handling a given request.
Signature:
isAvailable(request: GenerateContentRequest): Promise<boolean>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| request | GenerateContentRequest | A potential request to be passed to the model. |
Returns:
Promise<boolean>