Skip to content

Commit

Permalink
Merge 93588d7 into 8360014
Browse files Browse the repository at this point in the history
  • Loading branch information
dlarocque authored Jun 24, 2024
2 parents 8360014 + 93588d7 commit b72a4db
Show file tree
Hide file tree
Showing 19 changed files with 653 additions and 144 deletions.
5 changes: 5 additions & 0 deletions .changeset/light-cheetahs-arrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@firebase/vertexai-preview': patch
---

Add a publicly exported `VertexAIError` class.
43 changes: 43 additions & 0 deletions common/api-review/vertexai-preview.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { AppCheckTokenResult } from '@firebase/app-check-interop-types';
import { FirebaseApp } from '@firebase/app';
import { FirebaseAuthTokenData } from '@firebase/auth-interop-types';
import { FirebaseError } from '@firebase/util';

// @public
export interface BaseParams {
Expand Down Expand Up @@ -83,6 +84,14 @@ export interface CountTokensResponse {
totalTokens: number;
}

// @public
export interface CustomErrorData {
errorDetails?: ErrorDetails[];
response?: GenerateContentResponse;
status?: number;
statusText?: string;
}

// @public
interface Date_2 {
// (undocumented)
Expand All @@ -102,6 +111,16 @@ export interface EnhancedGenerateContentResponse extends GenerateContentResponse
text: () => string;
}

// @public
export interface ErrorDetails {
// (undocumented)
'@type'?: string;
[key: string]: unknown;
domain?: string;
metadata?: Record<string, unknown>;
reason?: string;
}

// @public
export interface FileData {
// (undocumented)
Expand Down Expand Up @@ -590,6 +609,30 @@ export interface VertexAI {
location: string;
}

// @public
export class VertexAIError extends FirebaseError {
constructor(code: VertexAIErrorCode, message: string, customErrorData?: CustomErrorData | undefined);
// (undocumented)
readonly code: VertexAIErrorCode;
// (undocumented)
readonly customErrorData?: CustomErrorData | undefined;
// (undocumented)
readonly message: string;
}

// @public
export const enum VertexAIErrorCode {
ERROR = "error",
FETCH_ERROR = "fetch-error",
INVALID_CONTENT = "invalid-content",
NO_API_KEY = "no-api-key",
NO_MODEL = "no-model",
NO_PROJECT_ID = "no-project-id",
PARSE_FAILED = "parse-failed",
REQUEST_ERROR = "request-error",
RESPONSE_ERROR = "response-error"
}

// @public
export interface VertexAIOptions {
// (undocumented)
Expand Down
6 changes: 6 additions & 0 deletions docs-devsite/_toc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -468,10 +468,14 @@ toc:
path: /docs/reference/js/vertexai-preview.counttokensrequest.md
- title: CountTokensResponse
path: /docs/reference/js/vertexai-preview.counttokensresponse.md
- title: CustomErrorData
path: /docs/reference/js/vertexai-preview.customerrordata.md
- title: Date_2
path: /docs/reference/js/vertexai-preview.date_2.md
- title: EnhancedGenerateContentResponse
path: /docs/reference/js/vertexai-preview.enhancedgeneratecontentresponse.md
- title: ErrorDetails
path: /docs/reference/js/vertexai-preview.errordetails.md
- title: FileData
path: /docs/reference/js/vertexai-preview.filedata.md
- title: FileDataPart
Expand Down Expand Up @@ -541,6 +545,8 @@ toc:
path: /docs/reference/js/vertexai-preview.usagemetadata.md
- title: VertexAI
path: /docs/reference/js/vertexai-preview.vertexai.md
- title: VertexAIError
path: /docs/reference/js/vertexai-preview.vertexaierror.md
- title: VertexAIOptions
path: /docs/reference/js/vertexai-preview.vertexaioptions.md
- title: VideoMetadata
Expand Down
68 changes: 68 additions & 0 deletions docs-devsite/vertexai-preview.customerrordata.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
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 %}

# CustomErrorData interface
Details object that contains data originating from a bad HTTP response.

<b>Signature:</b>

```typescript
export interface CustomErrorData
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [errorDetails](./vertexai-preview.customerrordata.md#customerrordataerrordetails) | [ErrorDetails](./vertexai-preview.errordetails.md#errordetails_interface)<!-- -->\[\] | Optional additional details about the error. |
| [response](./vertexai-preview.customerrordata.md#customerrordataresponse) | [GenerateContentResponse](./vertexai-preview.generatecontentresponse.md#generatecontentresponse_interface) | Response from a [GenerateContentRequest](./vertexai-preview.generatecontentrequest.md#generatecontentrequest_interface) |
| [status](./vertexai-preview.customerrordata.md#customerrordatastatus) | number | HTTP status code of the error response. |
| [statusText](./vertexai-preview.customerrordata.md#customerrordatastatustext) | string | HTTP status text of the error response. |

## CustomErrorData.errorDetails

Optional additional details about the error.

<b>Signature:</b>

```typescript
errorDetails?: ErrorDetails[];
```

## CustomErrorData.response

Response from a [GenerateContentRequest](./vertexai-preview.generatecontentrequest.md#generatecontentrequest_interface)

<b>Signature:</b>

```typescript
response?: GenerateContentResponse;
```

## CustomErrorData.status

HTTP status code of the error response.

<b>Signature:</b>

```typescript
status?: number;
```

## CustomErrorData.statusText

HTTP status text of the error response.

<b>Signature:</b>

```typescript
statusText?: string;
```
66 changes: 66 additions & 0 deletions docs-devsite/vertexai-preview.errordetails.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
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 %}

# ErrorDetails interface
Details object that may be included in an error response.

<b>Signature:</b>

```typescript
export interface ErrorDetails
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| ["@type"](./vertexai-preview.errordetails.md#errordetails"@type") | string | |
| [domain](./vertexai-preview.errordetails.md#errordetailsdomain) | string | The domain where the error occured. |
| [metadata](./vertexai-preview.errordetails.md#errordetailsmetadata) | Record&lt;string, unknown&gt; | Additonal metadata about the error. |
| [reason](./vertexai-preview.errordetails.md#errordetailsreason) | string | The reason for the error. |

## ErrorDetails."@type"

<b>Signature:</b>

```typescript
'@type'?: string;
```

## ErrorDetails.domain

The domain where the error occured.

<b>Signature:</b>

```typescript
domain?: string;
```

## ErrorDetails.metadata

Additonal metadata about the error.

<b>Signature:</b>

```typescript
metadata?: Record<string, unknown>;
```

## ErrorDetails.reason

The reason for the error.

<b>Signature:</b>

```typescript
reason?: string;
```
28 changes: 28 additions & 0 deletions docs-devsite/vertexai-preview.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ The Vertex AI For Firebase Web SDK.
| --- | --- |
| [ChatSession](./vertexai-preview.chatsession.md#chatsession_class) | ChatSession class that enables sending chat messages and stores history of sent and received messages so far. |
| [GenerativeModel](./vertexai-preview.generativemodel.md#generativemodel_class) | Class for generative model APIs. |
| [VertexAIError](./vertexai-preview.vertexaierror.md#vertexaierror_class) | Error class for the Vertex AI for Firebase SDK. |

## Enumerations

Expand All @@ -41,6 +42,7 @@ The Vertex AI For Firebase Web SDK.
| [HarmCategory](./vertexai-preview.md#harmcategory) | Harm categories that would cause prompts or candidates to be blocked. |
| [HarmProbability](./vertexai-preview.md#harmprobability) | Probability that a prompt or candidate matches a harm category. |
| [HarmSeverity](./vertexai-preview.md#harmseverity) | Harm severity levels. |
| [VertexAIErrorCode](./vertexai-preview.md#vertexaierrorcode) | Standardized error codes that [VertexAIError](./vertexai-preview.vertexaierror.md#vertexaierror_class) can have. |

## Interfaces

Expand All @@ -52,8 +54,10 @@ The Vertex AI For Firebase Web SDK.
| [Content](./vertexai-preview.content.md#content_interface) | Content type for both prompts and response candidates. |
| [CountTokensRequest](./vertexai-preview.counttokensrequest.md#counttokensrequest_interface) | Params for calling [GenerativeModel.countTokens()](./vertexai-preview.generativemodel.md#generativemodelcounttokens) |
| [CountTokensResponse](./vertexai-preview.counttokensresponse.md#counttokensresponse_interface) | Response from calling [GenerativeModel.countTokens()](./vertexai-preview.generativemodel.md#generativemodelcounttokens)<!-- -->. |
| [CustomErrorData](./vertexai-preview.customerrordata.md#customerrordata_interface) | Details object that contains data originating from a bad HTTP response. |
| [Date\_2](./vertexai-preview.date_2.md#date_2_interface) | Protobuf google.type.Date |
| [EnhancedGenerateContentResponse](./vertexai-preview.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponse_interface) | Response object wrapped with helper methods. |
| [ErrorDetails](./vertexai-preview.errordetails.md#errordetails_interface) | Details object that may be included in an error response. |
| [FileData](./vertexai-preview.filedata.md#filedata_interface) | Data pointing to a file uploaded on Google Cloud Storage. |
| [FileDataPart](./vertexai-preview.filedatapart.md#filedatapart_interface) | Content part interface if the part represents [FileData](./vertexai-preview.filedata.md#filedata_interface) |
| [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) | A predicted [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) returned from the model that contains a string representing the [FunctionDeclaration.name](./vertexai-preview.functiondeclaration.md#functiondeclarationname) and a structured JSON object containing the parameters and their values. |
Expand Down Expand Up @@ -367,3 +371,27 @@ export declare enum HarmSeverity
| HARM\_SEVERITY\_NEGLIGIBLE | <code>&quot;HARM_SEVERITY_NEGLIGIBLE&quot;</code> | |
| HARM\_SEVERITY\_UNSPECIFIED | <code>&quot;HARM_SEVERITY_UNSPECIFIED&quot;</code> | |

## VertexAIErrorCode

Standardized error codes that [VertexAIError](./vertexai-preview.vertexaierror.md#vertexaierror_class) can have.

<b>Signature:</b>

```typescript
export declare const enum VertexAIErrorCode
```

## Enumeration Members

| Member | Value | Description |
| --- | --- | --- |
| ERROR | <code>&quot;error&quot;</code> | A generic error occurred. |
| FETCH\_ERROR | <code>&quot;fetch-error&quot;</code> | An error occurred while performing a fetch. |
| INVALID\_CONTENT | <code>&quot;invalid-content&quot;</code> | An error associated with a Content object. |
| NO\_API\_KEY | <code>&quot;no-api-key&quot;</code> | An error occurred due to a missing Firebase API key. |
| NO\_MODEL | <code>&quot;no-model&quot;</code> | An error occurred due to a model name not being specified during initialization. |
| NO\_PROJECT\_ID | <code>&quot;no-project-id&quot;</code> | An error occurred due to a missing project ID. |
| PARSE\_FAILED | <code>&quot;parse-failed&quot;</code> | An error occurred while parsing. |
| REQUEST\_ERROR | <code>&quot;request-error&quot;</code> | An error occurred in a request. |
| RESPONSE\_ERROR | <code>&quot;response-error&quot;</code> | An error occurred in a response. |

76 changes: 76 additions & 0 deletions docs-devsite/vertexai-preview.vertexaierror.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
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 %}

# VertexAIError class
Error class for the Vertex AI for Firebase SDK.

<b>Signature:</b>

```typescript
export declare class VertexAIError extends FirebaseError
```
<b>Extends:</b> [FirebaseError](./util.firebaseerror.md#firebaseerror_class)
## Constructors
| Constructor | Modifiers | Description |
| --- | --- | --- |
| [(constructor)(code, message, customErrorData)](./vertexai-preview.vertexaierror.md#vertexaierrorconstructor) | | Constructs a new instance of the <code>VertexAIError</code> class. |
## Properties
| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [code](./vertexai-preview.vertexaierror.md#vertexaierrorcode) | | [VertexAIErrorCode](./vertexai-preview.md#vertexaierrorcode) | |
| [customErrorData](./vertexai-preview.vertexaierror.md#vertexaierrorcustomerrordata) | | [CustomErrorData](./vertexai-preview.customerrordata.md#customerrordata_interface) \| undefined | |
| [message](./vertexai-preview.vertexaierror.md#vertexaierrormessage) | | string | |
## VertexAIError.(constructor)
Constructs a new instance of the `VertexAIError` class.
<b>Signature:</b>
```typescript
constructor(code: VertexAIErrorCode, message: string, customErrorData?: CustomErrorData | undefined);
```
#### Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| code | [VertexAIErrorCode](./vertexai-preview.md#vertexaierrorcode) | The error code from [VertexAIErrorCode](./vertexai-preview.md#vertexaierrorcode)<!-- -->. |
| message | string | A human-readable message describing the error. |
| customErrorData | [CustomErrorData](./vertexai-preview.customerrordata.md#customerrordata_interface) \| undefined | Optional error data. |
## VertexAIError.code
<b>Signature:</b>
```typescript
readonly code: VertexAIErrorCode;
```
## VertexAIError.customErrorData
<b>Signature:</b>
```typescript
readonly customErrorData?: CustomErrorData | undefined;
```
## VertexAIError.message
<b>Signature:</b>
```typescript
readonly message: string;
```
Loading

0 comments on commit b72a4db

Please sign in to comment.