From a907304b21390eec20525355480f2ebe010ac1bd Mon Sep 17 00:00:00 2001 From: A Vertex SDK engineer Date: Tue, 25 Aug 2026 17:07:48 -0700 Subject: [PATCH] feat(agentplatform): Support Memory Bank configs. feat(agentplatform): Support client.memory_banks.get feat(agentplatform): Support client.memory_banks.list PiperOrigin-RevId: 970892415 --- src/converters/_memorybanks_converters.ts | 627 +++++++++++++++++++++- src/memorybanks.ts | 98 +++- src/types/common.ts | 143 ++++- 3 files changed, 860 insertions(+), 8 deletions(-) diff --git a/src/converters/_memorybanks_converters.ts b/src/converters/_memorybanks_converters.ts index f22258ce..351a5143 100644 --- a/src/converters/_memorybanks_converters.ts +++ b/src/converters/_memorybanks_converters.ts @@ -9,12 +9,53 @@ import * as common from '@google/genai/vertex_internal'; import * as types from '../types.js'; -export function createMemoryBankRequestParametersToVertex(): Record< - string, - unknown -> { +export function createMemoryBankConfigToVertex( + fromObject: types.CreateMemoryBankConfig, + parentObject: Record, +): Record { const toObject: Record = {}; + const fromDisplayName = common.getValueByPath(fromObject, ['displayName']); + if (parentObject !== undefined && fromDisplayName != null) { + common.setValueByPath(parentObject, ['displayName'], fromDisplayName); + } + + const fromDescription = common.getValueByPath(fromObject, ['description']); + if (parentObject !== undefined && fromDescription != null) { + common.setValueByPath(parentObject, ['description'], fromDescription); + } + + const fromEncryptionSpec = common.getValueByPath(fromObject, [ + 'encryptionSpec', + ]); + if (parentObject !== undefined && fromEncryptionSpec != null) { + common.setValueByPath(parentObject, ['encryptionSpec'], fromEncryptionSpec); + } + + return toObject; +} + +export function createMemoryBankRequestParametersToVertex( + fromObject: types.CreateMemoryBankRequestParameters, +): Record { + const toObject: Record = {}; + + const fromConfig = common.getValueByPath(fromObject, ['config']); + if (fromConfig != null) { + createMemoryBankConfigToVertex(fromConfig, toObject); + } + + const fromMemoryBankConfig = common.getValueByPath(fromObject, [ + 'memoryBankConfig', + ]); + if (fromMemoryBankConfig != null) { + common.setValueByPath( + toObject, + ['context_spec', 'memory_bank_config'], + reasoningEngineContextSpecMemoryBankConfigToVertex(fromMemoryBankConfig), + ); + } + return toObject; } @@ -55,6 +96,19 @@ export function getMemoryBankOperationParametersToVertex( return toObject; } +export function getMemoryBankRequestParametersToVertex( + fromObject: types.GetMemoryBankRequestParameters, +): Record { + const toObject: Record = {}; + + const fromName = common.getValueByPath(fromObject, ['name']); + if (fromName != null) { + common.setValueByPath(toObject, ['_url', 'name'], fromName); + } + + return toObject; +} + export function ingestEventsConfigToVertex( fromObject: types.IngestEventsConfig, parentObject: Record, @@ -168,3 +222,568 @@ export function ingestEventsRequestParametersToVertex( return toObject; } + +export function listMemoryBanksConfigToVertex( + fromObject: types.ListMemoryBanksConfig, + parentObject: Record, +): Record { + const toObject: Record = {}; + + const fromPageSize = common.getValueByPath(fromObject, ['pageSize']); + if (parentObject !== undefined && fromPageSize != null) { + common.setValueByPath(parentObject, ['_query', 'pageSize'], fromPageSize); + } + + const fromPageToken = common.getValueByPath(fromObject, ['pageToken']); + if (parentObject !== undefined && fromPageToken != null) { + common.setValueByPath(parentObject, ['_query', 'pageToken'], fromPageToken); + } + + return toObject; +} + +export function listMemoryBanksRequestParametersToVertex( + fromObject: types.ListMemoryBanksRequestParameters, +): Record { + const toObject: Record = {}; + + const fromConfig = common.getValueByPath(fromObject, ['config']); + if (fromConfig != null) { + listMemoryBanksConfigToVertex(fromConfig, toObject); + } + + return toObject; +} + +export function listReasoningEnginesResponseFromVertex( + fromObject: types.ListReasoningEnginesResponse, +): Record { + const toObject: Record = {}; + + const fromSdkHttpResponse = common.getValueByPath(fromObject, [ + 'sdkHttpResponse', + ]); + if (fromSdkHttpResponse != null) { + common.setValueByPath(toObject, ['sdkHttpResponse'], fromSdkHttpResponse); + } + + const fromNextPageToken = common.getValueByPath(fromObject, [ + 'nextPageToken', + ]); + if (fromNextPageToken != null) { + common.setValueByPath(toObject, ['nextPageToken'], fromNextPageToken); + } + + const fromReasoningEngines = common.getValueByPath(fromObject, [ + 'reasoningEngines', + ]); + if (fromReasoningEngines != null) { + let transformedList = fromReasoningEngines; + if (Array.isArray(transformedList)) { + transformedList = transformedList.map((item) => { + return reasoningEngineFromVertex(item); + }); + } + common.setValueByPath(toObject, ['reasoningEngines'], transformedList); + } + + return toObject; +} + +export function managedSemanticMemoryConfigFromVertex( + fromObject: types.ManagedSemanticMemoryConfig, +): Record { + const toObject: Record = {}; + + const fromGenerationConfig = common.getValueByPath(fromObject, [ + 'generationConfig', + ]); + if (fromGenerationConfig != null) { + common.setValueByPath(toObject, ['generationConfig'], fromGenerationConfig); + } + + const fromSimilaritySearchConfig = common.getValueByPath(fromObject, [ + 'similaritySearchConfig', + ]); + if (fromSimilaritySearchConfig != null) { + common.setValueByPath( + toObject, + ['similaritySearchConfig'], + fromSimilaritySearchConfig, + ); + } + + const fromUnstructuredMemoryConfigs = common.getValueByPath(fromObject, [ + 'unstructuredMemoryConfigs', + ]); + if (fromUnstructuredMemoryConfigs != null) { + let transformedList = fromUnstructuredMemoryConfigs; + if (Array.isArray(transformedList)) { + transformedList = transformedList.map((item) => { + return item; + }); + } + common.setValueByPath( + toObject, + ['unstructuredMemoryConfigs'], + transformedList, + ); + } + + const fromStructuredMemoryConfigs = common.getValueByPath(fromObject, [ + 'structuredMemoryConfigs', + ]); + if (fromStructuredMemoryConfigs != null) { + let transformedList = fromStructuredMemoryConfigs; + if (Array.isArray(transformedList)) { + transformedList = transformedList.map((item) => { + return structuredMemoryConfigFromVertex(item); + }); + } + common.setValueByPath( + toObject, + ['structuredMemoryConfigs'], + transformedList, + ); + } + + const fromTtlConfig = common.getValueByPath(fromObject, ['ttlConfig']); + if (fromTtlConfig != null) { + common.setValueByPath(toObject, ['ttlConfig'], fromTtlConfig); + } + + const fromDisableMemoryRevisions = common.getValueByPath(fromObject, [ + 'disableMemoryRevisions', + ]); + if (fromDisableMemoryRevisions != null) { + common.setValueByPath( + toObject, + ['disableMemoryRevisions'], + fromDisableMemoryRevisions, + ); + } + + return toObject; +} + +export function memoryBankFromVertex( + fromObject: types.MemoryBank, +): Record { + const toObject: Record = {}; + + const fromName = common.getValueByPath(fromObject, ['name']); + if (fromName != null) { + common.setValueByPath(toObject, ['name'], fromName); + } + + const fromManagedSemanticMemoryConfig = common.getValueByPath(fromObject, [ + 'managedSemanticMemoryConfig', + ]); + if (fromManagedSemanticMemoryConfig != null) { + common.setValueByPath( + toObject, + ['managedSemanticMemoryConfig'], + managedSemanticMemoryConfigFromVertex(fromManagedSemanticMemoryConfig), + ); + } + + const fromDisplayName = common.getValueByPath(fromObject, ['displayName']); + if (fromDisplayName != null) { + common.setValueByPath(toObject, ['displayName'], fromDisplayName); + } + + const fromDescription = common.getValueByPath(fromObject, ['description']); + if (fromDescription != null) { + common.setValueByPath(toObject, ['description'], fromDescription); + } + + const fromCreateTime = common.getValueByPath(fromObject, ['createTime']); + if (fromCreateTime != null) { + common.setValueByPath(toObject, ['createTime'], fromCreateTime); + } + + const fromUpdateTime = common.getValueByPath(fromObject, ['updateTime']); + if (fromUpdateTime != null) { + common.setValueByPath(toObject, ['updateTime'], fromUpdateTime); + } + + const fromEncryptionSpec = common.getValueByPath(fromObject, [ + 'encryptionSpec', + ]); + if (fromEncryptionSpec != null) { + common.setValueByPath(toObject, ['encryptionSpec'], fromEncryptionSpec); + } + + return toObject; +} + +export function memoryBankOperationFromVertex( + fromObject: types.MemoryBankOperation, +): Record { + const toObject: Record = {}; + + const fromName = common.getValueByPath(fromObject, ['name']); + if (fromName != null) { + common.setValueByPath(toObject, ['name'], fromName); + } + + const fromMetadata = common.getValueByPath(fromObject, ['metadata']); + if (fromMetadata != null) { + common.setValueByPath(toObject, ['metadata'], fromMetadata); + } + + const fromDone = common.getValueByPath(fromObject, ['done']); + if (fromDone != null) { + common.setValueByPath(toObject, ['done'], fromDone); + } + + const fromError = common.getValueByPath(fromObject, ['error']); + if (fromError != null) { + common.setValueByPath(toObject, ['error'], fromError); + } + + const fromResponse = common.getValueByPath(fromObject, ['response']); + if (fromResponse != null) { + common.setValueByPath( + toObject, + ['response'], + memoryBankFromVertex(fromResponse), + ); + } + + return toObject; +} + +export function reasoningEngineContextSpecFromVertex( + fromObject: types.ReasoningEngineContextSpec, +): Record { + const toObject: Record = {}; + + const fromMemoryBankConfig = common.getValueByPath(fromObject, [ + 'memoryBankConfig', + ]); + if (fromMemoryBankConfig != null) { + common.setValueByPath( + toObject, + ['memoryBankConfig'], + reasoningEngineContextSpecMemoryBankConfigFromVertex( + fromMemoryBankConfig, + ), + ); + } + + return toObject; +} + +export function reasoningEngineContextSpecMemoryBankConfigFromVertex( + fromObject: types.ReasoningEngineContextSpecMemoryBankConfig, +): Record { + const toObject: Record = {}; + + const fromCustomizationConfigs = common.getValueByPath(fromObject, [ + 'customizationConfigs', + ]); + if (fromCustomizationConfigs != null) { + let transformedList = fromCustomizationConfigs; + if (Array.isArray(transformedList)) { + transformedList = transformedList.map((item) => { + return item; + }); + } + common.setValueByPath(toObject, ['customizationConfigs'], transformedList); + } + + const fromDisableMemoryRevisions = common.getValueByPath(fromObject, [ + 'disableMemoryRevisions', + ]); + if (fromDisableMemoryRevisions != null) { + common.setValueByPath( + toObject, + ['disableMemoryRevisions'], + fromDisableMemoryRevisions, + ); + } + + const fromGenerationConfig = common.getValueByPath(fromObject, [ + 'generationConfig', + ]); + if (fromGenerationConfig != null) { + common.setValueByPath(toObject, ['generationConfig'], fromGenerationConfig); + } + + const fromSimilaritySearchConfig = common.getValueByPath(fromObject, [ + 'similaritySearchConfig', + ]); + if (fromSimilaritySearchConfig != null) { + common.setValueByPath( + toObject, + ['similaritySearchConfig'], + fromSimilaritySearchConfig, + ); + } + + const fromTtlConfig = common.getValueByPath(fromObject, ['ttlConfig']); + if (fromTtlConfig != null) { + common.setValueByPath(toObject, ['ttlConfig'], fromTtlConfig); + } + + const fromStructuredMemoryConfigs = common.getValueByPath(fromObject, [ + 'structuredMemoryConfigs', + ]); + if (fromStructuredMemoryConfigs != null) { + let transformedList = fromStructuredMemoryConfigs; + if (Array.isArray(transformedList)) { + transformedList = transformedList.map((item) => { + return structuredMemoryConfigFromVertex(item); + }); + } + common.setValueByPath( + toObject, + ['structuredMemoryConfigs'], + transformedList, + ); + } + + return toObject; +} + +export function reasoningEngineContextSpecMemoryBankConfigToVertex( + fromObject: types.ReasoningEngineContextSpecMemoryBankConfig, +): Record { + const toObject: Record = {}; + + const fromCustomizationConfigs = common.getValueByPath(fromObject, [ + 'customizationConfigs', + ]); + if (fromCustomizationConfigs != null) { + let transformedList = fromCustomizationConfigs; + if (Array.isArray(transformedList)) { + transformedList = transformedList.map((item) => { + return item; + }); + } + common.setValueByPath(toObject, ['customizationConfigs'], transformedList); + } + + const fromDisableMemoryRevisions = common.getValueByPath(fromObject, [ + 'disableMemoryRevisions', + ]); + if (fromDisableMemoryRevisions != null) { + common.setValueByPath( + toObject, + ['disableMemoryRevisions'], + fromDisableMemoryRevisions, + ); + } + + const fromGenerationConfig = common.getValueByPath(fromObject, [ + 'generationConfig', + ]); + if (fromGenerationConfig != null) { + common.setValueByPath(toObject, ['generationConfig'], fromGenerationConfig); + } + + const fromSimilaritySearchConfig = common.getValueByPath(fromObject, [ + 'similaritySearchConfig', + ]); + if (fromSimilaritySearchConfig != null) { + common.setValueByPath( + toObject, + ['similaritySearchConfig'], + fromSimilaritySearchConfig, + ); + } + + const fromTtlConfig = common.getValueByPath(fromObject, ['ttlConfig']); + if (fromTtlConfig != null) { + common.setValueByPath(toObject, ['ttlConfig'], fromTtlConfig); + } + + const fromStructuredMemoryConfigs = common.getValueByPath(fromObject, [ + 'structuredMemoryConfigs', + ]); + if (fromStructuredMemoryConfigs != null) { + let transformedList = fromStructuredMemoryConfigs; + if (Array.isArray(transformedList)) { + transformedList = transformedList.map((item) => { + return structuredMemoryConfigToVertex(item); + }); + } + common.setValueByPath( + toObject, + ['structuredMemoryConfigs'], + transformedList, + ); + } + + return toObject; +} + +export function reasoningEngineFromVertex( + fromObject: types.ReasoningEngine, +): Record { + const toObject: Record = {}; + + const fromEncryptionSpec = common.getValueByPath(fromObject, [ + 'encryptionSpec', + ]); + if (fromEncryptionSpec != null) { + common.setValueByPath(toObject, ['encryptionSpec'], fromEncryptionSpec); + } + + const fromContextSpec = common.getValueByPath(fromObject, ['contextSpec']); + if (fromContextSpec != null) { + common.setValueByPath( + toObject, + ['contextSpec'], + reasoningEngineContextSpecFromVertex(fromContextSpec), + ); + } + + const fromCreateTime = common.getValueByPath(fromObject, ['createTime']); + if (fromCreateTime != null) { + common.setValueByPath(toObject, ['createTime'], fromCreateTime); + } + + const fromDescription = common.getValueByPath(fromObject, ['description']); + if (fromDescription != null) { + common.setValueByPath(toObject, ['description'], fromDescription); + } + + const fromDisplayName = common.getValueByPath(fromObject, ['displayName']); + if (fromDisplayName != null) { + common.setValueByPath(toObject, ['displayName'], fromDisplayName); + } + + const fromEtag = common.getValueByPath(fromObject, ['etag']); + if (fromEtag != null) { + common.setValueByPath(toObject, ['etag'], fromEtag); + } + + const fromLabels = common.getValueByPath(fromObject, ['labels']); + if (fromLabels != null) { + common.setValueByPath(toObject, ['labels'], fromLabels); + } + + const fromName = common.getValueByPath(fromObject, ['name']); + if (fromName != null) { + common.setValueByPath(toObject, ['name'], fromName); + } + + const fromSpec = common.getValueByPath(fromObject, ['spec']); + if (fromSpec != null) { + common.setValueByPath(toObject, ['spec'], fromSpec); + } + + const fromUpdateTime = common.getValueByPath(fromObject, ['updateTime']); + if (fromUpdateTime != null) { + common.setValueByPath(toObject, ['updateTime'], fromUpdateTime); + } + + const fromTrafficConfig = common.getValueByPath(fromObject, [ + 'trafficConfig', + ]); + if (fromTrafficConfig != null) { + common.setValueByPath(toObject, ['trafficConfig'], fromTrafficConfig); + } + + return toObject; +} + +export function structuredMemoryConfigFromVertex( + fromObject: types.StructuredMemoryConfig, +): Record { + const toObject: Record = {}; + + const fromSchemaConfigs = common.getValueByPath(fromObject, [ + 'schemaConfigs', + ]); + if (fromSchemaConfigs != null) { + let transformedList = fromSchemaConfigs; + if (Array.isArray(transformedList)) { + transformedList = transformedList.map((item) => { + return structuredMemorySchemaConfigFromVertex(item); + }); + } + common.setValueByPath(toObject, ['schemaConfigs'], transformedList); + } + + const fromScopeKeys = common.getValueByPath(fromObject, ['scopeKeys']); + if (fromScopeKeys != null) { + common.setValueByPath(toObject, ['scopeKeys'], fromScopeKeys); + } + + return toObject; +} + +export function structuredMemoryConfigToVertex( + fromObject: types.StructuredMemoryConfig, +): Record { + const toObject: Record = {}; + + const fromSchemaConfigs = common.getValueByPath(fromObject, [ + 'schemaConfigs', + ]); + if (fromSchemaConfigs != null) { + let transformedList = fromSchemaConfigs; + if (Array.isArray(transformedList)) { + transformedList = transformedList.map((item) => { + return structuredMemorySchemaConfigToVertex(item); + }); + } + common.setValueByPath(toObject, ['schemaConfigs'], transformedList); + } + + const fromScopeKeys = common.getValueByPath(fromObject, ['scopeKeys']); + if (fromScopeKeys != null) { + common.setValueByPath(toObject, ['scopeKeys'], fromScopeKeys); + } + + return toObject; +} + +export function structuredMemorySchemaConfigFromVertex( + fromObject: types.StructuredMemorySchemaConfig, +): Record { + const toObject: Record = {}; + + const fromMemorySchema = common.getValueByPath(fromObject, ['schema']); + if (fromMemorySchema != null) { + common.setValueByPath(toObject, ['memorySchema'], fromMemorySchema); + } + + const fromId = common.getValueByPath(fromObject, ['id']); + if (fromId != null) { + common.setValueByPath(toObject, ['id'], fromId); + } + + const fromMemoryType = common.getValueByPath(fromObject, ['memoryType']); + if (fromMemoryType != null) { + common.setValueByPath(toObject, ['memoryType'], fromMemoryType); + } + + return toObject; +} + +export function structuredMemorySchemaConfigToVertex( + fromObject: types.StructuredMemorySchemaConfig, +): Record { + const toObject: Record = {}; + + const fromMemorySchema = common.getValueByPath(fromObject, ['memorySchema']); + if (fromMemorySchema != null) { + common.setValueByPath(toObject, ['schema'], fromMemorySchema); + } + + const fromId = common.getValueByPath(fromObject, ['id']); + if (fromId != null) { + common.setValueByPath(toObject, ['id'], fromId); + } + + const fromMemoryType = common.getValueByPath(fromObject, ['memoryType']); + if (fromMemoryType != null) { + common.setValueByPath(toObject, ['memoryType'], fromMemoryType); + } + + return toObject; +} diff --git a/src/memorybanks.ts b/src/memorybanks.ts index ede60c9c..e1738285 100644 --- a/src/memorybanks.ts +++ b/src/memorybanks.ts @@ -28,7 +28,7 @@ export class MemoryBanks extends BaseModule { let path: string = ''; let queryParams: Record = {}; if (this.apiClient.isVertexAI()) { - const body = converters.createMemoryBankRequestParametersToVertex(); + const body = converters.createMemoryBankRequestParametersToVertex(params); path = common.formatMap( 'reasoningEngines', body['_url'] as Record, @@ -51,7 +51,9 @@ export class MemoryBanks extends BaseModule { return httpResponse.json(); }) as Promise; - return response.then((resp) => { + return response.then((apiResponse) => { + const resp = converters.memoryBankOperationFromVertex(apiResponse); + return resp as types.MemoryBankOperation; }); } else { @@ -102,6 +104,49 @@ export class MemoryBanks extends BaseModule { } } + async getInternal( + params: types.GetMemoryBankRequestParameters, + ): Promise { + let response: Promise; + + let path: string = ''; + let queryParams: Record = {}; + if (this.apiClient.isVertexAI()) { + const body = converters.getMemoryBankRequestParametersToVertex(params); + path = common.formatMap( + '{name}', + body['_url'] as Record, + ); + queryParams = body['_query'] as Record; + delete body['_url']; + delete body['_query']; + delete body['config']; + + response = this.apiClient + .request({ + path: path, + queryParams: queryParams, + body: JSON.stringify(body), + httpMethod: 'GET', + httpOptions: params.config?.httpOptions, + abortSignal: params.config?.abortSignal, + }) + .then((httpResponse) => { + return httpResponse.json(); + }) as Promise; + + return response.then((apiResponse) => { + const resp = converters.reasoningEngineFromVertex(apiResponse); + + return resp as types.ReasoningEngine; + }); + } else { + throw new Error( + 'This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).', + ); + } + } + async ingestEventsInternal( params: types.IngestEventsRequestParameters, ): Promise { @@ -143,6 +188,51 @@ export class MemoryBanks extends BaseModule { } } + async listInternal( + params: types.ListMemoryBanksRequestParameters, + ): Promise { + let response: Promise; + + let path: string = ''; + let queryParams: Record = {}; + if (this.apiClient.isVertexAI()) { + const body = converters.listMemoryBanksRequestParametersToVertex(params); + path = common.formatMap( + 'reasoningEngines', + body['_url'] as Record, + ); + queryParams = body['_query'] as Record; + delete body['_url']; + delete body['_query']; + delete body['config']; + + response = this.apiClient + .request({ + path: path, + queryParams: queryParams, + body: JSON.stringify(body), + httpMethod: 'GET', + httpOptions: params.config?.httpOptions, + abortSignal: params.config?.abortSignal, + }) + .then((httpResponse) => { + return httpResponse.json(); + }) as Promise; + + return response.then((apiResponse) => { + const resp = + converters.listReasoningEnginesResponseFromVertex(apiResponse); + const typedResp = new types.ListReasoningEnginesResponse(); + Object.assign(typedResp, resp); + return typedResp; + }); + } else { + throw new Error( + 'This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).', + ); + } + } + async getMemoryBankOperationInternal( params: types.GetMemoryBankOperationParameters, ): Promise { @@ -174,7 +264,9 @@ export class MemoryBanks extends BaseModule { return httpResponse.json(); }) as Promise; - return response.then((resp) => { + return response.then((apiResponse) => { + const resp = converters.memoryBankOperationFromVertex(apiResponse); + return resp as types.MemoryBankOperation; }); } else { diff --git a/src/types/common.ts b/src/types/common.ts index db33e415..a42888cd 100644 --- a/src/types/common.ts +++ b/src/types/common.ts @@ -629,7 +629,7 @@ export declare interface MemoryBankCustomizationConfigConsolidationConfig { revisionsPerCandidateCount?: number; } -/** Represents configuration for organizing natural language memories for a particular scope. */ +/** Represents configuration for organizing natural language memories. */ export declare interface MemoryBankCustomizationConfig { /** Optional. Indicates whether the memories will be generated in the third person (i.e. "The user generates memories with Memory Bank."). By default, the memories will be generated in the first person (i.e. "I generate memories with Memory Bank.") */ enableThirdPersonMemories?: boolean; @@ -1214,17 +1214,112 @@ export declare interface CreateMemoryBankConfig { be charged usage for any applicable operations. */ abortSignal?: AbortSignal; + /** The user-defined name of the Memory Bank. + + The display name can be up to 128 characters long and can comprise any + UTF-8 characters. + */ + displayName?: string; + /** The description of the Memory Bank. */ + description?: string; + /** The encryption spec to be used for the Memory Bank. */ + encryptionSpec?: genaiTypes.EncryptionSpec; } /** Parameters for creating memory banks. */ export declare interface CreateMemoryBankRequestParameters { config?: CreateMemoryBankConfig; + memoryBankConfig?: ReasoningEngineContextSpecMemoryBankConfig; +} + +/** The configuration for generating memories. */ +export declare interface ManagedSemanticMemoryConfigGenerationConfig { + /** The model used to generate memories. + + Format: + `projects/{project}/locations/{location}/publishers/google/models/{model}`. */ + model?: string; + /** The configuration for triggering memory generation. */ + generationTriggerConfig?: MemoryGenerationTriggerConfig; +} + +/** The configuration for similarity search. */ +export declare interface ManagedSemanticMemoryConfigSimilaritySearchConfig { + /** The model used to generate embeddings to look up similar memories. + Format: + `projects/{project}/locations/{location}/publishers/google/models/{model}`. */ + embeddingModel?: string; +} + +/** The configuration for granular TTL. */ +export declare interface ManagedSemanticMemoryConfigTtlConfigGranularTtlConfig { + /** Optional. The TTL duration for memories uploaded via + CreateMemory. */ + createTtl?: string; + /** Optional. The TTL duration for memories generated via + GenerateMemories. */ + generateCreatedTtl?: string; + /** Optional. The TTL duration for memories updated via + GenerateMemories (GenerateMemoriesResponse.GeneratedMemory.Action.UPDATED). + In the case of an UPDATE action, the `expire_time` of the existing memory + will be updated to the new value (now + TTL). */ + generateUpdatedTtl?: string; +} + +/** The configuration for automatic TTL ('time-to-live') of the memories. */ +export declare interface ManagedSemanticMemoryConfigTtlConfig { + /** The default TTL for memories in the Memory Bank. If not set, TTL will not be applied automatically. The TTL can be explicitly set by modifying the `expire_time` of each Memory resource. */ + defaultTtl?: string; + /** The granular TTL config for memories. */ + granularTtlConfig?: ManagedSemanticMemoryConfigTtlConfigGranularTtlConfig; + /** The default TTL for memory revisions in the Memory Bank. If not set, TTL will not be applied automatically. The TTL can be explicitly set by modifying the `expire_time` of each Memory resource. */ + memoryRevisionDefaultTtl?: string; +} + +/** The configuration for managed semantic memory. */ +export declare interface ManagedSemanticMemoryConfig { + /** Represents configuration for LLMs calls. */ + generationConfig?: ManagedSemanticMemoryConfigGenerationConfig; + /** Configuration for how to perform similarity search on memories. */ + similaritySearchConfig?: ManagedSemanticMemoryConfigSimilaritySearchConfig; + /** Configuration for how to customize Memory Bank behavior for a + particular scope for unstructured memories. */ + unstructuredMemoryConfigs?: MemoryBankCustomizationConfig[]; + /** Configuration for organizing structured memories for a particular + scope. */ + structuredMemoryConfigs?: StructuredMemoryConfig[]; + /** Configuration for automatic TTL ('time-to-live') of the memories in + the Memory Bank. If not set, TTL will not be applied automatically. The + TTL can be explicitly set by modifying the `expire_time` of each Memory + resource. */ + ttlConfig?: ManagedSemanticMemoryConfigTtlConfig; + /** If true, no memory revisions will be created for any requests to + Memory Bank. */ + disableMemoryRevisions?: boolean; +} + +/** Represents a customer-managed encryption key specification that can be applied to a Vertex AI resource. */ +export declare interface EncryptionSpec { + /** Required. Resource name of the Cloud KMS key used to protect the resource. The Cloud KMS key must be in the same region as the resource. It must have the format `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`. */ + kmsKeyName?: string; } /** A memory bank. */ export declare interface MemoryBank { /** Required. Represents the ID of the schema. Must be 1-63 characters, start with a lowercase letter, and consist of lowercase letters, numbers, and hyphens. */ name?: string; + /** Represents the configuration for managed memories in Memory Bank. If not set, then the default configuration will be used. */ + managedSemanticMemoryConfig?: ManagedSemanticMemoryConfig; + /** Represents the display name of the Memory Bank. */ + displayName?: string; + /** Represents the description of the Memory Bank. */ + description?: string; + /** Timestamp when this Memory Bank was created. */ + createTime?: string; + /** Timestamp when this Memory Bank was most recently updated. */ + updateTime?: string; + /** Customer-managed encryption key spec for a Memory Bank. If set, this Memory Bank and all sub-resources of this Memory Bank will be secured by this key. */ + encryptionSpec?: EncryptionSpec; } /** Operation that has an memory bank as a response. */ @@ -1275,6 +1370,26 @@ export declare interface DeleteMemoryBankOperation { error?: Record; } +/** Config for getting a Memory Bank. */ +export declare interface GetMemoryBankConfig { + /** Used to override HTTP request options. */ + httpOptions?: genaiTypes.HttpOptions; + /** Abort signal which can be used to cancel the request. + + NOTE: AbortSignal is a client-only operation. Using it to cancel an + operation will not cancel the request in the service. You will still + be charged usage for any applicable operations. + */ + abortSignal?: AbortSignal; +} + +/** Parameters for getting a Memory Bank. */ +export declare interface GetMemoryBankRequestParameters { + /** Name of the Memory Bank. */ + name: string; + config?: GetMemoryBankConfig; +} + /** The direct contents source event for ingesting events. */ export declare interface IngestionDirectContentsSourceEvent { /** Required. The content of the event. */ @@ -1363,6 +1478,26 @@ export declare interface MemoryBankIngestEventsOperation { error?: Record; } +/** Config for listing Memory Banks. */ +export declare interface ListMemoryBanksConfig { + /** Used to override HTTP request options. */ + httpOptions?: genaiTypes.HttpOptions; + /** Abort signal which can be used to cancel the request. + + NOTE: AbortSignal is a client-only operation. Using it to cancel an + operation will not cancel the request in the service. You will still + be charged usage for any applicable operations. + */ + abortSignal?: AbortSignal; + pageSize?: number; + pageToken?: string; +} + +/** Parameters for listing Memory Banks. */ +export declare interface ListMemoryBanksRequestParameters { + config?: ListMemoryBanksConfig; +} + export declare interface GetMemoryBankOperationConfig { /** Used to override HTTP request options. */ httpOptions?: genaiTypes.HttpOptions; @@ -4360,3 +4495,9 @@ export declare interface PromptVersionRef { versionId?: string; model?: string; } + +/** The response for listing Memory Banks. */ +export class ListMemoryBanksResponse { + /** The list of Memory Banks. */ + memoryBanks?: MemoryBank[]; +}