Skip to content

Commit 662874b

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
feat: Add structured data and memory type to Memory.
feat: Add memory_types filter to RetrieveMemories PiperOrigin-RevId: 893553153
1 parent 62656c2 commit 662874b

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

vertexai/_genai/memories.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,9 @@ def _RetrieveAgentEngineMemoriesConfig_to_vertex(
329329
[item for item in getv(from_object, ["filter_groups"])],
330330
)
331331

332+
if getv(from_object, ["memory_types"]) is not None:
333+
setv(parent_object, ["memoryTypes"], getv(from_object, ["memory_types"]))
334+
332335
return to_object
333336

334337

vertexai/_genai/types/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,9 +661,13 @@
661661
from .common import MemoryRevision
662662
from .common import MemoryRevisionDict
663663
from .common import MemoryRevisionOrDict
664+
from .common import MemoryStructuredContent
665+
from .common import MemoryStructuredContentDict
666+
from .common import MemoryStructuredContentOrDict
664667
from .common import MemoryTopicId
665668
from .common import MemoryTopicIdDict
666669
from .common import MemoryTopicIdOrDict
670+
from .common import MemoryType
667671
from .common import Message
668672
from .common import MessageDict
669673
from .common import Metadata
@@ -1682,6 +1686,9 @@
16821686
"AgentEngineMemoryConfig",
16831687
"AgentEngineMemoryConfigDict",
16841688
"AgentEngineMemoryConfigOrDict",
1689+
"MemoryStructuredContent",
1690+
"MemoryStructuredContentDict",
1691+
"MemoryStructuredContentOrDict",
16851692
"Memory",
16861693
"MemoryDict",
16871694
"MemoryOrDict",
@@ -2138,6 +2145,7 @@
21382145
"ManagedTopicEnum",
21392146
"IdentityType",
21402147
"AgentServerMode",
2148+
"MemoryType",
21412149
"Operator",
21422150
"Language",
21432151
"MachineConfig",

vertexai/_genai/types/common.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,17 @@ class AgentServerMode(_common.CaseInSensitiveEnum):
280280
"""Experimental agent server mode. This mode contains experimental features."""
281281

282282

283+
class MemoryType(_common.CaseInSensitiveEnum):
284+
"""The type of the memory."""
285+
286+
MEMORY_TYPE_UNSPECIFIED = "MEMORY_TYPE_UNSPECIFIED"
287+
"""Represents an unspecified memory type. This value should not be used."""
288+
NATURAL_LANGUAGE_COLLECTION = "NATURAL_LANGUAGE_COLLECTION"
289+
"""Indicates belonging to a collection of natural language memories."""
290+
STRUCTURED_PROFILE = "STRUCTURED_PROFILE"
291+
"""Indicates belonging to a structured profile."""
292+
293+
283294
class Operator(_common.CaseInSensitiveEnum):
284295
"""Operator to apply to the filter. If not set, then EQUAL will be used."""
285296

@@ -8269,6 +8280,34 @@ class _CreateAgentEngineMemoryRequestParametersDict(TypedDict, total=False):
82698280
]
82708281

82718282

8283+
class MemoryStructuredContent(_common.BaseModel):
8284+
"""Represents the structured value of the memory."""
8285+
8286+
data: Optional[dict[str, Any]] = Field(
8287+
default=None,
8288+
description="""Required. Represents the structured value of the memory.""",
8289+
)
8290+
schema_id: Optional[str] = Field(
8291+
default=None,
8292+
description="""Required. Represents the schema ID for which this structured memory belongs to.""",
8293+
)
8294+
8295+
8296+
class MemoryStructuredContentDict(TypedDict, total=False):
8297+
"""Represents the structured value of the memory."""
8298+
8299+
data: Optional[dict[str, Any]]
8300+
"""Required. Represents the structured value of the memory."""
8301+
8302+
schema_id: Optional[str]
8303+
"""Required. Represents the schema ID for which this structured memory belongs to."""
8304+
8305+
8306+
MemoryStructuredContentOrDict = Union[
8307+
MemoryStructuredContent, MemoryStructuredContentDict
8308+
]
8309+
8310+
82728311
class Memory(_common.BaseModel):
82738312
"""A memory."""
82748313

@@ -8329,6 +8368,14 @@ class Memory(_common.BaseModel):
83298368
default=None,
83308369
description="""Output only. Timestamp when this Memory was most recently updated.""",
83318370
)
8371+
memory_type: Optional[MemoryType] = Field(
8372+
default=None,
8373+
description="""Optional. Represents the type of the memory. If not set, the `NATURAL_LANGUAGE_COLLECTION` type is used. If `STRUCTURED_COLLECTION` or `STRUCTURED_PROFILE` is used, then `structured_data` must be provided.""",
8374+
)
8375+
structured_content: Optional[MemoryStructuredContent] = Field(
8376+
default=None,
8377+
description="""Optional. Represents the structured content of the memory.""",
8378+
)
83328379

83338380

83348381
class MemoryDict(TypedDict, total=False):
@@ -8379,6 +8426,12 @@ class MemoryDict(TypedDict, total=False):
83798426
update_time: Optional[datetime.datetime]
83808427
"""Output only. Timestamp when this Memory was most recently updated."""
83818428

8429+
memory_type: Optional[MemoryType]
8430+
"""Optional. Represents the type of the memory. If not set, the `NATURAL_LANGUAGE_COLLECTION` type is used. If `STRUCTURED_COLLECTION` or `STRUCTURED_PROFILE` is used, then `structured_data` must be provided."""
8431+
8432+
structured_content: Optional[MemoryStructuredContentDict]
8433+
"""Optional. Represents the structured content of the memory."""
8434+
83828435

83838436
MemoryOrDict = Union[Memory, MemoryDict]
83848437

@@ -9284,6 +9337,13 @@ class RetrieveAgentEngineMemoriesConfig(_common.BaseModel):
92849337
metadata.author = "agent 321"))`.
92859338
""",
92869339
)
9340+
memory_types: Optional[list[MemoryType]] = Field(
9341+
default=None,
9342+
description="""Specifies the types of memories to retrieve. If this field is empty
9343+
or not provided, the request will default to retrieving only memories of
9344+
type `NATURAL_LANGUAGE_COLLECTION`. If populated, the request will
9345+
retrieve memories matching any of the specified `MemoryType` values.""",
9346+
)
92879347

92889348

92899349
class RetrieveAgentEngineMemoriesConfigDict(TypedDict, total=False):
@@ -9318,6 +9378,12 @@ class RetrieveAgentEngineMemoriesConfigDict(TypedDict, total=False):
93189378
metadata.author = "agent 321"))`.
93199379
"""
93209380

9381+
memory_types: Optional[list[MemoryType]]
9382+
"""Specifies the types of memories to retrieve. If this field is empty
9383+
or not provided, the request will default to retrieving only memories of
9384+
type `NATURAL_LANGUAGE_COLLECTION`. If populated, the request will
9385+
retrieve memories matching any of the specified `MemoryType` values."""
9386+
93219387

93229388
RetrieveAgentEngineMemoriesConfigOrDict = Union[
93239389
RetrieveAgentEngineMemoriesConfig, RetrieveAgentEngineMemoriesConfigDict

0 commit comments

Comments
 (0)