Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a type definitions for response_schema and function calling #193

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/silver-cats-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@google/generative-ai": patch
---

Fix a schema type for response_schema and function calling
24 changes: 3 additions & 21 deletions common/api-review/generative-ai-server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,21 +267,7 @@ export interface FunctionCallPart {
export interface FunctionDeclaration {
description?: string;
name: string;
parameters?: FunctionDeclarationSchema;
}

// @public
export interface FunctionDeclarationSchema {
description?: string;
properties: {
[k: string]: FunctionDeclarationSchemaProperty;
};
required?: string[];
type: FunctionDeclarationSchemaType;
}

// @public
export interface FunctionDeclarationSchemaProperty extends Schema {
parameters?: Schema;
}

// @public
Expand Down Expand Up @@ -417,10 +403,6 @@ export interface RequestOptions {
timeout?: number;
}

// @public
export interface ResponseSchema extends Schema {
}

// @public
export interface RpcStatus {
code: number;
Expand All @@ -434,10 +416,10 @@ export interface Schema {
enum?: string[];
example?: unknown;
format?: string;
items?: FunctionDeclarationSchema;
items?: Schema;
nullable?: boolean;
properties?: {
[k: string]: FunctionDeclarationSchema;
[k: string]: Schema;
};
required?: string[];
type?: FunctionDeclarationSchemaType;
Expand Down
26 changes: 4 additions & 22 deletions common/api-review/generative-ai.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,21 +319,7 @@ export interface FunctionCallPart {
export interface FunctionDeclaration {
description?: string;
name: string;
parameters?: FunctionDeclarationSchema;
}

// @public
export interface FunctionDeclarationSchema {
description?: string;
properties: {
[k: string]: FunctionDeclarationSchemaProperty;
};
required?: string[];
type: FunctionDeclarationSchemaType;
}

// @public
export interface FunctionDeclarationSchemaProperty extends Schema {
parameters?: Schema;
}

// @public
Expand Down Expand Up @@ -440,7 +426,7 @@ export interface GenerationConfig {
// (undocumented)
maxOutputTokens?: number;
responseMimeType?: string;
responseSchema?: ResponseSchema;
responseSchema?: Schema;
// (undocumented)
stopSequences?: string[];
// (undocumented)
Expand Down Expand Up @@ -630,10 +616,6 @@ export interface RequestOptions {
timeout?: number;
}

// @public
export interface ResponseSchema extends Schema {
}

// @public
export interface SafetyRating {
// (undocumented)
Expand All @@ -656,10 +638,10 @@ export interface Schema {
enum?: string[];
example?: unknown;
format?: string;
items?: FunctionDeclarationSchema;
items?: Schema;
nullable?: boolean;
properties?: {
[k: string]: FunctionDeclarationSchema;
[k: string]: Schema;
};
required?: string[];
type?: FunctionDeclarationSchemaType;
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/main/generative-ai.functiondeclaration.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ export declare interface FunctionDeclaration
| --- | --- | --- | --- |
| [description?](./generative-ai.functiondeclaration.description.md) | | string | _(Optional)_ Optional. Description and purpose of the function. Model uses it to decide how and whether to call the function. |
| [name](./generative-ai.functiondeclaration.name.md) | | string | The name of the function to call. Must start with a letter or an underscore. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a max length of 64. |
| [parameters?](./generative-ai.functiondeclaration.parameters.md) | | [FunctionDeclarationSchema](./generative-ai.functiondeclarationschema.md) | _(Optional)_ Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. string Key: the name of the parameter. Parameter names are case sensitive. Schema Value: the Schema defining the type used for the parameter. For function with no parameters, this can be left unset. |
| [parameters?](./generative-ai.functiondeclaration.parameters.md) | | [Schema](./generative-ai.schema.md) | _(Optional)_ Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. string Key: the name of the parameter. Parameter names are case sensitive. Schema Value: the Schema defining the type used for the parameter. For function with no parameters, this can be left unset. |

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Optional. Describes the parameters to this function in JSON Schema Object format
**Signature:**

```typescript
parameters?: FunctionDeclarationSchema;
parameters?: Schema;
```

## Example
Expand Down

This file was deleted.

23 changes: 0 additions & 23 deletions docs/reference/main/generative-ai.functiondeclarationschema.md

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion docs/reference/main/generative-ai.generationconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface GenerationConfig
| [candidateCount?](./generative-ai.generationconfig.candidatecount.md) | | number | _(Optional)_ |
| [maxOutputTokens?](./generative-ai.generationconfig.maxoutputtokens.md) | | number | _(Optional)_ |
| [responseMimeType?](./generative-ai.generationconfig.responsemimetype.md) | | string | _(Optional)_ Output response mimetype of the generated candidate text. Supported mimetype: <code>text/plain</code>: (default) Text output. <code>application/json</code>: JSON response in the candidates. |
| [responseSchema?](./generative-ai.generationconfig.responseschema.md) | | [ResponseSchema](./generative-ai.responseschema.md) | _(Optional)_ Output response schema of the generated candidate text. Note: This only applies when the specified <code>responseMIMEType</code> supports a schema; currently this is limited to <code>application/json</code>. |
| [responseSchema?](./generative-ai.generationconfig.responseschema.md) | | [Schema](./generative-ai.schema.md) | _(Optional)_ Output response schema of the generated candidate text. Note: This only applies when the specified <code>responseMIMEType</code> supports a schema; currently this is limited to <code>application/json</code>. |
| [stopSequences?](./generative-ai.generationconfig.stopsequences.md) | | string\[\] | _(Optional)_ |
| [temperature?](./generative-ai.generationconfig.temperature.md) | | number | _(Optional)_ |
| [topK?](./generative-ai.generationconfig.topk.md) | | number | _(Optional)_ |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ Output response schema of the generated candidate text. Note: This only applies
**Signature:**

```typescript
responseSchema?: ResponseSchema;
responseSchema?: Schema;
```
3 changes: 0 additions & 3 deletions docs/reference/main/generative-ai.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@
| [FunctionCallingConfig](./generative-ai.functioncallingconfig.md) | |
| [FunctionCallPart](./generative-ai.functioncallpart.md) | Content part interface if the part represents a FunctionCall. |
| [FunctionDeclaration](./generative-ai.functiondeclaration.md) | Structured representation of a function declaration as defined by the \[OpenAPI 3.0 specification\](https://spec.openapis.org/oas/v3.0.3). Included in this declaration are the function name and parameters. This FunctionDeclaration is a representation of a block of code that can be used as a Tool by the model and executed by the client. |
| [FunctionDeclarationSchema](./generative-ai.functiondeclarationschema.md) | Schema for parameters passed to [FunctionDeclaration.parameters](./generative-ai.functiondeclaration.parameters.md)<!-- -->. |
| [FunctionDeclarationSchemaProperty](./generative-ai.functiondeclarationschemaproperty.md) | Schema for top-level function declaration |
| [FunctionDeclarationsTool](./generative-ai.functiondeclarationstool.md) | A FunctionDeclarationsTool is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model. |
| [FunctionResponse](./generative-ai.functionresponse.md) | The result output from a \[FunctionCall\] that contains a string representing the \[FunctionDeclaration.name\] and a structured JSON object containing any output from the function is used as context to the model. This should contain the result of a \[FunctionCall\] made based on model prediction. |
| [FunctionResponsePart](./generative-ai.functionresponsepart.md) | Content part interface if the part represents FunctionResponse. |
Expand All @@ -77,7 +75,6 @@
| [ModelParams](./generative-ai.modelparams.md) | Params passed to [GoogleGenerativeAI.getGenerativeModel()](./generative-ai.googlegenerativeai.getgenerativemodel.md)<!-- -->. |
| [PromptFeedback](./generative-ai.promptfeedback.md) | If the prompt was blocked, this will be populated with <code>blockReason</code> and the relevant <code>safetyRatings</code>. |
| [RequestOptions](./generative-ai.requestoptions.md) | Params passed to getGenerativeModel() or GoogleAIFileManager(). |
| [ResponseSchema](./generative-ai.responseschema.md) | Schema passed to <code>GenerationConfig.responseSchema</code> |
| [SafetyRating](./generative-ai.safetyrating.md) | A safety rating associated with a [GenerateContentCandidate](./generative-ai.generatecontentcandidate.md) |
| [SafetySetting](./generative-ai.safetysetting.md) | Safety setting that can be sent as part of request parameters. |
| [Schema](./generative-ai.schema.md) | Schema is used to define the format of input/output data. Represents a select subset of an OpenAPI 3.0 schema object. More fields may be added in the future as needed. |
Expand Down
15 changes: 0 additions & 15 deletions docs/reference/main/generative-ai.responseschema.md

This file was deleted.

4 changes: 2 additions & 2 deletions docs/reference/main/generative-ai.schema.items.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

## Schema.items property

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

**Signature:**

```typescript
items?: FunctionDeclarationSchema;
items?: Schema;
```
4 changes: 2 additions & 2 deletions docs/reference/main/generative-ai.schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ export interface Schema
| [enum?](./generative-ai.schema.enum.md) | | string\[\] | _(Optional)_ Optional. The enum of the property. |
| [example?](./generative-ai.schema.example.md) | | unknown | _(Optional)_ Optional. The example of the property. |
| [format?](./generative-ai.schema.format.md) | | string | _(Optional)_ Optional. The format of the property. |
| [items?](./generative-ai.schema.items.md) | | [FunctionDeclarationSchema](./generative-ai.functiondeclarationschema.md) | _(Optional)_ Optional. The items of the property. [FunctionDeclarationSchema](./generative-ai.functiondeclarationschema.md) |
| [items?](./generative-ai.schema.items.md) | | [Schema](./generative-ai.schema.md) | _(Optional)_ Optional. The items of the property. |
| [nullable?](./generative-ai.schema.nullable.md) | | boolean | _(Optional)_ Optional. Whether the property is nullable. |
| [properties?](./generative-ai.schema.properties.md) | | { \[k: string\]: [FunctionDeclarationSchema](./generative-ai.functiondeclarationschema.md)<!-- -->; } | _(Optional)_ Optional. Map of [FunctionDeclarationSchema](./generative-ai.functiondeclarationschema.md)<!-- -->. |
| [properties?](./generative-ai.schema.properties.md) | | { \[k: string\]: [Schema](./generative-ai.schema.md)<!-- -->; } | _(Optional)_ Optional. Map of [Schema](./generative-ai.schema.md)<!-- -->. |
| [required?](./generative-ai.schema.required.md) | | string\[\] | _(Optional)_ Optional. Array of required property. |
| [type?](./generative-ai.schema.type.md) | | [FunctionDeclarationSchemaType](./generative-ai.functiondeclarationschematype.md) | _(Optional)_ Optional. The type of the property. [FunctionDeclarationSchemaType](./generative-ai.functiondeclarationschematype.md)<!-- -->. |

4 changes: 2 additions & 2 deletions docs/reference/main/generative-ai.schema.properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

## Schema.properties property

Optional. Map of [FunctionDeclarationSchema](./generative-ai.functiondeclarationschema.md)<!-- -->.
Optional. Map of [Schema](./generative-ai.schema.md)<!-- -->.

**Signature:**

```typescript
properties?: {
[k: string]: FunctionDeclarationSchema;
[k: string]: Schema;
};
```
2 changes: 1 addition & 1 deletion docs/reference/server/generative-ai.functiondeclaration.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ export declare interface FunctionDeclaration
| --- | --- | --- | --- |
| [description?](./generative-ai.functiondeclaration.description.md) | | string | _(Optional)_ Optional. Description and purpose of the function. Model uses it to decide how and whether to call the function. |
| [name](./generative-ai.functiondeclaration.name.md) | | string | The name of the function to call. Must start with a letter or an underscore. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a max length of 64. |
| [parameters?](./generative-ai.functiondeclaration.parameters.md) | | [FunctionDeclarationSchema](./generative-ai.functiondeclarationschema.md) | _(Optional)_ Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. string Key: the name of the parameter. Parameter names are case sensitive. Schema Value: the Schema defining the type used for the parameter. For function with no parameters, this can be left unset. |
| [parameters?](./generative-ai.functiondeclaration.parameters.md) | | [Schema](./generative-ai.schema.md) | _(Optional)_ Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. string Key: the name of the parameter. Parameter names are case sensitive. Schema Value: the Schema defining the type used for the parameter. For function with no parameters, this can be left unset. |

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Optional. Describes the parameters to this function in JSON Schema Object format
**Signature:**

```typescript
parameters?: FunctionDeclarationSchema;
parameters?: Schema;
```

## Example
Expand Down

This file was deleted.

23 changes: 0 additions & 23 deletions docs/reference/server/generative-ai.functiondeclarationschema.md

This file was deleted.

This file was deleted.

This file was deleted.

Loading