Skip to content

Commit a4e68aa

Browse files
committed
Fix typings for functionDeclaration.parameters.
1 parent 30de503 commit a4e68aa

File tree

5 files changed

+22
-13
lines changed

5 files changed

+22
-13
lines changed

.changeset/rotten-taxis-allow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@firebase/vertexai': patch
3+
---
4+
5+
Fix typings for functionDeclaration.parameters.

common/api-review/vertexai.api.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ export interface FunctionCallPart {
280280
export interface FunctionDeclaration {
281281
description: string;
282282
name: string;
283-
parameters?: ObjectSchemaInterface;
283+
parameters?: ObjectSchema | ObjectSchemaRequest;
284284
}
285285

286286
// @public
@@ -701,9 +701,8 @@ export class ObjectSchema extends Schema {
701701
}
702702

703703
// @public
704-
export interface ObjectSchemaInterface extends SchemaInterface {
705-
// (undocumented)
706-
optionalProperties?: string[];
704+
export interface ObjectSchemaRequest extends SchemaRequest {
705+
optionalProperties?: never;
707706
// (undocumented)
708707
type: SchemaType.OBJECT;
709708
}

packages/ai/src/requests/schema-builder.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ import {
2121
SchemaInterface,
2222
SchemaType,
2323
SchemaParams,
24-
SchemaRequest,
25-
ObjectSchemaInterface
24+
SchemaRequest
2625
} from '../types/schema';
2726

2827
/**
@@ -292,7 +291,7 @@ export class ObjectSchema extends Schema {
292291
if (required.length > 0) {
293292
obj.required = required;
294293
}
295-
delete (obj as ObjectSchemaInterface).optionalProperties;
294+
delete obj.optionalProperties;
296295
return obj as SchemaRequest;
297296
}
298297
}

packages/ai/src/types/requests.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { TypedSchema } from '../requests/schema-builder';
18+
import { ObjectSchema, TypedSchema } from '../requests/schema-builder';
1919
import { Content, Part } from './content';
2020
import {
2121
FunctionCallingMode,
@@ -24,7 +24,7 @@ import {
2424
HarmCategory,
2525
ResponseModality
2626
} from './enums';
27-
import { ObjectSchemaInterface, SchemaRequest } from './schema';
27+
import { ObjectSchemaRequest, SchemaRequest } from './schema';
2828

2929
/**
3030
* Base parameters for a number of methods.
@@ -193,7 +193,7 @@ export declare interface FunctionDeclaration {
193193
* format. Reflects the Open API 3.03 Parameter Object. Parameter names are
194194
* case-sensitive. For a function with no parameters, this can be left unset.
195195
*/
196-
parameters?: ObjectSchemaInterface;
196+
parameters?: ObjectSchema | ObjectSchemaRequest;
197197
}
198198

199199
/**

packages/ai/src/types/schema.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,16 @@ export interface SchemaInterface extends SchemaShared<SchemaInterface> {
114114
}
115115

116116
/**
117-
* Interface for {@link ObjectSchema} class.
117+
* Interface for JSON parameters in {@link SchemaType.OBJECT} format when
118+
* not using the {@link ObjectSchema} helper.
118119
* @public
119120
*/
120-
export interface ObjectSchemaInterface extends SchemaInterface {
121+
export interface ObjectSchemaRequest extends SchemaRequest {
121122
type: SchemaType.OBJECT;
122-
optionalProperties?: string[];
123+
/**
124+
* This is not a property accepted in the final request to the backend, but is
125+
* a client-side convenience property that is only usable by constructing
126+
* a schema through the `Schema.object()` helper method.
127+
*/
128+
optionalProperties?: never;
123129
}

0 commit comments

Comments
 (0)