-
Notifications
You must be signed in to change notification settings - Fork 65
Open
Labels
api: aiplatformIssues related to the googleapis/nodejs-vertexai API.Issues related to the googleapis/nodejs-vertexai API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Environment details
- Programming language: TypeScript
- OS: Any
- Language runtime version: Node.js 18+
- Package version: ^1.10.0
Steps to reproduce
- Import and use the
Schemainterface from@google-cloud/vertexai. - Attempt to define schema fields like
additionalProperties,minProperties,maxProperties,anyOf, etc., which are supported by the Vertex AI REST API schema specification but are not present in the TypeScript interface provided by the SDK. - Observe that TypeScript raises type errors even though the API accepts those fields at runtime.
Suggested Fix
Please update the Schema type definition in the SDK to match the actual REST API capabilities. Below is a more accurate version of the types/common.ts interface:
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** This file contains interfaces that are usable in the types folder. */
/**
* The list of OpenAPI data types
* as defined by https://swagger.io/docs/specification/data-models/data-types/
*/
export enum SchemaType {
/** String type. */
STRING = "STRING",
/** Number type. */
NUMBER = "NUMBER",
/** Integer type. */
INTEGER = "INTEGER",
/** Boolean type. */
BOOLEAN = "BOOLEAN",
/** Array type. */
ARRAY = "ARRAY",
/** Object type. */
OBJECT = "OBJECT"
}
// Helper type to map SchemaType to its corresponding value type
type SchemaValueByType<T extends SchemaType | undefined> =
T extends SchemaType.STRING ? string :
T extends SchemaType.NUMBER ? number :
T extends SchemaType.INTEGER ? number :
T extends SchemaType.BOOLEAN ? boolean :
T extends SchemaType.ARRAY ? unknown[] :
T extends SchemaType.OBJECT ? Record<string, unknown> :
unknown;
/**
* 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.
*/
export type Schema<T extends SchemaType> = {
type?: T;
format?: string;
title?: string;
description?: string;
nullable?: boolean;
default?: SchemaValueByType<T>; // ahora depende del tipo
example?: SchemaValueByType<T>; // también depende del tipo
items?: Schema;
minItems?: string;
maxItems?: string;
enum?: string[];
properties?: {
[key: string]: Schema;
};
propertyOrdering?: string[];
required?: string[];
minProperties?: string;
maxProperties?: string;
minimum?: number;
maximum?: number;
minLength?: string;
maxLength?: string;
pattern?: string;
anyOf?: Schema[];
additionalProperties?: boolean | Schema;
ref?: string;
defs?: {
[key: string]: Schema;
};
};This change would allow developers to use the client library in type-safe ways that are aligned with the official Vertex AI schema documentation and API behavior.
Thanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api: aiplatformIssues related to the googleapis/nodejs-vertexai API.Issues related to the googleapis/nodejs-vertexai API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.