Skip to content

[VertexAI] Fix typings for functionDeclaration.parameters. #8948

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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/rotten-taxis-allow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@firebase/vertexai': patch
---

Fix typings for functionDeclaration.parameters.
7 changes: 3 additions & 4 deletions common/api-review/vertexai.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export interface FunctionCallPart {
export interface FunctionDeclaration {
description: string;
name: string;
parameters?: ObjectSchemaInterface;
parameters?: ObjectSchema | ObjectSchemaRequest;
}

// @public
Expand Down Expand Up @@ -567,9 +567,8 @@ export class ObjectSchema extends Schema {
}

// @public
export interface ObjectSchemaInterface extends SchemaInterface {
// (undocumented)
optionalProperties?: string[];
export interface ObjectSchemaRequest extends SchemaRequest {
optionalProperties?: never;
// (undocumented)
type: SchemaType.OBJECT;
}
Expand Down
4 changes: 2 additions & 2 deletions docs-devsite/_toc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,8 @@ toc:
path: /docs/reference/js/vertexai.numberschema.md
- title: ObjectSchema
path: /docs/reference/js/vertexai.objectschema.md
- title: ObjectSchemaInterface
path: /docs/reference/js/vertexai.objectschemainterface.md
- title: ObjectSchemaRequest
path: /docs/reference/js/vertexai.objectschemarequest.md
- title: PromptFeedback
path: /docs/reference/js/vertexai.promptfeedback.md
- title: RequestOptions
Expand Down
4 changes: 2 additions & 2 deletions docs-devsite/vertexai.functiondeclaration.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export declare interface FunctionDeclaration
| --- | --- | --- |
| [description](./vertexai.functiondeclaration.md#functiondeclarationdescription) | string | Description and purpose of the function. Model uses it to decide how and whether to call the function. |
| [name](./vertexai.functiondeclaration.md#functiondeclarationname) | 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](./vertexai.functiondeclaration.md#functiondeclarationparameters) | [ObjectSchemaInterface](./vertexai.objectschemainterface.md#objectschemainterface_interface) | Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. Parameter names are case-sensitive. For a function with no parameters, this can be left unset. |
| [parameters](./vertexai.functiondeclaration.md#functiondeclarationparameters) | [ObjectSchema](./vertexai.objectschema.md#objectschema_class) \| [ObjectSchemaRequest](./vertexai.objectschemarequest.md#objectschemarequest_interface) | Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. Parameter names are case-sensitive. For a function with no parameters, this can be left unset. |

## FunctionDeclaration.description

Expand Down Expand Up @@ -53,5 +53,5 @@ Optional. Describes the parameters to this function in JSON Schema Object format
<b>Signature:</b>

```typescript
parameters?: ObjectSchemaInterface;
parameters?: ObjectSchema | ObjectSchemaRequest;
```
2 changes: 1 addition & 1 deletion docs-devsite/vertexai.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ The Vertex AI in Firebase Web SDK.
| [InlineDataPart](./vertexai.inlinedatapart.md#inlinedatapart_interface) | Content part interface if the part represents an image. |
| [ModalityTokenCount](./vertexai.modalitytokencount.md#modalitytokencount_interface) | Represents token counting info for a single modality. |
| [ModelParams](./vertexai.modelparams.md#modelparams_interface) | Params passed to [getGenerativeModel()](./vertexai.md#getgenerativemodel_e3037c9)<!-- -->. |
| [ObjectSchemaInterface](./vertexai.objectschemainterface.md#objectschemainterface_interface) | Interface for [ObjectSchema](./vertexai.objectschema.md#objectschema_class) class. |
| [ObjectSchemaRequest](./vertexai.objectschemarequest.md#objectschemarequest_interface) | Interface for JSON parameters in [SchemaType.OBJECT](./vertexai.md#schematypeobject_enummember) format when not using the [ObjectSchema](./vertexai.objectschema.md#objectschema_class) helper. |
| [PromptFeedback](./vertexai.promptfeedback.md#promptfeedback_interface) | If the prompt was blocked, this will be populated with <code>blockReason</code> and the relevant <code>safetyRatings</code>. |
| [RequestOptions](./vertexai.requestoptions.md#requestoptions_interface) | Params passed to [getGenerativeModel()](./vertexai.md#getgenerativemodel_e3037c9)<!-- -->. |
| [RetrievedContextAttribution](./vertexai.retrievedcontextattribution.md#retrievedcontextattribution_interface) | |
Expand Down
43 changes: 0 additions & 43 deletions docs-devsite/vertexai.objectschemainterface.md

This file was deleted.

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

# ObjectSchemaRequest interface
Interface for JSON parameters in [SchemaType.OBJECT](./vertexai.md#schematypeobject_enummember) format when not using the [ObjectSchema](./vertexai.objectschema.md#objectschema_class) helper.

<b>Signature:</b>

```typescript
export interface ObjectSchemaRequest extends SchemaRequest
```
<b>Extends:</b> [SchemaRequest](./vertexai.schemarequest.md#schemarequest_interface)

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [optionalProperties](./vertexai.objectschemarequest.md#objectschemarequestoptionalproperties) | never | This is not a property accepted in the final request to the backend, but is a client-side convenience property that is only usable by constructing a schema through the <code>Schema.object()</code> helper method. |
| [type](./vertexai.objectschemarequest.md#objectschemarequesttype) | [SchemaType.OBJECT](./vertexai.md#schematypeobject_enummember) | |

## ObjectSchemaRequest.optionalProperties

This is not a property accepted in the final request to the backend, but is a client-side convenience property that is only usable by constructing a schema through the `Schema.object()` helper method.

<b>Signature:</b>

```typescript
optionalProperties?: never;
```

## ObjectSchemaRequest.type

<b>Signature:</b>

```typescript
type: SchemaType.OBJECT;
```
5 changes: 2 additions & 3 deletions packages/vertexai/src/requests/schema-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import {
SchemaInterface,
SchemaType,
SchemaParams,
SchemaRequest,
ObjectSchemaInterface
SchemaRequest
} from '../types/schema';

/**
Expand Down Expand Up @@ -286,7 +285,7 @@ export class ObjectSchema extends Schema {
if (required.length > 0) {
obj.required = required;
}
delete (obj as ObjectSchemaInterface).optionalProperties;
delete obj.optionalProperties;
return obj as SchemaRequest;
}
}
6 changes: 3 additions & 3 deletions packages/vertexai/src/types/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
* limitations under the License.
*/

import { TypedSchema } from '../requests/schema-builder';
import { ObjectSchema, TypedSchema } from '../requests/schema-builder';
import { Content, Part } from './content';
import {
FunctionCallingMode,
HarmBlockMethod,
HarmBlockThreshold,
HarmCategory
} from './enums';
import { ObjectSchemaInterface, SchemaRequest } from './schema';
import { ObjectSchemaRequest, SchemaRequest } from './schema';

/**
* Base parameters for a number of methods.
Expand Down Expand Up @@ -175,7 +175,7 @@ export declare interface FunctionDeclaration {
* format. Reflects the Open API 3.03 Parameter Object. Parameter names are
* case-sensitive. For a function with no parameters, this can be left unset.
*/
parameters?: ObjectSchemaInterface;
parameters?: ObjectSchema | ObjectSchemaRequest;
}

/**
Expand Down
12 changes: 9 additions & 3 deletions packages/vertexai/src/types/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,16 @@ export interface SchemaInterface extends SchemaShared<SchemaInterface> {
}

/**
* Interface for {@link ObjectSchema} class.
* Interface for JSON parameters in {@link SchemaType.OBJECT} format when
* not using the {@link ObjectSchema} helper.
* @public
*/
export interface ObjectSchemaInterface extends SchemaInterface {
export interface ObjectSchemaRequest extends SchemaRequest {
type: SchemaType.OBJECT;
optionalProperties?: string[];
/**
* This is not a property accepted in the final request to the backend, but is
* a client-side convenience property that is only usable by constructing
* a schema through the `Schema.object()` helper method.
*/
optionalProperties?: never;
}
Loading