diff --git a/packages/google-cloud-vectorsearch/.prettierignore b/packages/google-cloud-vectorsearch/.prettierignore new file mode 100644 index 000000000000..9340ad9b86d3 --- /dev/null +++ b/packages/google-cloud-vectorsearch/.prettierignore @@ -0,0 +1,6 @@ +**/node_modules +**/coverage +test/fixtures +build/ +docs/ +protos/ diff --git a/packages/google-cloud-vectorsearch/.prettierrc.js b/packages/google-cloud-vectorsearch/.prettierrc.js new file mode 100644 index 000000000000..7649ee3c254e --- /dev/null +++ b/packages/google-cloud-vectorsearch/.prettierrc.js @@ -0,0 +1,22 @@ +// Copyright 2026 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 is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/packages/google-cloud-vectorsearch/protos/google/cloud/vectorsearch/v1beta/data_object_search_service.proto b/packages/google-cloud-vectorsearch/protos/google/cloud/vectorsearch/v1beta/data_object_search_service.proto index a636c829627d..3ae3f5f85386 100644 --- a/packages/google-cloud-vectorsearch/protos/google/cloud/vectorsearch/v1beta/data_object_search_service.proto +++ b/packages/google-cloud-vectorsearch/protos/google/cloud/vectorsearch/v1beta/data_object_search_service.proto @@ -24,6 +24,7 @@ import "google/cloud/vectorsearch/v1beta/common.proto"; import "google/cloud/vectorsearch/v1beta/data_object.proto"; import "google/cloud/vectorsearch/v1beta/embedding_config.proto"; import "google/protobuf/struct.proto"; +import "google/rpc/status.proto"; option csharp_namespace = "Google.Cloud.VectorSearch.V1Beta"; option go_package = "cloud.google.com/go/vectorsearch/apiv1beta/vectorsearchpb;vectorsearchpb"; @@ -325,6 +326,10 @@ message SearchResponseMetadata { // K-Nearest Neighbor (KNN) index engine. bool used_knn = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; } + + // Output only. Warnings or non-fatal errors that occurred during execution. + repeated google.rpc.Status warnings = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; } // Response for a search request. @@ -453,6 +458,13 @@ message Ranker { // Reciprocal Rank Fusion ranking. ReciprocalRankFusion rrf = 1; } + + // The reranker to use for final ranking of the results combined by the + // ranker. + oneof reranker { + // Optional. Vertex AI ranking. + VertexRanker vertex_ranker = 2 [(google.api.field_behavior) = OPTIONAL]; + } } // Defines the Reciprocal Rank Fusion (RRF) algorithm for result ranking. @@ -461,6 +473,39 @@ message ReciprocalRankFusion { repeated double weights = 1 [(google.api.field_behavior) = REQUIRED]; } +// Defines a ranker using the Vertex AI ranking service. +// See https://cloud.google.com/generative-ai-app-builder/docs/ranking for +// details. +message VertexRanker { + // The record spec for text search. + message TextRecordSpec { + // Required. The query against which the records are ranked and scored. + string query = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The template used to generate the record's title. + string title_template = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The template used to generate the record's content. + string content_template = 3 [(google.api.field_behavior) = OPTIONAL]; + } + + // The record specification for ranking. At least one record spec must be + // set. + oneof record_spec { + // The record spec for text search. + TextRecordSpec text_record_spec = 6; + } + + // Required. The model used for ranking documents. The list of available + // models is described in + // https://docs.cloud.google.com/generative-ai-app-builder/docs/ranking#models. + // Currently, only `semantic-ranker-fast@latest` is supported. + string model = 4 [(google.api.field_behavior) = REQUIRED]; + + // Required. The number of documents to be processed for ranking. + int32 top_n = 5 [(google.api.field_behavior) = REQUIRED]; +} + // A response from a batch search operation. message BatchSearchDataObjectsResponse { // Output only. A list of search responses, one for each request in the batch. diff --git a/packages/google-cloud-vectorsearch/protos/protos.d.ts b/packages/google-cloud-vectorsearch/protos/protos.d.ts index 27172cf01fd3..2b0fadd43a66 100644 --- a/packages/google-cloud-vectorsearch/protos/protos.d.ts +++ b/packages/google-cloud-vectorsearch/protos/protos.d.ts @@ -9425,6 +9425,9 @@ export namespace google { /** SearchResponseMetadata usedKnn */ usedKnn?: (boolean|null); + + /** SearchResponseMetadata warnings */ + warnings?: (google.rpc.IStatus[]|null); } /** Represents a SearchResponseMetadata. */ @@ -9442,6 +9445,9 @@ export namespace google { /** SearchResponseMetadata usedKnn. */ public usedKnn?: (boolean|null); + /** SearchResponseMetadata warnings. */ + public warnings: google.rpc.IStatus[]; + /** SearchResponseMetadata indexType. */ public indexType?: ("usedIndex"|"usedKnn"); @@ -10388,6 +10394,9 @@ export namespace google { /** Ranker rrf */ rrf?: (google.cloud.vectorsearch.v1beta.IReciprocalRankFusion|null); + + /** Ranker vertexRanker */ + vertexRanker?: (google.cloud.vectorsearch.v1beta.IVertexRanker|null); } /** Represents a Ranker. */ @@ -10402,9 +10411,15 @@ export namespace google { /** Ranker rrf. */ public rrf?: (google.cloud.vectorsearch.v1beta.IReciprocalRankFusion|null); + /** Ranker vertexRanker. */ + public vertexRanker?: (google.cloud.vectorsearch.v1beta.IVertexRanker|null); + /** Ranker ranker. */ public ranker?: "rrf"; + /** Ranker reranker. */ + public reranker?: "vertexRanker"; + /** * Creates a new Ranker instance using the specified properties. * @param [properties] Properties to set @@ -10580,6 +10595,230 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + /** Properties of a VertexRanker. */ + interface IVertexRanker { + + /** VertexRanker textRecordSpec */ + textRecordSpec?: (google.cloud.vectorsearch.v1beta.VertexRanker.ITextRecordSpec|null); + + /** VertexRanker model */ + model?: (string|null); + + /** VertexRanker topN */ + topN?: (number|null); + } + + /** Represents a VertexRanker. */ + class VertexRanker implements IVertexRanker { + + /** + * Constructs a new VertexRanker. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.vectorsearch.v1beta.IVertexRanker); + + /** VertexRanker textRecordSpec. */ + public textRecordSpec?: (google.cloud.vectorsearch.v1beta.VertexRanker.ITextRecordSpec|null); + + /** VertexRanker model. */ + public model: string; + + /** VertexRanker topN. */ + public topN: number; + + /** VertexRanker recordSpec. */ + public recordSpec?: "textRecordSpec"; + + /** + * Creates a new VertexRanker instance using the specified properties. + * @param [properties] Properties to set + * @returns VertexRanker instance + */ + public static create(properties?: google.cloud.vectorsearch.v1beta.IVertexRanker): google.cloud.vectorsearch.v1beta.VertexRanker; + + /** + * Encodes the specified VertexRanker message. Does not implicitly {@link google.cloud.vectorsearch.v1beta.VertexRanker.verify|verify} messages. + * @param message VertexRanker message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.vectorsearch.v1beta.IVertexRanker, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified VertexRanker message, length delimited. Does not implicitly {@link google.cloud.vectorsearch.v1beta.VertexRanker.verify|verify} messages. + * @param message VertexRanker message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.vectorsearch.v1beta.IVertexRanker, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a VertexRanker message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns VertexRanker + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.vectorsearch.v1beta.VertexRanker; + + /** + * Decodes a VertexRanker message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns VertexRanker + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.vectorsearch.v1beta.VertexRanker; + + /** + * Verifies a VertexRanker message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a VertexRanker message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns VertexRanker + */ + public static fromObject(object: { [k: string]: any }): google.cloud.vectorsearch.v1beta.VertexRanker; + + /** + * Creates a plain object from a VertexRanker message. Also converts values to other types if specified. + * @param message VertexRanker + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.vectorsearch.v1beta.VertexRanker, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this VertexRanker to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for VertexRanker + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace VertexRanker { + + /** Properties of a TextRecordSpec. */ + interface ITextRecordSpec { + + /** TextRecordSpec query */ + query?: (string|null); + + /** TextRecordSpec titleTemplate */ + titleTemplate?: (string|null); + + /** TextRecordSpec contentTemplate */ + contentTemplate?: (string|null); + } + + /** Represents a TextRecordSpec. */ + class TextRecordSpec implements ITextRecordSpec { + + /** + * Constructs a new TextRecordSpec. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.vectorsearch.v1beta.VertexRanker.ITextRecordSpec); + + /** TextRecordSpec query. */ + public query: string; + + /** TextRecordSpec titleTemplate. */ + public titleTemplate: string; + + /** TextRecordSpec contentTemplate. */ + public contentTemplate: string; + + /** + * Creates a new TextRecordSpec instance using the specified properties. + * @param [properties] Properties to set + * @returns TextRecordSpec instance + */ + public static create(properties?: google.cloud.vectorsearch.v1beta.VertexRanker.ITextRecordSpec): google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec; + + /** + * Encodes the specified TextRecordSpec message. Does not implicitly {@link google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec.verify|verify} messages. + * @param message TextRecordSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.vectorsearch.v1beta.VertexRanker.ITextRecordSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TextRecordSpec message, length delimited. Does not implicitly {@link google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec.verify|verify} messages. + * @param message TextRecordSpec message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.vectorsearch.v1beta.VertexRanker.ITextRecordSpec, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TextRecordSpec message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TextRecordSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec; + + /** + * Decodes a TextRecordSpec message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TextRecordSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec; + + /** + * Verifies a TextRecordSpec message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a TextRecordSpec message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TextRecordSpec + */ + public static fromObject(object: { [k: string]: any }): google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec; + + /** + * Creates a plain object from a TextRecordSpec message. Also converts values to other types if specified. + * @param message TextRecordSpec + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TextRecordSpec to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for TextRecordSpec + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + /** Properties of a BatchSearchDataObjectsResponse. */ interface IBatchSearchDataObjectsResponse { diff --git a/packages/google-cloud-vectorsearch/protos/protos.js b/packages/google-cloud-vectorsearch/protos/protos.js index 627d48b2b4fa..586eb56869ae 100644 --- a/packages/google-cloud-vectorsearch/protos/protos.js +++ b/packages/google-cloud-vectorsearch/protos/protos.js @@ -23163,6 +23163,7 @@ * @interface ISearchResponseMetadata * @property {google.cloud.vectorsearch.v1beta.SearchResponseMetadata.IIndexInfo|null} [usedIndex] SearchResponseMetadata usedIndex * @property {boolean|null} [usedKnn] SearchResponseMetadata usedKnn + * @property {Array.|null} [warnings] SearchResponseMetadata warnings */ /** @@ -23174,6 +23175,7 @@ * @param {google.cloud.vectorsearch.v1beta.ISearchResponseMetadata=} [properties] Properties to set */ function SearchResponseMetadata(properties) { + this.warnings = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -23196,6 +23198,14 @@ */ SearchResponseMetadata.prototype.usedKnn = null; + /** + * SearchResponseMetadata warnings. + * @member {Array.} warnings + * @memberof google.cloud.vectorsearch.v1beta.SearchResponseMetadata + * @instance + */ + SearchResponseMetadata.prototype.warnings = $util.emptyArray; + // OneOf field names bound to virtual getters and setters var $oneOfFields; @@ -23238,6 +23248,9 @@ $root.google.cloud.vectorsearch.v1beta.SearchResponseMetadata.IndexInfo.encode(message.usedIndex, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); if (message.usedKnn != null && Object.hasOwnProperty.call(message, "usedKnn")) writer.uint32(/* id 2, wireType 0 =*/16).bool(message.usedKnn); + if (message.warnings != null && message.warnings.length) + for (var i = 0; i < message.warnings.length; ++i) + $root.google.rpc.Status.encode(message.warnings[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); return writer; }; @@ -23282,6 +23295,12 @@ message.usedKnn = reader.bool(); break; } + case 3: { + if (!(message.warnings && message.warnings.length)) + message.warnings = []; + message.warnings.push($root.google.rpc.Status.decode(reader, reader.uint32())); + break; + } default: reader.skipType(tag & 7); break; @@ -23333,6 +23352,15 @@ if (typeof message.usedKnn !== "boolean") return "usedKnn: boolean expected"; } + if (message.warnings != null && message.hasOwnProperty("warnings")) { + if (!Array.isArray(message.warnings)) + return "warnings: array expected"; + for (var i = 0; i < message.warnings.length; ++i) { + var error = $root.google.rpc.Status.verify(message.warnings[i]); + if (error) + return "warnings." + error; + } + } return null; }; @@ -23355,6 +23383,16 @@ } if (object.usedKnn != null) message.usedKnn = Boolean(object.usedKnn); + if (object.warnings) { + if (!Array.isArray(object.warnings)) + throw TypeError(".google.cloud.vectorsearch.v1beta.SearchResponseMetadata.warnings: array expected"); + message.warnings = []; + for (var i = 0; i < object.warnings.length; ++i) { + if (typeof object.warnings[i] !== "object") + throw TypeError(".google.cloud.vectorsearch.v1beta.SearchResponseMetadata.warnings: object expected"); + message.warnings[i] = $root.google.rpc.Status.fromObject(object.warnings[i]); + } + } return message; }; @@ -23371,6 +23409,8 @@ if (!options) options = {}; var object = {}; + if (options.arrays || options.defaults) + object.warnings = []; if (message.usedIndex != null && message.hasOwnProperty("usedIndex")) { object.usedIndex = $root.google.cloud.vectorsearch.v1beta.SearchResponseMetadata.IndexInfo.toObject(message.usedIndex, options); if (options.oneofs) @@ -23381,6 +23421,11 @@ if (options.oneofs) object.indexType = "usedKnn"; } + if (message.warnings && message.warnings.length) { + object.warnings = []; + for (var j = 0; j < message.warnings.length; ++j) + object.warnings[j] = $root.google.rpc.Status.toObject(message.warnings[j], options); + } return object; }; @@ -25505,6 +25550,7 @@ * @memberof google.cloud.vectorsearch.v1beta * @interface IRanker * @property {google.cloud.vectorsearch.v1beta.IReciprocalRankFusion|null} [rrf] Ranker rrf + * @property {google.cloud.vectorsearch.v1beta.IVertexRanker|null} [vertexRanker] Ranker vertexRanker */ /** @@ -25530,6 +25576,14 @@ */ Ranker.prototype.rrf = null; + /** + * Ranker vertexRanker. + * @member {google.cloud.vectorsearch.v1beta.IVertexRanker|null|undefined} vertexRanker + * @memberof google.cloud.vectorsearch.v1beta.Ranker + * @instance + */ + Ranker.prototype.vertexRanker = null; + // OneOf field names bound to virtual getters and setters var $oneOfFields; @@ -25544,6 +25598,17 @@ set: $util.oneOfSetter($oneOfFields) }); + /** + * Ranker reranker. + * @member {"vertexRanker"|undefined} reranker + * @memberof google.cloud.vectorsearch.v1beta.Ranker + * @instance + */ + Object.defineProperty(Ranker.prototype, "reranker", { + get: $util.oneOfGetter($oneOfFields = ["vertexRanker"]), + set: $util.oneOfSetter($oneOfFields) + }); + /** * Creates a new Ranker instance using the specified properties. * @function create @@ -25570,6 +25635,8 @@ writer = $Writer.create(); if (message.rrf != null && Object.hasOwnProperty.call(message, "rrf")) $root.google.cloud.vectorsearch.v1beta.ReciprocalRankFusion.encode(message.rrf, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.vertexRanker != null && Object.hasOwnProperty.call(message, "vertexRanker")) + $root.google.cloud.vectorsearch.v1beta.VertexRanker.encode(message.vertexRanker, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); return writer; }; @@ -25610,6 +25677,10 @@ message.rrf = $root.google.cloud.vectorsearch.v1beta.ReciprocalRankFusion.decode(reader, reader.uint32()); break; } + case 2: { + message.vertexRanker = $root.google.cloud.vectorsearch.v1beta.VertexRanker.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -25654,6 +25725,14 @@ return "rrf." + error; } } + if (message.vertexRanker != null && message.hasOwnProperty("vertexRanker")) { + properties.reranker = 1; + { + var error = $root.google.cloud.vectorsearch.v1beta.VertexRanker.verify(message.vertexRanker); + if (error) + return "vertexRanker." + error; + } + } return null; }; @@ -25674,6 +25753,11 @@ throw TypeError(".google.cloud.vectorsearch.v1beta.Ranker.rrf: object expected"); message.rrf = $root.google.cloud.vectorsearch.v1beta.ReciprocalRankFusion.fromObject(object.rrf); } + if (object.vertexRanker != null) { + if (typeof object.vertexRanker !== "object") + throw TypeError(".google.cloud.vectorsearch.v1beta.Ranker.vertexRanker: object expected"); + message.vertexRanker = $root.google.cloud.vectorsearch.v1beta.VertexRanker.fromObject(object.vertexRanker); + } return message; }; @@ -25695,6 +25779,11 @@ if (options.oneofs) object.ranker = "rrf"; } + if (message.vertexRanker != null && message.hasOwnProperty("vertexRanker")) { + object.vertexRanker = $root.google.cloud.vectorsearch.v1beta.VertexRanker.toObject(message.vertexRanker, options); + if (options.oneofs) + object.reranker = "vertexRanker"; + } return object; }; @@ -25956,6 +26045,535 @@ return ReciprocalRankFusion; })(); + v1beta.VertexRanker = (function() { + + /** + * Properties of a VertexRanker. + * @memberof google.cloud.vectorsearch.v1beta + * @interface IVertexRanker + * @property {google.cloud.vectorsearch.v1beta.VertexRanker.ITextRecordSpec|null} [textRecordSpec] VertexRanker textRecordSpec + * @property {string|null} [model] VertexRanker model + * @property {number|null} [topN] VertexRanker topN + */ + + /** + * Constructs a new VertexRanker. + * @memberof google.cloud.vectorsearch.v1beta + * @classdesc Represents a VertexRanker. + * @implements IVertexRanker + * @constructor + * @param {google.cloud.vectorsearch.v1beta.IVertexRanker=} [properties] Properties to set + */ + function VertexRanker(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * VertexRanker textRecordSpec. + * @member {google.cloud.vectorsearch.v1beta.VertexRanker.ITextRecordSpec|null|undefined} textRecordSpec + * @memberof google.cloud.vectorsearch.v1beta.VertexRanker + * @instance + */ + VertexRanker.prototype.textRecordSpec = null; + + /** + * VertexRanker model. + * @member {string} model + * @memberof google.cloud.vectorsearch.v1beta.VertexRanker + * @instance + */ + VertexRanker.prototype.model = ""; + + /** + * VertexRanker topN. + * @member {number} topN + * @memberof google.cloud.vectorsearch.v1beta.VertexRanker + * @instance + */ + VertexRanker.prototype.topN = 0; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * VertexRanker recordSpec. + * @member {"textRecordSpec"|undefined} recordSpec + * @memberof google.cloud.vectorsearch.v1beta.VertexRanker + * @instance + */ + Object.defineProperty(VertexRanker.prototype, "recordSpec", { + get: $util.oneOfGetter($oneOfFields = ["textRecordSpec"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new VertexRanker instance using the specified properties. + * @function create + * @memberof google.cloud.vectorsearch.v1beta.VertexRanker + * @static + * @param {google.cloud.vectorsearch.v1beta.IVertexRanker=} [properties] Properties to set + * @returns {google.cloud.vectorsearch.v1beta.VertexRanker} VertexRanker instance + */ + VertexRanker.create = function create(properties) { + return new VertexRanker(properties); + }; + + /** + * Encodes the specified VertexRanker message. Does not implicitly {@link google.cloud.vectorsearch.v1beta.VertexRanker.verify|verify} messages. + * @function encode + * @memberof google.cloud.vectorsearch.v1beta.VertexRanker + * @static + * @param {google.cloud.vectorsearch.v1beta.IVertexRanker} message VertexRanker message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VertexRanker.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.model != null && Object.hasOwnProperty.call(message, "model")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.model); + if (message.topN != null && Object.hasOwnProperty.call(message, "topN")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.topN); + if (message.textRecordSpec != null && Object.hasOwnProperty.call(message, "textRecordSpec")) + $root.google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec.encode(message.textRecordSpec, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified VertexRanker message, length delimited. Does not implicitly {@link google.cloud.vectorsearch.v1beta.VertexRanker.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.vectorsearch.v1beta.VertexRanker + * @static + * @param {google.cloud.vectorsearch.v1beta.IVertexRanker} message VertexRanker message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VertexRanker.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a VertexRanker message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.vectorsearch.v1beta.VertexRanker + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.vectorsearch.v1beta.VertexRanker} VertexRanker + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VertexRanker.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.vectorsearch.v1beta.VertexRanker(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 6: { + message.textRecordSpec = $root.google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec.decode(reader, reader.uint32()); + break; + } + case 4: { + message.model = reader.string(); + break; + } + case 5: { + message.topN = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a VertexRanker message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.vectorsearch.v1beta.VertexRanker + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.vectorsearch.v1beta.VertexRanker} VertexRanker + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VertexRanker.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a VertexRanker message. + * @function verify + * @memberof google.cloud.vectorsearch.v1beta.VertexRanker + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + VertexRanker.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.textRecordSpec != null && message.hasOwnProperty("textRecordSpec")) { + properties.recordSpec = 1; + { + var error = $root.google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec.verify(message.textRecordSpec); + if (error) + return "textRecordSpec." + error; + } + } + if (message.model != null && message.hasOwnProperty("model")) + if (!$util.isString(message.model)) + return "model: string expected"; + if (message.topN != null && message.hasOwnProperty("topN")) + if (!$util.isInteger(message.topN)) + return "topN: integer expected"; + return null; + }; + + /** + * Creates a VertexRanker message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.vectorsearch.v1beta.VertexRanker + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.vectorsearch.v1beta.VertexRanker} VertexRanker + */ + VertexRanker.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.vectorsearch.v1beta.VertexRanker) + return object; + var message = new $root.google.cloud.vectorsearch.v1beta.VertexRanker(); + if (object.textRecordSpec != null) { + if (typeof object.textRecordSpec !== "object") + throw TypeError(".google.cloud.vectorsearch.v1beta.VertexRanker.textRecordSpec: object expected"); + message.textRecordSpec = $root.google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec.fromObject(object.textRecordSpec); + } + if (object.model != null) + message.model = String(object.model); + if (object.topN != null) + message.topN = object.topN | 0; + return message; + }; + + /** + * Creates a plain object from a VertexRanker message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.vectorsearch.v1beta.VertexRanker + * @static + * @param {google.cloud.vectorsearch.v1beta.VertexRanker} message VertexRanker + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + VertexRanker.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.model = ""; + object.topN = 0; + } + if (message.model != null && message.hasOwnProperty("model")) + object.model = message.model; + if (message.topN != null && message.hasOwnProperty("topN")) + object.topN = message.topN; + if (message.textRecordSpec != null && message.hasOwnProperty("textRecordSpec")) { + object.textRecordSpec = $root.google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec.toObject(message.textRecordSpec, options); + if (options.oneofs) + object.recordSpec = "textRecordSpec"; + } + return object; + }; + + /** + * Converts this VertexRanker to JSON. + * @function toJSON + * @memberof google.cloud.vectorsearch.v1beta.VertexRanker + * @instance + * @returns {Object.} JSON object + */ + VertexRanker.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for VertexRanker + * @function getTypeUrl + * @memberof google.cloud.vectorsearch.v1beta.VertexRanker + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + VertexRanker.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.vectorsearch.v1beta.VertexRanker"; + }; + + VertexRanker.TextRecordSpec = (function() { + + /** + * Properties of a TextRecordSpec. + * @memberof google.cloud.vectorsearch.v1beta.VertexRanker + * @interface ITextRecordSpec + * @property {string|null} [query] TextRecordSpec query + * @property {string|null} [titleTemplate] TextRecordSpec titleTemplate + * @property {string|null} [contentTemplate] TextRecordSpec contentTemplate + */ + + /** + * Constructs a new TextRecordSpec. + * @memberof google.cloud.vectorsearch.v1beta.VertexRanker + * @classdesc Represents a TextRecordSpec. + * @implements ITextRecordSpec + * @constructor + * @param {google.cloud.vectorsearch.v1beta.VertexRanker.ITextRecordSpec=} [properties] Properties to set + */ + function TextRecordSpec(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * TextRecordSpec query. + * @member {string} query + * @memberof google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec + * @instance + */ + TextRecordSpec.prototype.query = ""; + + /** + * TextRecordSpec titleTemplate. + * @member {string} titleTemplate + * @memberof google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec + * @instance + */ + TextRecordSpec.prototype.titleTemplate = ""; + + /** + * TextRecordSpec contentTemplate. + * @member {string} contentTemplate + * @memberof google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec + * @instance + */ + TextRecordSpec.prototype.contentTemplate = ""; + + /** + * Creates a new TextRecordSpec instance using the specified properties. + * @function create + * @memberof google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec + * @static + * @param {google.cloud.vectorsearch.v1beta.VertexRanker.ITextRecordSpec=} [properties] Properties to set + * @returns {google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec} TextRecordSpec instance + */ + TextRecordSpec.create = function create(properties) { + return new TextRecordSpec(properties); + }; + + /** + * Encodes the specified TextRecordSpec message. Does not implicitly {@link google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec.verify|verify} messages. + * @function encode + * @memberof google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec + * @static + * @param {google.cloud.vectorsearch.v1beta.VertexRanker.ITextRecordSpec} message TextRecordSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TextRecordSpec.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.query != null && Object.hasOwnProperty.call(message, "query")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.query); + if (message.titleTemplate != null && Object.hasOwnProperty.call(message, "titleTemplate")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.titleTemplate); + if (message.contentTemplate != null && Object.hasOwnProperty.call(message, "contentTemplate")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.contentTemplate); + return writer; + }; + + /** + * Encodes the specified TextRecordSpec message, length delimited. Does not implicitly {@link google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec + * @static + * @param {google.cloud.vectorsearch.v1beta.VertexRanker.ITextRecordSpec} message TextRecordSpec message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TextRecordSpec.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a TextRecordSpec message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec} TextRecordSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TextRecordSpec.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.query = reader.string(); + break; + } + case 2: { + message.titleTemplate = reader.string(); + break; + } + case 3: { + message.contentTemplate = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TextRecordSpec message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec} TextRecordSpec + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TextRecordSpec.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TextRecordSpec message. + * @function verify + * @memberof google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TextRecordSpec.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.query != null && message.hasOwnProperty("query")) + if (!$util.isString(message.query)) + return "query: string expected"; + if (message.titleTemplate != null && message.hasOwnProperty("titleTemplate")) + if (!$util.isString(message.titleTemplate)) + return "titleTemplate: string expected"; + if (message.contentTemplate != null && message.hasOwnProperty("contentTemplate")) + if (!$util.isString(message.contentTemplate)) + return "contentTemplate: string expected"; + return null; + }; + + /** + * Creates a TextRecordSpec message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec} TextRecordSpec + */ + TextRecordSpec.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec) + return object; + var message = new $root.google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec(); + if (object.query != null) + message.query = String(object.query); + if (object.titleTemplate != null) + message.titleTemplate = String(object.titleTemplate); + if (object.contentTemplate != null) + message.contentTemplate = String(object.contentTemplate); + return message; + }; + + /** + * Creates a plain object from a TextRecordSpec message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec + * @static + * @param {google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec} message TextRecordSpec + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TextRecordSpec.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.query = ""; + object.titleTemplate = ""; + object.contentTemplate = ""; + } + if (message.query != null && message.hasOwnProperty("query")) + object.query = message.query; + if (message.titleTemplate != null && message.hasOwnProperty("titleTemplate")) + object.titleTemplate = message.titleTemplate; + if (message.contentTemplate != null && message.hasOwnProperty("contentTemplate")) + object.contentTemplate = message.contentTemplate; + return object; + }; + + /** + * Converts this TextRecordSpec to JSON. + * @function toJSON + * @memberof google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec + * @instance + * @returns {Object.} JSON object + */ + TextRecordSpec.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for TextRecordSpec + * @function getTypeUrl + * @memberof google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + TextRecordSpec.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.vectorsearch.v1beta.VertexRanker.TextRecordSpec"; + }; + + return TextRecordSpec; + })(); + + return VertexRanker; + })(); + v1beta.BatchSearchDataObjectsResponse = (function() { /** diff --git a/packages/google-cloud-vectorsearch/protos/protos.json b/packages/google-cloud-vectorsearch/protos/protos.json index f10b6dd83bfb..3358c71c89bc 100644 --- a/packages/google-cloud-vectorsearch/protos/protos.json +++ b/packages/google-cloud-vectorsearch/protos/protos.json @@ -2855,6 +2855,14 @@ "options": { "(google.api.field_behavior)": "OUTPUT_ONLY" } + }, + "warnings": { + "rule": "repeated", + "type": "google.rpc.Status", + "id": 3, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } } }, "nested": { @@ -3055,12 +3063,24 @@ "oneof": [ "rrf" ] + }, + "reranker": { + "oneof": [ + "vertexRanker" + ] } }, "fields": { "rrf": { "type": "ReciprocalRankFusion", "id": 1 + }, + "vertexRanker": { + "type": "VertexRanker", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, @@ -3076,6 +3096,62 @@ } } }, + "VertexRanker": { + "oneofs": { + "recordSpec": { + "oneof": [ + "textRecordSpec" + ] + } + }, + "fields": { + "textRecordSpec": { + "type": "TextRecordSpec", + "id": 6 + }, + "model": { + "type": "string", + "id": 4, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "topN": { + "type": "int32", + "id": 5, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + }, + "nested": { + "TextRecordSpec": { + "fields": { + "query": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "titleTemplate": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "contentTemplate": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + } + } + }, "BatchSearchDataObjectsResponse": { "fields": { "results": { diff --git a/packages/google-cloud-vectorsearch/samples/generated/v1/snippet_metadata_google.cloud.vectorsearch.v1.json b/packages/google-cloud-vectorsearch/samples/generated/v1/snippet_metadata_google.cloud.vectorsearch.v1.json index 63507a782548..900975e2887b 100644 --- a/packages/google-cloud-vectorsearch/samples/generated/v1/snippet_metadata_google.cloud.vectorsearch.v1.json +++ b/packages/google-cloud-vectorsearch/samples/generated/v1/snippet_metadata_google.cloud.vectorsearch.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-vectorsearch", - "version": "0.6.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-vectorsearch/samples/generated/v1beta/snippet_metadata_google.cloud.vectorsearch.v1beta.json b/packages/google-cloud-vectorsearch/samples/generated/v1beta/snippet_metadata_google.cloud.vectorsearch.v1beta.json index b1d52f036c33..72365cb661da 100644 --- a/packages/google-cloud-vectorsearch/samples/generated/v1beta/snippet_metadata_google.cloud.vectorsearch.v1beta.json +++ b/packages/google-cloud-vectorsearch/samples/generated/v1beta/snippet_metadata_google.cloud.vectorsearch.v1beta.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-vectorsearch", - "version": "0.6.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-vectorsearch/src/index.ts b/packages/google-cloud-vectorsearch/src/index.ts index 2927a884ac62..4b22be327eec 100644 --- a/packages/google-cloud-vectorsearch/src/index.ts +++ b/packages/google-cloud-vectorsearch/src/index.ts @@ -1,4 +1,4 @@ -// Copyright 2026 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/packages/google-cloud-vectorsearch/webpack.config.js b/packages/google-cloud-vectorsearch/webpack.config.js index bded5b550991..f4062e96f41a 100644 --- a/packages/google-cloud-vectorsearch/webpack.config.js +++ b/packages/google-cloud-vectorsearch/webpack.config.js @@ -1,4 +1,4 @@ -// Copyright 2026 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License.