diff --git a/common/api-review/vertexai.api.md b/common/api-review/vertexai.api.md
index d8c189a0059..2286824d45c 100644
--- a/common/api-review/vertexai.api.md
+++ b/common/api-review/vertexai.api.md
@@ -510,11 +510,7 @@ export interface ImagenSafetySettings {
}
// @public
-export enum InferenceMode {
- ONLY_IN_CLOUD = "ONLY_IN_CLOUD",
- ONLY_ON_DEVICE = "ONLY_ON_DEVICE",
- PREFER_ON_DEVICE = "PREFER_ON_DEVICE"
-}
+export type InferenceMode = 'prefer_on_device' | 'only_on_device' | 'only_in_cloud';
// @public
export interface InlineDataPart {
diff --git a/docs-devsite/vertexai.md b/docs-devsite/vertexai.md
index 734a21fa3dc..3ad906c6e47 100644
--- a/docs-devsite/vertexai.md
+++ b/docs-devsite/vertexai.md
@@ -55,7 +55,6 @@ The Vertex AI in Firebase Web SDK.
| [ImagenAspectRatio](./vertexai.md#imagenaspectratio) | (Public Preview) Aspect ratios for Imagen images.To specify an aspect ratio for generated images, set the aspectRatio
property in your [ImagenGenerationConfig](./vertexai.imagengenerationconfig.md#imagengenerationconfig_interface).See the the [documentation](http://firebase.google.com/docs/vertex-ai/generate-images) for more details and examples of the supported aspect ratios. |
| [ImagenPersonFilterLevel](./vertexai.md#imagenpersonfilterlevel) | (Public Preview) A filter level controlling whether generation of images containing people or faces is allowed.See the personGeneration documentation for more details. |
| [ImagenSafetyFilterLevel](./vertexai.md#imagensafetyfilterlevel) | (Public Preview) A filter level controlling how aggressively to filter sensitive content.Text prompts provided as inputs and images (generated or uploaded) through Imagen on Vertex AI are assessed against a list of safety filters, which include 'harmful categories' (for example, violence
, sexual
, derogatory
, and toxic
). This filter level controls how aggressively to filter out potentially harmful content from responses. See the [documentation](http://firebase.google.com/docs/vertex-ai/generate-images) and the [Responsible AI and usage guidelines](https://cloud.google.com/vertex-ai/generative-ai/docs/image/responsible-ai-imagen#safety-filters) for more details. |
-| [InferenceMode](./vertexai.md#inferencemode) | Determines whether inference happens on-device or in-cloud. |
| [Modality](./vertexai.md#modality) | Content part modality. |
| [SchemaType](./vertexai.md#schematype) | Contains the list of OpenAPI data types as defined by the [OpenAPI specification](https://swagger.io/docs/specification/data-models/data-types/) |
| [VertexAIErrorCode](./vertexai.md#vertexaierrorcode) | Standardized error codes that [VertexAIError](./vertexai.vertexaierror.md#vertexaierror_class) can have. |
@@ -132,6 +131,7 @@ The Vertex AI in Firebase Web SDK.
| Type Alias | Description |
| --- | --- |
+| [InferenceMode](./vertexai.md#inferencemode) | Determines whether inference happens on-device or in-cloud. |
| [Part](./vertexai.md#part) | Content part - includes text, image/video, or function call/response part types. |
| [Role](./vertexai.md#role) | Role is the producer of the content. |
| [Tool](./vertexai.md#tool) | Defines a tool that model can call to access external knowledge. |
@@ -225,6 +225,16 @@ Possible roles.
POSSIBLE_ROLES: readonly ["user", "model", "function", "system"]
```
+## InferenceMode
+
+Determines whether inference happens on-device or in-cloud.
+
+Signature:
+
+```typescript
+export type InferenceMode = 'prefer_on_device' | 'only_on_device' | 'only_in_cloud';
+```
+
## Part
Content part - includes text, image/video, or function call/response part types.
@@ -491,24 +501,6 @@ export declare enum ImagenSafetyFilterLevel
| BLOCK\_NONE | "block_none"
| (Public Preview) The least aggressive filtering level; blocks very few sensitive prompts and responses.Access to this feature is restricted and may require your case to be reviewed and approved by Cloud support. |
| BLOCK\_ONLY\_HIGH | "block_only_high"
| (Public Preview) Blocks few sensitive prompts and responses. |
-## InferenceMode
-
-Determines whether inference happens on-device or in-cloud.
-
-Signature:
-
-```typescript
-export declare enum InferenceMode
-```
-
-## Enumeration Members
-
-| Member | Value | Description |
-| --- | --- | --- |
-| ONLY\_IN\_CLOUD | "ONLY_IN_CLOUD"
| Exclusively uses the in-cloud model. |
-| ONLY\_ON\_DEVICE | "ONLY_ON_DEVICE"
| Exclusively uses the on-device model. Throws if one is not available. |
-| PREFER\_ON\_DEVICE | "PREFER_ON_DEVICE"
| Uses the on-device model if available, or falls back to the in-cloud model. |
-
## Modality
Content part modality.
diff --git a/packages/vertexai/src/api.test.ts b/packages/vertexai/src/api.test.ts
index aeb090e24c5..7b25dbdf9e9 100644
--- a/packages/vertexai/src/api.test.ts
+++ b/packages/vertexai/src/api.test.ts
@@ -14,12 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import {
- ImagenModelParams,
- InferenceMode,
- ModelParams,
- VertexAIErrorCode
-} from './types';
+import { ImagenModelParams, ModelParams, VertexAIErrorCode } from './types';
import { VertexAIError } from './errors';
import { ImagenModel, getGenerativeModel, getImagenModel } from './api';
import { expect } from 'chai';
@@ -108,7 +103,7 @@ describe('Top level API', () => {
});
it('getGenerativeModel with HybridParams sets a default model', () => {
const genModel = getGenerativeModel(fakeVertexAI, {
- mode: InferenceMode.ONLY_ON_DEVICE
+ mode: 'only_on_device'
});
expect(genModel.model).to.equal(
`publishers/google/models/${GenerativeModel.DEFAULT_HYBRID_IN_CLOUD_MODEL}`
@@ -116,7 +111,7 @@ describe('Top level API', () => {
});
it('getGenerativeModel with HybridParams honors a model override', () => {
const genModel = getGenerativeModel(fakeVertexAI, {
- mode: InferenceMode.ONLY_IN_CLOUD,
+ mode: 'prefer_on_device',
inCloudParams: { model: 'my-model' }
});
expect(genModel.model).to.equal('publishers/google/models/my-model');
diff --git a/packages/vertexai/src/types/enums.ts b/packages/vertexai/src/types/enums.ts
index 57629e5c9f5..a9481d40f5f 100644
--- a/packages/vertexai/src/types/enums.ts
+++ b/packages/vertexai/src/types/enums.ts
@@ -240,23 +240,3 @@ export enum Modality {
*/
DOCUMENT = 'DOCUMENT'
}
-
-/**
- * Determines whether inference happens on-device or in-cloud.
- */
-export enum InferenceMode {
- /**
- * Uses the on-device model if available, or falls back to the in-cloud model.
- */
- PREFER_ON_DEVICE = 'PREFER_ON_DEVICE',
-
- /**
- * Exclusively uses the on-device model. Throws if one is not available.
- */
- ONLY_ON_DEVICE = 'ONLY_ON_DEVICE',
-
- /**
- * Exclusively uses the in-cloud model.
- */
- ONLY_IN_CLOUD = 'ONLY_IN_CLOUD'
-}
diff --git a/packages/vertexai/src/types/requests.ts b/packages/vertexai/src/types/requests.ts
index 345f98ca163..35a3c428d73 100644
--- a/packages/vertexai/src/types/requests.ts
+++ b/packages/vertexai/src/types/requests.ts
@@ -22,8 +22,7 @@ import {
FunctionCallingMode,
HarmBlockMethod,
HarmBlockThreshold,
- HarmCategory,
- InferenceMode
+ HarmCategory
} from './enums';
import { ObjectSchemaInterface, SchemaRequest } from './schema';
@@ -233,3 +232,11 @@ export interface HybridParams {
*/
inCloudParams?: ModelParams;
}
+
+/**
+ * Determines whether inference happens on-device or in-cloud.
+ */
+export type InferenceMode =
+ | 'prefer_on_device'
+ | 'only_on_device'
+ | 'only_in_cloud';