UNPKG

@langchain/community

Version:
1 lines • 11.9 kB
{"version":3,"file":"googlevertexai.d.ts","names":["GoogleAuthOptions","VectorStore","EmbeddingsInterface","Document","DocumentInput","AsyncCaller","AsyncCallerCallOptions","AsyncCallerParams","GoogleVertexAIConnection","Docstore","GoogleVertexAIConnectionParams","GoogleResponse","GoogleAbstractedClientOpsMethod","IdDocumentInput","IdDocument","IndexEndpointConnectionParams","DeployedIndex","IndexEndpointResponse","IndexEndpointConnection","Promise","MatchingEngineDeleteParams","RemoveDatapointParams","RemoveDatapointResponse","RemoveDatapointConnection","UpsertDatapointParams","Restriction","CrowdingTag","IndexDatapoint","UpsertDatapointResponse","UpsertDatapointConnection","PublicAPIEndpointInfo","MatchingEngineArgs","MatchingEngine","Record"],"sources":["../../src/vectorstores/googlevertexai.d.ts"],"sourcesContent":["import { GoogleAuthOptions } from \"google-auth-library\";\nimport { VectorStore } from \"@langchain/core/vectorstores\";\nimport type { EmbeddingsInterface } from \"@langchain/core/embeddings\";\nimport { Document, DocumentInput } from \"@langchain/core/documents\";\nimport { AsyncCaller, AsyncCallerCallOptions, AsyncCallerParams } from \"@langchain/core/utils/async_caller\";\nimport { GoogleVertexAIConnection } from \"../utils/googlevertexai-connection.js\";\nimport { Docstore } from \"../stores/doc/base.js\";\nimport { GoogleVertexAIConnectionParams, GoogleResponse, GoogleAbstractedClientOpsMethod } from \"../types/googlevertexai-types.js\";\n/**\n * Allows us to create IdDocument classes that contain the ID.\n */\nexport interface IdDocumentInput extends DocumentInput {\n id?: string;\n}\n/**\n * A Document that optionally includes the ID of the document.\n */\nexport declare class IdDocument extends Document implements IdDocumentInput {\n id?: string;\n constructor(fields: IdDocumentInput);\n}\ninterface IndexEndpointConnectionParams extends GoogleVertexAIConnectionParams<GoogleAuthOptions> {\n indexEndpoint: string;\n}\ninterface DeployedIndex {\n id: string;\n index: string;\n}\ninterface IndexEndpointResponse extends GoogleResponse {\n data: {\n deployedIndexes: DeployedIndex[];\n publicEndpointDomainName: string;\n };\n}\ndeclare class IndexEndpointConnection extends GoogleVertexAIConnection<AsyncCallerCallOptions, IndexEndpointResponse, GoogleAuthOptions> {\n indexEndpoint: string;\n constructor(fields: IndexEndpointConnectionParams, caller: AsyncCaller);\n buildUrl(): Promise<string>;\n buildMethod(): GoogleAbstractedClientOpsMethod;\n request(options: AsyncCallerCallOptions): Promise<IndexEndpointResponse>;\n}\n/**\n * Used to represent parameters that are necessary to delete documents\n * from the matching engine. These must be a list of string IDs\n */\nexport interface MatchingEngineDeleteParams {\n ids: string[];\n}\ninterface RemoveDatapointParams extends GoogleVertexAIConnectionParams<GoogleAuthOptions> {\n index: string;\n}\ninterface RemoveDatapointResponse extends GoogleResponse {\n}\ndeclare class RemoveDatapointConnection extends GoogleVertexAIConnection<AsyncCallerCallOptions, RemoveDatapointResponse, GoogleAuthOptions> {\n index: string;\n constructor(fields: RemoveDatapointParams, caller: AsyncCaller);\n buildUrl(): Promise<string>;\n buildMethod(): GoogleAbstractedClientOpsMethod;\n request(datapointIds: string[], options: AsyncCallerCallOptions): Promise<RemoveDatapointResponse>;\n}\ninterface UpsertDatapointParams extends GoogleVertexAIConnectionParams<GoogleAuthOptions> {\n index: string;\n}\nexport interface Restriction {\n namespace: string;\n allowList?: string[];\n denyList?: string[];\n}\ninterface CrowdingTag {\n crowdingAttribute: string;\n}\ninterface IndexDatapoint {\n datapointId: string;\n featureVector: number[];\n restricts?: Restriction[];\n crowdingTag?: CrowdingTag;\n}\ninterface UpsertDatapointResponse extends GoogleResponse {\n}\ndeclare class UpsertDatapointConnection extends GoogleVertexAIConnection<AsyncCallerCallOptions, UpsertDatapointResponse, GoogleAuthOptions> {\n index: string;\n constructor(fields: UpsertDatapointParams, caller: AsyncCaller);\n buildUrl(): Promise<string>;\n buildMethod(): GoogleAbstractedClientOpsMethod;\n request(datapoints: IndexDatapoint[], options: AsyncCallerCallOptions): Promise<UpsertDatapointResponse>;\n}\n/**\n * Information about the Matching Engine public API endpoint.\n * Primarily exported to allow for testing.\n */\nexport interface PublicAPIEndpointInfo {\n apiEndpoint?: string;\n deployedIndexId?: string;\n}\n/**\n * Parameters necessary to configure the Matching Engine.\n */\nexport interface MatchingEngineArgs extends GoogleVertexAIConnectionParams<GoogleAuthOptions>, IndexEndpointConnectionParams, UpsertDatapointParams {\n docstore: Docstore;\n callerParams?: AsyncCallerParams;\n callerOptions?: AsyncCallerCallOptions;\n apiEndpoint?: string;\n deployedIndexId?: string;\n}\n/**\n * A class that represents a connection to a Google Vertex AI Matching Engine\n * instance.\n */\nexport declare class MatchingEngine extends VectorStore implements MatchingEngineArgs {\n FilterType: Restriction[];\n /**\n * Docstore that retains the document, stored by ID\n */\n docstore: Docstore;\n /**\n * The host to connect to for queries and upserts.\n */\n apiEndpoint: string;\n apiVersion: string;\n endpoint: string;\n location: string;\n /**\n * The id for the index endpoint\n */\n indexEndpoint: string;\n /**\n * The id for the index\n */\n index: string;\n /**\n * Explicitly set Google Auth credentials if you cannot get them from google auth application-default login\n * This is useful for serverless or autoscaling environments like Fargate\n */\n authOptions: GoogleAuthOptions;\n /**\n * The id for the \"deployed index\", which is an identifier in the\n * index endpoint that references the index (but is not the index id)\n */\n deployedIndexId: string;\n callerParams: AsyncCallerParams;\n callerOptions: AsyncCallerCallOptions;\n caller: AsyncCaller;\n indexEndpointClient: IndexEndpointConnection;\n removeDatapointClient: RemoveDatapointConnection;\n upsertDatapointClient: UpsertDatapointConnection;\n constructor(embeddings: EmbeddingsInterface, args: MatchingEngineArgs);\n _vectorstoreType(): string;\n addDocuments(documents: Document[]): Promise<void>;\n addVectors(vectors: number[][], documents: Document[]): Promise<void>;\n cleanMetadata(documentMetadata: Record<string, any>): {\n [key: string]: string | number | boolean | string[] | null;\n };\n /**\n * Given the metadata from a document, convert it to an array of Restriction\n * objects that may be passed to the Matching Engine and stored.\n * The default implementation flattens any metadata and includes it as\n * an \"allowList\". Subclasses can choose to convert some of these to\n * \"denyList\" items or to add additional restrictions (for example, to format\n * dates into a different structure or to add additional restrictions\n * based on the date).\n * @param documentMetadata - The metadata from a document\n * @returns a Restriction[] (or an array of a subclass, from the FilterType)\n */\n metadataToRestrictions(documentMetadata: Record<string, any>): this[\"FilterType\"];\n /**\n * Create an index datapoint for the vector and document id.\n * If an id does not exist, create it and set the document to its value.\n * @param vector\n * @param document\n */\n buildDatapoint(vector: number[], document: IdDocument): IndexDatapoint;\n delete(params: MatchingEngineDeleteParams): Promise<void>;\n similaritySearchVectorWithScore(query: number[], k: number, filter?: this[\"FilterType\"]): Promise<[Document, number][]>;\n /**\n * For this index endpoint, figure out what API Endpoint URL and deployed\n * index ID should be used to do upserts and queries.\n * Also sets the `apiEndpoint` and `deployedIndexId` property for future use.\n * @return The URL\n */\n determinePublicAPIEndpoint(): Promise<PublicAPIEndpointInfo>;\n getPublicAPIEndpoint(): Promise<string>;\n getDeployedIndexId(): Promise<string>;\n static fromTexts(texts: string[], metadatas: object[] | object, embeddings: EmbeddingsInterface, dbConfig: MatchingEngineArgs): Promise<VectorStore>;\n static fromDocuments(docs: Document[], embeddings: EmbeddingsInterface, dbConfig: MatchingEngineArgs): Promise<VectorStore>;\n}\nexport {};\n//# sourceMappingURL=googlevertexai.d.ts.map"],"mappings":";;;;;;;;;;;;;AAWA;AAMqBc,UANJD,eAAAA,SAAwBT,aAMV,CAAA;EAEPS,EAAAA,CAAAA,EAAAA,MAAAA;;;AAFmD;AAG1E;AAISG,cAPWF,UAAAA,SAAmBX,QAAAA,YAAoBU,eAOrC,CAAA;EAIbI,EAAAA,CAAAA,EAAAA,MAAAA;EAMIC,WAAAA,CAAAA,MAAAA,EAfUL,eAea;;UAb3BE,6BAAAA,SAAsCL,8BAa+CO,CAbhBjB,iBAagBiB,CAAAA,CAAAA;EAAuBjB,aAAAA,EAAAA,MAAAA;;UAV5GgB,aAAAA,CAYqDX;EAC/Cc,EAAAA,EAAAA,MAAAA;EACGP,KAAAA,EAAAA,MAAAA;;UAVTK,qBAAAA,SAA8BN,cAWcM,CAAAA;EAARE,IAAA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