Skip to content

Commit 23d7681

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
feat: Add Customization Config to Memory Bank
PiperOrigin-RevId: 797485170
1 parent 7ebbddb commit 23d7681

File tree

1 file changed

+278
-0
lines changed

1 file changed

+278
-0
lines changed

vertexai/_genai/types.py

Lines changed: 278 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,21 @@ class JobState(_common.CaseInSensitiveEnum):
224224
"""The job is partially succeeded, some results may be missing due to errors."""
225225

226226

227+
class ManagedTopicEnum(_common.CaseInSensitiveEnum):
228+
"""Required. The managed topic."""
229+
230+
MANAGED_TOPIC_ENUM_UNSPECIFIED = "MANAGED_TOPIC_ENUM_UNSPECIFIED"
231+
"""Unspecified topic. This value should not be used."""
232+
USER_PERSONAL_INFO = "USER_PERSONAL_INFO"
233+
"""Significant personal information about the User like first names, relationships, hobbies, important dates."""
234+
USER_PREFERENCES = "USER_PREFERENCES"
235+
"""Stated or implied likes, dislikes, preferred styles, or patterns."""
236+
KEY_CONVERSATION_DETAILS = "KEY_CONVERSATION_DETAILS"
237+
"""Important milestones or conclusions within the dialogue."""
238+
EXPLICIT_INSTRUCTIONS = "EXPLICIT_INSTRUCTIONS"
239+
"""Information that the user explicitly requested to remember or forget."""
240+
241+
227242
class RubricContentType(_common.CaseInSensitiveEnum):
228243
"""Specifies the type of rubric content to generate."""
229244

@@ -4367,6 +4382,262 @@ class ReasoningEngineContextSpecMemoryBankConfigSimilaritySearchConfigDict(
43674382
]
43684383

43694384

4385+
class MemoryBankCustomizationConfigMemoryTopicCustomMemoryTopic(_common.BaseModel):
4386+
"""A custom memory topic defined by the developer."""
4387+
4388+
label: Optional[str] = Field(
4389+
default=None, description="""Required. The label of the topic."""
4390+
)
4391+
description: Optional[str] = Field(
4392+
default=None,
4393+
description="""Required. Description of the memory topic. This should explain what information should be extracted for this topic.""",
4394+
)
4395+
4396+
4397+
class MemoryBankCustomizationConfigMemoryTopicCustomMemoryTopicDict(
4398+
TypedDict, total=False
4399+
):
4400+
"""A custom memory topic defined by the developer."""
4401+
4402+
label: Optional[str]
4403+
"""Required. The label of the topic."""
4404+
4405+
description: Optional[str]
4406+
"""Required. Description of the memory topic. This should explain what information should be extracted for this topic."""
4407+
4408+
4409+
MemoryBankCustomizationConfigMemoryTopicCustomMemoryTopicOrDict = Union[
4410+
MemoryBankCustomizationConfigMemoryTopicCustomMemoryTopic,
4411+
MemoryBankCustomizationConfigMemoryTopicCustomMemoryTopicDict,
4412+
]
4413+
4414+
4415+
class MemoryBankCustomizationConfigMemoryTopicManagedMemoryTopic(_common.BaseModel):
4416+
"""A managed memory topic defined by the system."""
4417+
4418+
managed_topic_enum: Optional[ManagedTopicEnum] = Field(
4419+
default=None, description="""Required. The managed topic."""
4420+
)
4421+
4422+
4423+
class MemoryBankCustomizationConfigMemoryTopicManagedMemoryTopicDict(
4424+
TypedDict, total=False
4425+
):
4426+
"""A managed memory topic defined by the system."""
4427+
4428+
managed_topic_enum: Optional[ManagedTopicEnum]
4429+
"""Required. The managed topic."""
4430+
4431+
4432+
MemoryBankCustomizationConfigMemoryTopicManagedMemoryTopicOrDict = Union[
4433+
MemoryBankCustomizationConfigMemoryTopicManagedMemoryTopic,
4434+
MemoryBankCustomizationConfigMemoryTopicManagedMemoryTopicDict,
4435+
]
4436+
4437+
4438+
class MemoryBankCustomizationConfigMemoryTopic(_common.BaseModel):
4439+
"""A topic of information that should be extracted from conversations and stored as memories."""
4440+
4441+
custom_memory_topic: Optional[
4442+
MemoryBankCustomizationConfigMemoryTopicCustomMemoryTopic
4443+
] = Field(
4444+
default=None,
4445+
description="""A custom memory topic defined by the developer.""",
4446+
)
4447+
managed_memory_topic: Optional[
4448+
MemoryBankCustomizationConfigMemoryTopicManagedMemoryTopic
4449+
] = Field(
4450+
default=None,
4451+
description="""A managed memory topic defined by Memory Bank.""",
4452+
)
4453+
4454+
4455+
class MemoryBankCustomizationConfigMemoryTopicDict(TypedDict, total=False):
4456+
"""A topic of information that should be extracted from conversations and stored as memories."""
4457+
4458+
custom_memory_topic: Optional[
4459+
MemoryBankCustomizationConfigMemoryTopicCustomMemoryTopicDict
4460+
]
4461+
"""A custom memory topic defined by the developer."""
4462+
4463+
managed_memory_topic: Optional[
4464+
MemoryBankCustomizationConfigMemoryTopicManagedMemoryTopicDict
4465+
]
4466+
"""A managed memory topic defined by Memory Bank."""
4467+
4468+
4469+
MemoryBankCustomizationConfigMemoryTopicOrDict = Union[
4470+
MemoryBankCustomizationConfigMemoryTopic,
4471+
MemoryBankCustomizationConfigMemoryTopicDict,
4472+
]
4473+
4474+
4475+
class MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceEvent(
4476+
_common.BaseModel
4477+
):
4478+
"""A single conversation event."""
4479+
4480+
content: Optional[Content] = Field(
4481+
default=None, description="""Required. The content of the event."""
4482+
)
4483+
4484+
4485+
class MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceEventDict(
4486+
TypedDict, total=False
4487+
):
4488+
"""A single conversation event."""
4489+
4490+
content: Optional[ContentDict]
4491+
"""Required. The content of the event."""
4492+
4493+
4494+
MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceEventOrDict = (
4495+
Union[
4496+
MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceEvent,
4497+
MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceEventDict,
4498+
]
4499+
)
4500+
4501+
4502+
class MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSource(
4503+
_common.BaseModel
4504+
):
4505+
"""A conversation source for the example.
4506+
4507+
This is similar to `DirectContentsSource`.
4508+
"""
4509+
4510+
events: Optional[
4511+
list[
4512+
MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceEvent
4513+
]
4514+
] = Field(
4515+
default=None,
4516+
description="""Optional. The input conversation events for the example.""",
4517+
)
4518+
4519+
4520+
class MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceDict(
4521+
TypedDict, total=False
4522+
):
4523+
"""A conversation source for the example.
4524+
4525+
This is similar to `DirectContentsSource`.
4526+
"""
4527+
4528+
events: Optional[
4529+
list[
4530+
MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceEventDict
4531+
]
4532+
]
4533+
"""Optional. The input conversation events for the example."""
4534+
4535+
4536+
MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceOrDict = Union[
4537+
MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSource,
4538+
MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceDict,
4539+
]
4540+
4541+
4542+
class MemoryBankCustomizationConfigGenerateMemoriesExampleGeneratedMemory(
4543+
_common.BaseModel
4544+
):
4545+
"""A memory generated by the operation."""
4546+
4547+
fact: Optional[str] = Field(
4548+
default=None,
4549+
description="""Required. The fact to generate a memory from.""",
4550+
)
4551+
4552+
4553+
class MemoryBankCustomizationConfigGenerateMemoriesExampleGeneratedMemoryDict(
4554+
TypedDict, total=False
4555+
):
4556+
"""A memory generated by the operation."""
4557+
4558+
fact: Optional[str]
4559+
"""Required. The fact to generate a memory from."""
4560+
4561+
4562+
MemoryBankCustomizationConfigGenerateMemoriesExampleGeneratedMemoryOrDict = Union[
4563+
MemoryBankCustomizationConfigGenerateMemoriesExampleGeneratedMemory,
4564+
MemoryBankCustomizationConfigGenerateMemoriesExampleGeneratedMemoryDict,
4565+
]
4566+
4567+
4568+
class MemoryBankCustomizationConfigGenerateMemoriesExample(_common.BaseModel):
4569+
"""An example of how to generate memories for a particular scope."""
4570+
4571+
conversation_source: Optional[
4572+
MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSource
4573+
] = Field(default=None, description="""A conversation source for the example.""")
4574+
generated_memories: Optional[
4575+
list[MemoryBankCustomizationConfigGenerateMemoriesExampleGeneratedMemory]
4576+
] = Field(
4577+
default=None,
4578+
description="""Optional. The memories that are expected to be generated from the input conversation. An empty list indicates that no memories are expected to be generated for the input conversation.""",
4579+
)
4580+
4581+
4582+
class MemoryBankCustomizationConfigGenerateMemoriesExampleDict(TypedDict, total=False):
4583+
"""An example of how to generate memories for a particular scope."""
4584+
4585+
conversation_source: Optional[
4586+
MemoryBankCustomizationConfigGenerateMemoriesExampleConversationSourceDict
4587+
]
4588+
"""A conversation source for the example."""
4589+
4590+
generated_memories: Optional[
4591+
list[MemoryBankCustomizationConfigGenerateMemoriesExampleGeneratedMemoryDict]
4592+
]
4593+
"""Optional. The memories that are expected to be generated from the input conversation. An empty list indicates that no memories are expected to be generated for the input conversation."""
4594+
4595+
4596+
MemoryBankCustomizationConfigGenerateMemoriesExampleOrDict = Union[
4597+
MemoryBankCustomizationConfigGenerateMemoriesExample,
4598+
MemoryBankCustomizationConfigGenerateMemoriesExampleDict,
4599+
]
4600+
4601+
4602+
class MemoryBankCustomizationConfig(_common.BaseModel):
4603+
"""Configuration for organizing memories for a particular scope."""
4604+
4605+
scope_keys: Optional[list[str]] = Field(
4606+
default=None,
4607+
description="""Optional. The scope keys (i.e. 'user_id') for which to use this config. A request's scope must include all of the provided keys for the config to be used (order does not matter). If empty, then the config will be used for all requests that do not have a more specific config. Only one default config is allowed per Memory Bank.""",
4608+
)
4609+
memory_topics: Optional[list[MemoryBankCustomizationConfigMemoryTopic]] = Field(
4610+
default=None,
4611+
description="""Optional. Topics of information that should be extracted from conversations and stored as memories. If not set, then Memory Bank's default topics will be used.""",
4612+
)
4613+
generate_memories_examples: Optional[
4614+
list[MemoryBankCustomizationConfigGenerateMemoriesExample]
4615+
] = Field(
4616+
default=None,
4617+
description="""Optional. Examples of how to generate memories for a particular scope.""",
4618+
)
4619+
4620+
4621+
class MemoryBankCustomizationConfigDict(TypedDict, total=False):
4622+
"""Configuration for organizing memories for a particular scope."""
4623+
4624+
scope_keys: Optional[list[str]]
4625+
"""Optional. The scope keys (i.e. 'user_id') for which to use this config. A request's scope must include all of the provided keys for the config to be used (order does not matter). If empty, then the config will be used for all requests that do not have a more specific config. Only one default config is allowed per Memory Bank."""
4626+
4627+
memory_topics: Optional[list[MemoryBankCustomizationConfigMemoryTopicDict]]
4628+
"""Optional. Topics of information that should be extracted from conversations and stored as memories. If not set, then Memory Bank's default topics will be used."""
4629+
4630+
generate_memories_examples: Optional[
4631+
list[MemoryBankCustomizationConfigGenerateMemoriesExampleDict]
4632+
]
4633+
"""Optional. Examples of how to generate memories for a particular scope."""
4634+
4635+
4636+
MemoryBankCustomizationConfigOrDict = Union[
4637+
MemoryBankCustomizationConfig, MemoryBankCustomizationConfigDict
4638+
]
4639+
4640+
43704641
class ReasoningEngineContextSpecMemoryBankConfig(_common.BaseModel):
43714642
"""Specification for a Memory Bank."""
43724643

@@ -4382,6 +4653,10 @@ class ReasoningEngineContextSpecMemoryBankConfig(_common.BaseModel):
43824653
default=None,
43834654
description="""Optional. Configuration for how to perform similarity search on memories. If not set, the Memory Bank will use the default embedding model `text-embedding-005`.""",
43844655
)
4656+
customization_configs: Optional[list[MemoryBankCustomizationConfig]] = Field(
4657+
default=None,
4658+
description="""Optional. Configuration for how to customize Memory Bank behavior for a particular scope.""",
4659+
)
43854660

43864661

43874662
class ReasoningEngineContextSpecMemoryBankConfigDict(TypedDict, total=False):
@@ -4397,6 +4672,9 @@ class ReasoningEngineContextSpecMemoryBankConfigDict(TypedDict, total=False):
43974672
]
43984673
"""Optional. Configuration for how to perform similarity search on memories. If not set, the Memory Bank will use the default embedding model `text-embedding-005`."""
43994674

4675+
customization_configs: Optional[list[MemoryBankCustomizationConfigDict]]
4676+
"""Optional. Configuration for how to customize Memory Bank behavior for a particular scope."""
4677+
44004678

44014679
ReasoningEngineContextSpecMemoryBankConfigOrDict = Union[
44024680
ReasoningEngineContextSpecMemoryBankConfig,

0 commit comments

Comments
 (0)