Skip to content

Commit ee02ff0

Browse files
authoredMay 22, 2024··
Add additional properties to FileMetadataResponse (#147)
1 parent e308643 commit ee02ff0

27 files changed

+324
-14
lines changed
 

‎.changeset/few-pants-thank.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@google/generative-ai": patch
3+
---
4+
5+
Add additional properties `videoMetadata` and `error` to `FileMetadataResponse` type.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ErrorDetails](./generative-ai.errordetails.md) &gt; ["@type"](./generative-ai.errordetails.__type_.md)
4+
5+
## ErrorDetails."@type" property
6+
7+
**Signature:**
8+
9+
```typescript
10+
"@type"?: string;
11+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ErrorDetails](./generative-ai.errordetails.md) &gt; [domain](./generative-ai.errordetails.domain.md)
4+
5+
## ErrorDetails.domain property
6+
7+
**Signature:**
8+
9+
```typescript
10+
domain?: string;
11+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ErrorDetails](./generative-ai.errordetails.md)
4+
5+
## ErrorDetails interface
6+
7+
Details object that may be included in an error response.
8+
9+
**Signature:**
10+
11+
```typescript
12+
export interface ErrorDetails
13+
```
14+
15+
## Properties
16+
17+
| Property | Modifiers | Type | Description |
18+
| --- | --- | --- | --- |
19+
| ["@type"?](./generative-ai.errordetails.__type_.md) | | string | _(Optional)_ |
20+
| [domain?](./generative-ai.errordetails.domain.md) | | string | _(Optional)_ |
21+
| [metadata?](./generative-ai.errordetails.metadata.md) | | Record&lt;string, unknown&gt; | _(Optional)_ |
22+
| [reason?](./generative-ai.errordetails.reason.md) | | string | _(Optional)_ |
23+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ErrorDetails](./generative-ai.errordetails.md) &gt; [metadata](./generative-ai.errordetails.metadata.md)
4+
5+
## ErrorDetails.metadata property
6+
7+
**Signature:**
8+
9+
```typescript
10+
metadata?: Record<string, unknown>;
11+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ErrorDetails](./generative-ai.errordetails.md) &gt; [reason](./generative-ai.errordetails.reason.md)
4+
5+
## ErrorDetails.reason property
6+
7+
**Signature:**
8+
9+
```typescript
10+
reason?: string;
11+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [FileMetadataResponse](./generative-ai.filemetadataresponse.md) &gt; [error](./generative-ai.filemetadataresponse.error.md)
4+
5+
## FileMetadataResponse.error property
6+
7+
Error populated if file processing has failed.
8+
9+
**Signature:**
10+
11+
```typescript
12+
error?: RpcStatus;
13+
```

‎docs/reference/files/generative-ai.filemetadataresponse.md

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export interface FileMetadataResponse
1818
| --- | --- | --- | --- |
1919
| [createTime](./generative-ai.filemetadataresponse.createtime.md) | | string | |
2020
| [displayName?](./generative-ai.filemetadataresponse.displayname.md) | | string | _(Optional)_ |
21+
| [error?](./generative-ai.filemetadataresponse.error.md) | | [RpcStatus](./generative-ai.rpcstatus.md) | _(Optional)_ Error populated if file processing has failed. |
2122
| [expirationTime](./generative-ai.filemetadataresponse.expirationtime.md) | | string | |
2223
| [mimeType](./generative-ai.filemetadataresponse.mimetype.md) | | string | |
2324
| [name](./generative-ai.filemetadataresponse.name.md) | | string | |
@@ -26,4 +27,5 @@ export interface FileMetadataResponse
2627
| [state](./generative-ai.filemetadataresponse.state.md) | | [FileState](./generative-ai.filestate.md) | |
2728
| [updateTime](./generative-ai.filemetadataresponse.updatetime.md) | | string | |
2829
| [uri](./generative-ai.filemetadataresponse.uri.md) | | string | |
30+
| [videoMetadata?](./generative-ai.filemetadataresponse.videometadata.md) | | [VideoMetadata](./generative-ai.videometadata.md) | _(Optional)_ Video metadata populated after processing is complete. |
2931

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [FileMetadataResponse](./generative-ai.filemetadataresponse.md) &gt; [videoMetadata](./generative-ai.filemetadataresponse.videometadata.md)
4+
5+
## FileMetadataResponse.videoMetadata property
6+
7+
Video metadata populated after processing is complete.
8+
9+
**Signature:**
10+
11+
```typescript
12+
videoMetadata?: VideoMetadata;
13+
```

‎docs/reference/files/generative-ai.md

+3
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@
2020

2121
| Interface | Description |
2222
| --- | --- |
23+
| [ErrorDetails](./generative-ai.errordetails.md) | Details object that may be included in an error response. |
2324
| [FileMetadata](./generative-ai.filemetadata.md) | Metadata to provide alongside a file upload |
2425
| [FileMetadataResponse](./generative-ai.filemetadataresponse.md) | File metadata response from server. |
2526
| [ListFilesResponse](./generative-ai.listfilesresponse.md) | Response from calling [GoogleAIFileManager.listFiles()](./generative-ai.googleaifilemanager.listfiles.md) |
2627
| [ListParams](./generative-ai.listparams.md) | Params to pass to [GoogleAIFileManager.listFiles()](./generative-ai.googleaifilemanager.listfiles.md) |
2728
| [RequestOptions](./generative-ai.requestoptions.md) | Params passed to getGenerativeModel() or GoogleAIFileManager(). |
29+
| [RpcStatus](./generative-ai.rpcstatus.md) | Standard RPC error status object. |
2830
| [UploadFileResponse](./generative-ai.uploadfileresponse.md) | Response from calling [GoogleAIFileManager.uploadFile()](./generative-ai.googleaifilemanager.uploadfile.md) |
31+
| [VideoMetadata](./generative-ai.videometadata.md) | Metadata populated when video has been processed. |
2932

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [RpcStatus](./generative-ai.rpcstatus.md) &gt; [code](./generative-ai.rpcstatus.code.md)
4+
5+
## RpcStatus.code property
6+
7+
Error status code
8+
9+
**Signature:**
10+
11+
```typescript
12+
code: number;
13+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [RpcStatus](./generative-ai.rpcstatus.md) &gt; [details](./generative-ai.rpcstatus.details.md)
4+
5+
## RpcStatus.details property
6+
7+
A list of messages that carry the error details.
8+
9+
**Signature:**
10+
11+
```typescript
12+
details?: ErrorDetails[];
13+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [RpcStatus](./generative-ai.rpcstatus.md)
4+
5+
## RpcStatus interface
6+
7+
Standard RPC error status object.
8+
9+
**Signature:**
10+
11+
```typescript
12+
export interface RpcStatus
13+
```
14+
15+
## Properties
16+
17+
| Property | Modifiers | Type | Description |
18+
| --- | --- | --- | --- |
19+
| [code](./generative-ai.rpcstatus.code.md) | | number | Error status code |
20+
| [details?](./generative-ai.rpcstatus.details.md) | | [ErrorDetails](./generative-ai.errordetails.md)<!-- -->\[\] | _(Optional)_ A list of messages that carry the error details. |
21+
| [message](./generative-ai.rpcstatus.message.md) | | string | A developer-facing error message. |
22+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [RpcStatus](./generative-ai.rpcstatus.md) &gt; [message](./generative-ai.rpcstatus.message.md)
4+
5+
## RpcStatus.message property
6+
7+
A developer-facing error message.
8+
9+
**Signature:**
10+
11+
```typescript
12+
message: string;
13+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [VideoMetadata](./generative-ai.videometadata.md)
4+
5+
## VideoMetadata interface
6+
7+
Metadata populated when video has been processed.
8+
9+
**Signature:**
10+
11+
```typescript
12+
export interface VideoMetadata
13+
```
14+
15+
## Properties
16+
17+
| Property | Modifiers | Type | Description |
18+
| --- | --- | --- | --- |
19+
| [videoDuration](./generative-ai.videometadata.videoduration.md) | | string | The video duration in protobuf [Duration](https://cloud.google.com/ruby/docs/reference/google-cloud-workflows-v1/latest/Google-Protobuf-Duration#json-mapping) format. |
20+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [VideoMetadata](./generative-ai.videometadata.md) &gt; [videoDuration](./generative-ai.videometadata.videoduration.md)
4+
5+
## VideoMetadata.videoDuration property
6+
7+
The video duration in protobuf [Duration](https://cloud.google.com/ruby/docs/reference/google-cloud-workflows-v1/latest/Google-Protobuf-Duration#json-mapping) format.
8+
9+
**Signature:**
10+
11+
```typescript
12+
videoDuration: string;
13+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ErrorDetails](./generative-ai.errordetails.md) &gt; ["@type"](./generative-ai.errordetails.__type_.md)
4+
5+
## ErrorDetails."@type" property
6+
7+
**Signature:**
8+
9+
```typescript
10+
"@type"?: string;
11+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ErrorDetails](./generative-ai.errordetails.md) &gt; [domain](./generative-ai.errordetails.domain.md)
4+
5+
## ErrorDetails.domain property
6+
7+
**Signature:**
8+
9+
```typescript
10+
domain?: string;
11+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ErrorDetails](./generative-ai.errordetails.md)
4+
5+
## ErrorDetails interface
6+
7+
Details object that may be included in an error response.
8+
9+
**Signature:**
10+
11+
```typescript
12+
export interface ErrorDetails
13+
```
14+
15+
## Properties
16+
17+
| Property | Modifiers | Type | Description |
18+
| --- | --- | --- | --- |
19+
| ["@type"?](./generative-ai.errordetails.__type_.md) | | string | _(Optional)_ |
20+
| [domain?](./generative-ai.errordetails.domain.md) | | string | _(Optional)_ |
21+
| [metadata?](./generative-ai.errordetails.metadata.md) | | Record&lt;string, unknown&gt; | _(Optional)_ |
22+
| [reason?](./generative-ai.errordetails.reason.md) | | string | _(Optional)_ |
23+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ErrorDetails](./generative-ai.errordetails.md) &gt; [metadata](./generative-ai.errordetails.metadata.md)
4+
5+
## ErrorDetails.metadata property
6+
7+
**Signature:**
8+
9+
```typescript
10+
metadata?: Record<string, unknown>;
11+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ErrorDetails](./generative-ai.errordetails.md) &gt; [reason](./generative-ai.errordetails.reason.md)
4+
5+
## ErrorDetails.reason property
6+
7+
**Signature:**
8+
9+
```typescript
10+
reason?: string;
11+
```

‎docs/reference/main/generative-ai.googlegenerativeaifetcherror._constructor_.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ constructor(message: string, status?: number, statusText?: string, errorDetails?
1919
| message | string | |
2020
| status | number | _(Optional)_ |
2121
| statusText | string | _(Optional)_ |
22-
| errorDetails | ErrorDetails\[\] | _(Optional)_ |
22+
| errorDetails | [ErrorDetails](./generative-ai.errordetails.md)<!-- -->\[\] | _(Optional)_ |
2323

‎docs/reference/main/generative-ai.googlegenerativeaifetcherror.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export declare class GoogleGenerativeAIFetchError extends GoogleGenerativeAIErro
2323
2424
| Property | Modifiers | Type | Description |
2525
| --- | --- | --- | --- |
26-
| [errorDetails?](./generative-ai.googlegenerativeaifetcherror.errordetails.md) | | ErrorDetails\[\] | _(Optional)_ |
26+
| [errorDetails?](./generative-ai.googlegenerativeaifetcherror.errordetails.md) | | [ErrorDetails](./generative-ai.errordetails.md)<!-- -->\[\] | _(Optional)_ |
2727
| [status?](./generative-ai.googlegenerativeaifetcherror.status.md) | | number | _(Optional)_ |
2828
| [statusText?](./generative-ai.googlegenerativeaifetcherror.statustext.md) | | string | _(Optional)_ |
2929

‎docs/reference/main/generative-ai.md

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
| [EmbedContentRequest](./generative-ai.embedcontentrequest.md) | Params for calling [GenerativeModel.embedContent()](./generative-ai.generativemodel.embedcontent.md) |
4646
| [EmbedContentResponse](./generative-ai.embedcontentresponse.md) | Response from calling [GenerativeModel.embedContent()](./generative-ai.generativemodel.embedcontent.md)<!-- -->. |
4747
| [EnhancedGenerateContentResponse](./generative-ai.enhancedgeneratecontentresponse.md) | Response object wrapped with helper methods. |
48+
| [ErrorDetails](./generative-ai.errordetails.md) | Details object that may be included in an error response. |
4849
| [FileData](./generative-ai.filedata.md) | Data pointing to a file uploaded with the Files API. |
4950
| [FileDataPart](./generative-ai.filedatapart.md) | Content part interface if the part represents FunctionResponse. |
5051
| [FunctionCall](./generative-ai.functioncall.md) | A predicted \[FunctionCall\] returned from the model that contains a string representing the \[FunctionDeclaration.name\] and a structured JSON object containing the parameters and their values. |

‎packages/main/src/errors.ts

+2-12
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
import { ErrorDetails } from "../types";
19+
1820
/**
1921
* Basic error type for this SDK.
2022
* @public
@@ -62,15 +64,3 @@ export class GoogleGenerativeAIFetchError extends GoogleGenerativeAIError {
6264
* @public
6365
*/
6466
export class GoogleGenerativeAIRequestInputError extends GoogleGenerativeAIError {}
65-
66-
/**
67-
* Details object that may be included in an error response.
68-
* @public
69-
*/
70-
interface ErrorDetails {
71-
"@type"?: string;
72-
reason?: string;
73-
domain?: string;
74-
metadata?: Record<string, unknown>;
75-
[key: string]: unknown;
76-
}

‎packages/main/src/files/types.ts

+43
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
* limitations under the License.
1616
*/
1717

18+
import { ErrorDetails } from "../../types";
19+
20+
export { ErrorDetails };
21+
1822
/**
1923
* Params to pass to {@link GoogleAIFileManager.listFiles}
2024
* @public
@@ -49,6 +53,14 @@ export interface FileMetadataResponse {
4953
sha256Hash: string;
5054
uri: string;
5155
state: FileState;
56+
/**
57+
* Error populated if file processing has failed.
58+
*/
59+
error?: RpcStatus;
60+
/**
61+
* Video metadata populated after processing is complete.
62+
*/
63+
videoMetadata?: VideoMetadata;
5264
}
5365

5466
/**
@@ -82,3 +94,34 @@ export enum FileState {
8294
// File failed processing.
8395
FAILED = "FAILED",
8496
}
97+
98+
/**
99+
* Standard RPC error status object.
100+
* @public
101+
*/
102+
export interface RpcStatus {
103+
/**
104+
* Error status code
105+
*/
106+
code: number;
107+
/**
108+
* A developer-facing error message.
109+
*/
110+
message: string;
111+
/**
112+
* A list of messages that carry the error details.
113+
*/
114+
details?: ErrorDetails[];
115+
}
116+
117+
/**
118+
* Metadata populated when video has been processed.
119+
* @public
120+
*/
121+
export interface VideoMetadata {
122+
/**
123+
* The video duration in
124+
* protobuf {@link https://cloud.google.com/ruby/docs/reference/google-cloud-workflows-v1/latest/Google-Protobuf-Duration#json-mapping | Duration} format.
125+
*/
126+
videoDuration: string;
127+
}

‎packages/main/types/responses.ts

+12
Original file line numberDiff line numberDiff line change
@@ -183,3 +183,15 @@ export interface BatchEmbedContentsResponse {
183183
export interface ContentEmbedding {
184184
values: number[];
185185
}
186+
187+
/**
188+
* Details object that may be included in an error response.
189+
* @public
190+
*/
191+
export interface ErrorDetails {
192+
"@type"?: string;
193+
reason?: string;
194+
domain?: string;
195+
metadata?: Record<string, unknown>;
196+
[key: string]: unknown;
197+
}

0 commit comments

Comments
 (0)
Please sign in to comment.