Skip to content

Commit b72a4db

Browse files
authored
Merge 93588d7 into 8360014
2 parents 8360014 + 93588d7 commit b72a4db

19 files changed

+653
-144
lines changed

.changeset/light-cheetahs-arrive.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@firebase/vertexai-preview': patch
3+
---
4+
5+
Add a publicly exported `VertexAIError` class.

common/api-review/vertexai-preview.api.md

+43
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import { AppCheckTokenResult } from '@firebase/app-check-interop-types';
88
import { FirebaseApp } from '@firebase/app';
99
import { FirebaseAuthTokenData } from '@firebase/auth-interop-types';
10+
import { FirebaseError } from '@firebase/util';
1011

1112
// @public
1213
export interface BaseParams {
@@ -83,6 +84,14 @@ export interface CountTokensResponse {
8384
totalTokens: number;
8485
}
8586

87+
// @public
88+
export interface CustomErrorData {
89+
errorDetails?: ErrorDetails[];
90+
response?: GenerateContentResponse;
91+
status?: number;
92+
statusText?: string;
93+
}
94+
8695
// @public
8796
interface Date_2 {
8897
// (undocumented)
@@ -102,6 +111,16 @@ export interface EnhancedGenerateContentResponse extends GenerateContentResponse
102111
text: () => string;
103112
}
104113

114+
// @public
115+
export interface ErrorDetails {
116+
// (undocumented)
117+
'@type'?: string;
118+
[key: string]: unknown;
119+
domain?: string;
120+
metadata?: Record<string, unknown>;
121+
reason?: string;
122+
}
123+
105124
// @public
106125
export interface FileData {
107126
// (undocumented)
@@ -590,6 +609,30 @@ export interface VertexAI {
590609
location: string;
591610
}
592611

612+
// @public
613+
export class VertexAIError extends FirebaseError {
614+
constructor(code: VertexAIErrorCode, message: string, customErrorData?: CustomErrorData | undefined);
615+
// (undocumented)
616+
readonly code: VertexAIErrorCode;
617+
// (undocumented)
618+
readonly customErrorData?: CustomErrorData | undefined;
619+
// (undocumented)
620+
readonly message: string;
621+
}
622+
623+
// @public
624+
export const enum VertexAIErrorCode {
625+
ERROR = "error",
626+
FETCH_ERROR = "fetch-error",
627+
INVALID_CONTENT = "invalid-content",
628+
NO_API_KEY = "no-api-key",
629+
NO_MODEL = "no-model",
630+
NO_PROJECT_ID = "no-project-id",
631+
PARSE_FAILED = "parse-failed",
632+
REQUEST_ERROR = "request-error",
633+
RESPONSE_ERROR = "response-error"
634+
}
635+
593636
// @public
594637
export interface VertexAIOptions {
595638
// (undocumented)

docs-devsite/_toc.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -468,10 +468,14 @@ toc:
468468
path: /docs/reference/js/vertexai-preview.counttokensrequest.md
469469
- title: CountTokensResponse
470470
path: /docs/reference/js/vertexai-preview.counttokensresponse.md
471+
- title: CustomErrorData
472+
path: /docs/reference/js/vertexai-preview.customerrordata.md
471473
- title: Date_2
472474
path: /docs/reference/js/vertexai-preview.date_2.md
473475
- title: EnhancedGenerateContentResponse
474476
path: /docs/reference/js/vertexai-preview.enhancedgeneratecontentresponse.md
477+
- title: ErrorDetails
478+
path: /docs/reference/js/vertexai-preview.errordetails.md
475479
- title: FileData
476480
path: /docs/reference/js/vertexai-preview.filedata.md
477481
- title: FileDataPart
@@ -541,6 +545,8 @@ toc:
541545
path: /docs/reference/js/vertexai-preview.usagemetadata.md
542546
- title: VertexAI
543547
path: /docs/reference/js/vertexai-preview.vertexai.md
548+
- title: VertexAIError
549+
path: /docs/reference/js/vertexai-preview.vertexaierror.md
544550
- title: VertexAIOptions
545551
path: /docs/reference/js/vertexai-preview.vertexaioptions.md
546552
- title: VideoMetadata
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
Project: /docs/reference/js/_project.yaml
2+
Book: /docs/reference/_book.yaml
3+
page_type: reference
4+
5+
{% comment %}
6+
DO NOT EDIT THIS FILE!
7+
This is generated by the JS SDK team, and any local changes will be
8+
overwritten. Changes should be made in the source code at
9+
https://github.com/firebase/firebase-js-sdk
10+
{% endcomment %}
11+
12+
# CustomErrorData interface
13+
Details object that contains data originating from a bad HTTP response.
14+
15+
<b>Signature:</b>
16+
17+
```typescript
18+
export interface CustomErrorData
19+
```
20+
21+
## Properties
22+
23+
| Property | Type | Description |
24+
| --- | --- | --- |
25+
| [errorDetails](./vertexai-preview.customerrordata.md#customerrordataerrordetails) | [ErrorDetails](./vertexai-preview.errordetails.md#errordetails_interface)<!-- -->\[\] | Optional additional details about the error. |
26+
| [response](./vertexai-preview.customerrordata.md#customerrordataresponse) | [GenerateContentResponse](./vertexai-preview.generatecontentresponse.md#generatecontentresponse_interface) | Response from a [GenerateContentRequest](./vertexai-preview.generatecontentrequest.md#generatecontentrequest_interface) |
27+
| [status](./vertexai-preview.customerrordata.md#customerrordatastatus) | number | HTTP status code of the error response. |
28+
| [statusText](./vertexai-preview.customerrordata.md#customerrordatastatustext) | string | HTTP status text of the error response. |
29+
30+
## CustomErrorData.errorDetails
31+
32+
Optional additional details about the error.
33+
34+
<b>Signature:</b>
35+
36+
```typescript
37+
errorDetails?: ErrorDetails[];
38+
```
39+
40+
## CustomErrorData.response
41+
42+
Response from a [GenerateContentRequest](./vertexai-preview.generatecontentrequest.md#generatecontentrequest_interface)
43+
44+
<b>Signature:</b>
45+
46+
```typescript
47+
response?: GenerateContentResponse;
48+
```
49+
50+
## CustomErrorData.status
51+
52+
HTTP status code of the error response.
53+
54+
<b>Signature:</b>
55+
56+
```typescript
57+
status?: number;
58+
```
59+
60+
## CustomErrorData.statusText
61+
62+
HTTP status text of the error response.
63+
64+
<b>Signature:</b>
65+
66+
```typescript
67+
statusText?: string;
68+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
Project: /docs/reference/js/_project.yaml
2+
Book: /docs/reference/_book.yaml
3+
page_type: reference
4+
5+
{% comment %}
6+
DO NOT EDIT THIS FILE!
7+
This is generated by the JS SDK team, and any local changes will be
8+
overwritten. Changes should be made in the source code at
9+
https://github.com/firebase/firebase-js-sdk
10+
{% endcomment %}
11+
12+
# ErrorDetails interface
13+
Details object that may be included in an error response.
14+
15+
<b>Signature:</b>
16+
17+
```typescript
18+
export interface ErrorDetails
19+
```
20+
21+
## Properties
22+
23+
| Property | Type | Description |
24+
| --- | --- | --- |
25+
| ["@type"](./vertexai-preview.errordetails.md#errordetails"@type") | string | |
26+
| [domain](./vertexai-preview.errordetails.md#errordetailsdomain) | string | The domain where the error occured. |
27+
| [metadata](./vertexai-preview.errordetails.md#errordetailsmetadata) | Record&lt;string, unknown&gt; | Additonal metadata about the error. |
28+
| [reason](./vertexai-preview.errordetails.md#errordetailsreason) | string | The reason for the error. |
29+
30+
## ErrorDetails."@type"
31+
32+
<b>Signature:</b>
33+
34+
```typescript
35+
'@type'?: string;
36+
```
37+
38+
## ErrorDetails.domain
39+
40+
The domain where the error occured.
41+
42+
<b>Signature:</b>
43+
44+
```typescript
45+
domain?: string;
46+
```
47+
48+
## ErrorDetails.metadata
49+
50+
Additonal metadata about the error.
51+
52+
<b>Signature:</b>
53+
54+
```typescript
55+
metadata?: Record<string, unknown>;
56+
```
57+
58+
## ErrorDetails.reason
59+
60+
The reason for the error.
61+
62+
<b>Signature:</b>
63+
64+
```typescript
65+
reason?: string;
66+
```

docs-devsite/vertexai-preview.md

+28
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ The Vertex AI For Firebase Web SDK.
2727
| --- | --- |
2828
| [ChatSession](./vertexai-preview.chatsession.md#chatsession_class) | ChatSession class that enables sending chat messages and stores history of sent and received messages so far. |
2929
| [GenerativeModel](./vertexai-preview.generativemodel.md#generativemodel_class) | Class for generative model APIs. |
30+
| [VertexAIError](./vertexai-preview.vertexaierror.md#vertexaierror_class) | Error class for the Vertex AI for Firebase SDK. |
3031

3132
## Enumerations
3233

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

4547
## Interfaces
4648

@@ -52,8 +54,10 @@ The Vertex AI For Firebase Web SDK.
5254
| [Content](./vertexai-preview.content.md#content_interface) | Content type for both prompts and response candidates. |
5355
| [CountTokensRequest](./vertexai-preview.counttokensrequest.md#counttokensrequest_interface) | Params for calling [GenerativeModel.countTokens()](./vertexai-preview.generativemodel.md#generativemodelcounttokens) |
5456
| [CountTokensResponse](./vertexai-preview.counttokensresponse.md#counttokensresponse_interface) | Response from calling [GenerativeModel.countTokens()](./vertexai-preview.generativemodel.md#generativemodelcounttokens)<!-- -->. |
57+
| [CustomErrorData](./vertexai-preview.customerrordata.md#customerrordata_interface) | Details object that contains data originating from a bad HTTP response. |
5558
| [Date\_2](./vertexai-preview.date_2.md#date_2_interface) | Protobuf google.type.Date |
5659
| [EnhancedGenerateContentResponse](./vertexai-preview.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponse_interface) | Response object wrapped with helper methods. |
60+
| [ErrorDetails](./vertexai-preview.errordetails.md#errordetails_interface) | Details object that may be included in an error response. |
5761
| [FileData](./vertexai-preview.filedata.md#filedata_interface) | Data pointing to a file uploaded on Google Cloud Storage. |
5862
| [FileDataPart](./vertexai-preview.filedatapart.md#filedatapart_interface) | Content part interface if the part represents [FileData](./vertexai-preview.filedata.md#filedata_interface) |
5963
| [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. |
@@ -367,3 +371,27 @@ export declare enum HarmSeverity
367371
| HARM\_SEVERITY\_NEGLIGIBLE | <code>&quot;HARM_SEVERITY_NEGLIGIBLE&quot;</code> | |
368372
| HARM\_SEVERITY\_UNSPECIFIED | <code>&quot;HARM_SEVERITY_UNSPECIFIED&quot;</code> | |
369373

374+
## VertexAIErrorCode
375+
376+
Standardized error codes that [VertexAIError](./vertexai-preview.vertexaierror.md#vertexaierror_class) can have.
377+
378+
<b>Signature:</b>
379+
380+
```typescript
381+
export declare const enum VertexAIErrorCode
382+
```
383+
384+
## Enumeration Members
385+
386+
| Member | Value | Description |
387+
| --- | --- | --- |
388+
| ERROR | <code>&quot;error&quot;</code> | A generic error occurred. |
389+
| FETCH\_ERROR | <code>&quot;fetch-error&quot;</code> | An error occurred while performing a fetch. |
390+
| INVALID\_CONTENT | <code>&quot;invalid-content&quot;</code> | An error associated with a Content object. |
391+
| NO\_API\_KEY | <code>&quot;no-api-key&quot;</code> | An error occurred due to a missing Firebase API key. |
392+
| NO\_MODEL | <code>&quot;no-model&quot;</code> | An error occurred due to a model name not being specified during initialization. |
393+
| NO\_PROJECT\_ID | <code>&quot;no-project-id&quot;</code> | An error occurred due to a missing project ID. |
394+
| PARSE\_FAILED | <code>&quot;parse-failed&quot;</code> | An error occurred while parsing. |
395+
| REQUEST\_ERROR | <code>&quot;request-error&quot;</code> | An error occurred in a request. |
396+
| RESPONSE\_ERROR | <code>&quot;response-error&quot;</code> | An error occurred in a response. |
397+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
Project: /docs/reference/js/_project.yaml
2+
Book: /docs/reference/_book.yaml
3+
page_type: reference
4+
5+
{% comment %}
6+
DO NOT EDIT THIS FILE!
7+
This is generated by the JS SDK team, and any local changes will be
8+
overwritten. Changes should be made in the source code at
9+
https://github.com/firebase/firebase-js-sdk
10+
{% endcomment %}
11+
12+
# VertexAIError class
13+
Error class for the Vertex AI for Firebase SDK.
14+
15+
<b>Signature:</b>
16+
17+
```typescript
18+
export declare class VertexAIError extends FirebaseError
19+
```
20+
<b>Extends:</b> [FirebaseError](./util.firebaseerror.md#firebaseerror_class)
21+
22+
## Constructors
23+
24+
| Constructor | Modifiers | Description |
25+
| --- | --- | --- |
26+
| [(constructor)(code, message, customErrorData)](./vertexai-preview.vertexaierror.md#vertexaierrorconstructor) | | Constructs a new instance of the <code>VertexAIError</code> class. |
27+
28+
## Properties
29+
30+
| Property | Modifiers | Type | Description |
31+
| --- | --- | --- | --- |
32+
| [code](./vertexai-preview.vertexaierror.md#vertexaierrorcode) | | [VertexAIErrorCode](./vertexai-preview.md#vertexaierrorcode) | |
33+
| [customErrorData](./vertexai-preview.vertexaierror.md#vertexaierrorcustomerrordata) | | [CustomErrorData](./vertexai-preview.customerrordata.md#customerrordata_interface) \| undefined | |
34+
| [message](./vertexai-preview.vertexaierror.md#vertexaierrormessage) | | string | |
35+
36+
## VertexAIError.(constructor)
37+
38+
Constructs a new instance of the `VertexAIError` class.
39+
40+
<b>Signature:</b>
41+
42+
```typescript
43+
constructor(code: VertexAIErrorCode, message: string, customErrorData?: CustomErrorData | undefined);
44+
```
45+
46+
#### Parameters
47+
48+
| Parameter | Type | Description |
49+
| --- | --- | --- |
50+
| code | [VertexAIErrorCode](./vertexai-preview.md#vertexaierrorcode) | The error code from [VertexAIErrorCode](./vertexai-preview.md#vertexaierrorcode)<!-- -->. |
51+
| message | string | A human-readable message describing the error. |
52+
| customErrorData | [CustomErrorData](./vertexai-preview.customerrordata.md#customerrordata_interface) \| undefined | Optional error data. |
53+
54+
## VertexAIError.code
55+
56+
<b>Signature:</b>
57+
58+
```typescript
59+
readonly code: VertexAIErrorCode;
60+
```
61+
62+
## VertexAIError.customErrorData
63+
64+
<b>Signature:</b>
65+
66+
```typescript
67+
readonly customErrorData?: CustomErrorData | undefined;
68+
```
69+
70+
## VertexAIError.message
71+
72+
<b>Signature:</b>
73+
74+
```typescript
75+
readonly message: string;
76+
```

0 commit comments

Comments
 (0)