Skip to content

Commit 3b5daae

Browse files
authored
Fix Schema type to reference itself in its child properties (#222)
1 parent 27e2f97 commit 3b5daae

File tree

41 files changed

+190
-139
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+190
-139
lines changed

.changeset/breezy-scissors-attend.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@google/generative-ai": minor
3+
---
4+
5+
Fix `Schema` type to reference itself and not a derived type in its `items` array and `properties` map.

common/api-review/generative-ai-server.api.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -282,23 +282,13 @@ export interface FunctionDeclarationSchema {
282282
[k: string]: FunctionDeclarationSchemaProperty;
283283
};
284284
required?: string[];
285-
type: FunctionDeclarationSchemaType;
285+
type: SchemaType;
286286
}
287287

288288
// @public
289289
export interface FunctionDeclarationSchemaProperty extends Schema {
290290
}
291291

292-
// @public
293-
export enum FunctionDeclarationSchemaType {
294-
ARRAY = "ARRAY",
295-
BOOLEAN = "BOOLEAN",
296-
INTEGER = "INTEGER",
297-
NUMBER = "NUMBER",
298-
OBJECT = "OBJECT",
299-
STRING = "STRING"
300-
}
301-
302292
// @public
303293
export interface FunctionDeclarationsTool {
304294
functionDeclarations?: FunctionDeclaration[];
@@ -356,7 +346,6 @@ export class GoogleAIFileManager {
356346
apiKey: string;
357347
deleteFile(fileId: string): Promise<void>;
358348
getFile(fileId: string, requestOptions?: SingleRequestOptions): Promise<FileMetadataResponse>;
359-
// Warning: (ae-forgotten-export) The symbol "SingleRequestOptions" needs to be exported by the entry point index.d.ts
360349
listFiles(listParams?: ListParams, requestOptions?: SingleRequestOptions): Promise<ListFilesResponse>;
361350
uploadFile(filePath: string, fileMetadata: FileMetadata): Promise<UploadFileResponse>;
362351
}
@@ -440,13 +429,28 @@ export interface Schema {
440429
enum?: string[];
441430
example?: unknown;
442431
format?: string;
443-
items?: FunctionDeclarationSchema;
432+
items?: Schema;
444433
nullable?: boolean;
445434
properties?: {
446-
[k: string]: FunctionDeclarationSchema;
435+
[k: string]: Schema;
447436
};
448437
required?: string[];
449-
type?: FunctionDeclarationSchemaType;
438+
type?: SchemaType;
439+
}
440+
441+
// @public
442+
export enum SchemaType {
443+
ARRAY = "ARRAY",
444+
BOOLEAN = "BOOLEAN",
445+
INTEGER = "INTEGER",
446+
NUMBER = "NUMBER",
447+
OBJECT = "OBJECT",
448+
STRING = "STRING"
449+
}
450+
451+
// @public
452+
export interface SingleRequestOptions extends RequestOptions {
453+
signal?: AbortSignal;
450454
}
451455

452456
// @public

common/api-review/generative-ai.api.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -329,23 +329,13 @@ export interface FunctionDeclarationSchema {
329329
[k: string]: FunctionDeclarationSchemaProperty;
330330
};
331331
required?: string[];
332-
type: FunctionDeclarationSchemaType;
332+
type: SchemaType;
333333
}
334334

335335
// @public
336336
export interface FunctionDeclarationSchemaProperty extends Schema {
337337
}
338338

339-
// @public
340-
export enum FunctionDeclarationSchemaType {
341-
ARRAY = "ARRAY",
342-
BOOLEAN = "BOOLEAN",
343-
INTEGER = "INTEGER",
344-
NUMBER = "NUMBER",
345-
OBJECT = "OBJECT",
346-
STRING = "STRING"
347-
}
348-
349339
// @public
350340
export interface FunctionDeclarationsTool {
351341
functionDeclarations?: FunctionDeclaration[];
@@ -656,13 +646,23 @@ export interface Schema {
656646
enum?: string[];
657647
example?: unknown;
658648
format?: string;
659-
items?: FunctionDeclarationSchema;
649+
items?: Schema;
660650
nullable?: boolean;
661651
properties?: {
662-
[k: string]: FunctionDeclarationSchema;
652+
[k: string]: Schema;
663653
};
664654
required?: string[];
665-
type?: FunctionDeclarationSchemaType;
655+
type?: SchemaType;
656+
}
657+
658+
// @public
659+
export enum SchemaType {
660+
ARRAY = "ARRAY",
661+
BOOLEAN = "BOOLEAN",
662+
INTEGER = "INTEGER",
663+
NUMBER = "NUMBER",
664+
OBJECT = "OBJECT",
665+
STRING = "STRING"
666666
}
667667

668668
// @public

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ export declare class ChatSession
3030
| Method | Modifiers | Description |
3131
| --- | --- | --- |
3232
| [getHistory()](./generative-ai.chatsession.gethistory.md) | | Gets the chat history so far. Blocked prompts are not added to history. Blocked candidates are not added to history, nor are the prompts that generated them. |
33-
| [sendMessage(request, requestOptions)](./generative-ai.chatsession.sendmessage.md) | | <p>Sends a chat message and receives a non-streaming [GenerateContentResult](./generative-ai.generatecontentresult.md)<!-- -->.</p><p>Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided at the time of the initialization.</p> |
34-
| [sendMessageStream(request, requestOptions)](./generative-ai.chatsession.sendmessagestream.md) | | <p>Sends a chat message and receives the response as a [GenerateContentStreamResult](./generative-ai.generatecontentstreamresult.md) containing an iterable stream and a response promise.</p><p>Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided at the time of the initialization.</p> |
33+
| [sendMessage(request, requestOptions)](./generative-ai.chatsession.sendmessage.md) | | <p>Sends a chat message and receives a non-streaming [GenerateContentResult](./generative-ai.generatecontentresult.md)<!-- -->.</p><p>Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided to [GoogleGenerativeAI.getGenerativeModel()](./generative-ai.googlegenerativeai.getgenerativemodel.md)<!-- -->.</p> |
34+
| [sendMessageStream(request, requestOptions)](./generative-ai.chatsession.sendmessagestream.md) | | <p>Sends a chat message and receives the response as a [GenerateContentStreamResult](./generative-ai.generatecontentstreamresult.md) containing an iterable stream and a response promise.</p><p>Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided to [GoogleGenerativeAI.getGenerativeModel()](./generative-ai.googlegenerativeai.getgenerativemodel.md)<!-- -->.</p> |
3535

docs/reference/main/generative-ai.chatsession.sendmessage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
Sends a chat message and receives a non-streaming [GenerateContentResult](./generative-ai.generatecontentresult.md)<!-- -->.
88

9-
Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided at the time of the initialization.
9+
Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided to [GoogleGenerativeAI.getGenerativeModel()](./generative-ai.googlegenerativeai.getgenerativemodel.md)<!-- -->.
1010

1111
**Signature:**
1212

docs/reference/main/generative-ai.chatsession.sendmessagestream.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
Sends a chat message and receives the response as a [GenerateContentStreamResult](./generative-ai.generatecontentstreamresult.md) containing an iterable stream and a response promise.
88

9-
Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided at the time of the initialization.
9+
Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided to [GoogleGenerativeAI.getGenerativeModel()](./generative-ai.googlegenerativeai.getgenerativemodel.md)<!-- -->.
1010

1111
**Signature:**
1212

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ export interface FunctionDeclarationSchema
1919
| [description?](./generative-ai.functiondeclarationschema.description.md) | | string | _(Optional)_ Optional. Description of the parameter. |
2020
| [properties](./generative-ai.functiondeclarationschema.properties.md) | | { \[k: string\]: [FunctionDeclarationSchemaProperty](./generative-ai.functiondeclarationschemaproperty.md)<!-- -->; } | The format of the parameter. |
2121
| [required?](./generative-ai.functiondeclarationschema.required.md) | | string\[\] | _(Optional)_ Optional. Array of required parameters. |
22-
| [type](./generative-ai.functiondeclarationschema.type.md) | | [FunctionDeclarationSchemaType](./generative-ai.functiondeclarationschematype.md) | The type of the parameter. |
22+
| [type](./generative-ai.functiondeclarationschema.type.md) | | [SchemaType](./generative-ai.schematype.md) | The type of the parameter. |
2323

docs/reference/main/generative-ai.functiondeclarationschema.type.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ The type of the parameter.
99
**Signature:**
1010

1111
```typescript
12-
type: FunctionDeclarationSchemaType;
12+
type: SchemaType;
1313
```

docs/reference/main/generative-ai.generativemodel.batchembedcontents.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
Embeds an array of [EmbedContentRequest](./generative-ai.embedcontentrequest.md)<!-- -->s.
88

9-
Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided at the time of the initialization.
9+
Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided to [GoogleGenerativeAI.getGenerativeModel()](./generative-ai.googlegenerativeai.getgenerativemodel.md)<!-- -->.
1010

1111
**Signature:**
1212

docs/reference/main/generative-ai.generativemodel.counttokens.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
Counts the tokens in the provided request.
88

9-
Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided at the time of the initialization.
9+
Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided to [GoogleGenerativeAI.getGenerativeModel()](./generative-ai.googlegenerativeai.getgenerativemodel.md)<!-- -->.
1010

1111
**Signature:**
1212

docs/reference/main/generative-ai.generativemodel.embedcontent.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
Embeds the provided content.
88

9-
Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided at the time of the initialization.
9+
Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided to [GoogleGenerativeAI.getGenerativeModel()](./generative-ai.googlegenerativeai.getgenerativemodel.md)<!-- -->.
1010

1111
**Signature:**
1212

docs/reference/main/generative-ai.generativemodel.generatecontent.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
Makes a single non-streaming call to the model and returns an object containing a single [GenerateContentResponse](./generative-ai.generatecontentresponse.md)<!-- -->.
88

9-
Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided at the time of the initialization.
9+
Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided to [GoogleGenerativeAI.getGenerativeModel()](./generative-ai.googlegenerativeai.getgenerativemodel.md)<!-- -->.
1010

1111
**Signature:**
1212

docs/reference/main/generative-ai.generativemodel.generatecontentstream.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
Makes a single streaming call to the model and returns an object containing an iterable stream that iterates over all chunks in the streaming response as well as a promise that returns the final aggregated response.
88

9-
Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided at the time of the initialization.
9+
Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided to [GoogleGenerativeAI.getGenerativeModel()](./generative-ai.googlegenerativeai.getgenerativemodel.md)<!-- -->.
1010

1111
**Signature:**
1212

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ export declare class GenerativeModel
3636

3737
| Method | Modifiers | Description |
3838
| --- | --- | --- |
39-
| [batchEmbedContents(batchEmbedContentRequest, requestOptions)](./generative-ai.generativemodel.batchembedcontents.md) | | <p>Embeds an array of [EmbedContentRequest](./generative-ai.embedcontentrequest.md)<!-- -->s.</p><p>Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided at the time of the initialization.</p> |
40-
| [countTokens(request, requestOptions)](./generative-ai.generativemodel.counttokens.md) | | <p>Counts the tokens in the provided request.</p><p>Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided at the time of the initialization.</p> |
41-
| [embedContent(request, requestOptions)](./generative-ai.generativemodel.embedcontent.md) | | <p>Embeds the provided content.</p><p>Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided at the time of the initialization.</p> |
42-
| [generateContent(request, requestOptions)](./generative-ai.generativemodel.generatecontent.md) | | <p>Makes a single non-streaming call to the model and returns an object containing a single [GenerateContentResponse](./generative-ai.generatecontentresponse.md)<!-- -->.</p><p>Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided at the time of the initialization.</p> |
43-
| [generateContentStream(request, requestOptions)](./generative-ai.generativemodel.generatecontentstream.md) | | <p>Makes a single streaming call to the model and returns an object containing an iterable stream that iterates over all chunks in the streaming response as well as a promise that returns the final aggregated response.</p><p>Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided at the time of the initialization.</p> |
39+
| [batchEmbedContents(batchEmbedContentRequest, requestOptions)](./generative-ai.generativemodel.batchembedcontents.md) | | <p>Embeds an array of [EmbedContentRequest](./generative-ai.embedcontentrequest.md)<!-- -->s.</p><p>Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided to [GoogleGenerativeAI.getGenerativeModel()](./generative-ai.googlegenerativeai.getgenerativemodel.md)<!-- -->.</p> |
40+
| [countTokens(request, requestOptions)](./generative-ai.generativemodel.counttokens.md) | | <p>Counts the tokens in the provided request.</p><p>Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided to [GoogleGenerativeAI.getGenerativeModel()](./generative-ai.googlegenerativeai.getgenerativemodel.md)<!-- -->.</p> |
41+
| [embedContent(request, requestOptions)](./generative-ai.generativemodel.embedcontent.md) | | <p>Embeds the provided content.</p><p>Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided to [GoogleGenerativeAI.getGenerativeModel()](./generative-ai.googlegenerativeai.getgenerativemodel.md)<!-- -->.</p> |
42+
| [generateContent(request, requestOptions)](./generative-ai.generativemodel.generatecontent.md) | | <p>Makes a single non-streaming call to the model and returns an object containing a single [GenerateContentResponse](./generative-ai.generatecontentresponse.md)<!-- -->.</p><p>Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided to [GoogleGenerativeAI.getGenerativeModel()](./generative-ai.googlegenerativeai.getgenerativemodel.md)<!-- -->.</p> |
43+
| [generateContentStream(request, requestOptions)](./generative-ai.generativemodel.generatecontentstream.md) | | <p>Makes a single streaming call to the model and returns an object containing an iterable stream that iterates over all chunks in the streaming response as well as a promise that returns the final aggregated response.</p><p>Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided to [GoogleGenerativeAI.getGenerativeModel()](./generative-ai.googlegenerativeai.getgenerativemodel.md)<!-- -->.</p> |
4444
| [startChat(startChatParams)](./generative-ai.generativemodel.startchat.md) | | Gets a new [ChatSession](./generative-ai.chatsession.md) instance which can be used for multi-turn chats. |
4545

docs/reference/main/generative-ai.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
| [ExecutableCodeLanguage](./generative-ai.executablecodelanguage.md) | |
2525
| [FinishReason](./generative-ai.finishreason.md) | Reason that a candidate finished. |
2626
| [FunctionCallingMode](./generative-ai.functioncallingmode.md) | |
27-
| [FunctionDeclarationSchemaType](./generative-ai.functiondeclarationschematype.md) | Contains the list of OpenAPI data types as defined by https://swagger.io/docs/specification/data-models/data-types/ |
2827
| [HarmBlockThreshold](./generative-ai.harmblockthreshold.md) | Threshold above which a prompt or candidate will be blocked. |
2928
| [HarmCategory](./generative-ai.harmcategory.md) | Harm categories that would cause prompts or candidates to be blocked. |
3029
| [HarmProbability](./generative-ai.harmprobability.md) | Probability that a prompt or candidate matches a harm category. |
3130
| [Outcome](./generative-ai.outcome.md) | Possible outcomes of code execution. |
31+
| [SchemaType](./generative-ai.schematype.md) | Contains the list of OpenAPI data types as defined by https://swagger.io/docs/specification/data-models/data-types/ |
3232
| [TaskType](./generative-ai.tasktype.md) | Task type for embedding content. |
3333

3434
## Interfaces

docs/reference/main/generative-ai.schema.items.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
## Schema.items property
66

7-
Optional. The items of the property. [FunctionDeclarationSchema](./generative-ai.functiondeclarationschema.md)
7+
Optional. The items of the property.
88

99
**Signature:**
1010

1111
```typescript
12-
items?: FunctionDeclarationSchema;
12+
items?: Schema;
1313
```

0 commit comments

Comments
 (0)