Skip to content

Commit 6c3ef43

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 6c3ef43

File tree

3 files changed

+102
-0
lines changed

3 files changed

+102
-0
lines changed

vertexai/_genai/memories.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,13 @@ 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(
334+
parent_object,
335+
["memoryTypes"],
336+
[item for item in getv(from_object, ["memory_types"])],
337+
)
338+
332339
return to_object
333340

334341

vertexai/_genai/types/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,9 +661,16 @@
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
671+
from .common import MemoryType
672+
from .common import MemoryTypeDict
673+
from .common import MemoryTypeOrDict
667674
from .common import Message
668675
from .common import MessageDict
669676
from .common import Metadata
@@ -1682,6 +1689,9 @@
16821689
"AgentEngineMemoryConfig",
16831690
"AgentEngineMemoryConfigDict",
16841691
"AgentEngineMemoryConfigOrDict",
1692+
"MemoryStructuredContent",
1693+
"MemoryStructuredContentDict",
1694+
"MemoryStructuredContentOrDict",
16851695
"Memory",
16861696
"MemoryDict",
16871697
"MemoryOrDict",
@@ -1742,6 +1752,9 @@
17421752
"MemoryConjunctionFilter",
17431753
"MemoryConjunctionFilterDict",
17441754
"MemoryConjunctionFilterOrDict",
1755+
"MemoryType",
1756+
"MemoryTypeDict",
1757+
"MemoryTypeOrDict",
17451758
"RetrieveAgentEngineMemoriesConfig",
17461759
"RetrieveAgentEngineMemoriesConfigDict",
17471760
"RetrieveAgentEngineMemoriesConfigOrDict",
@@ -2138,6 +2151,7 @@
21382151
"ManagedTopicEnum",
21392152
"IdentityType",
21402153
"AgentServerMode",
2154+
"MemoryType",
21412155
"Operator",
21422156
"Language",
21432157
"MachineConfig",

vertexai/_genai/types/common.py

Lines changed: 81 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+
"""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."""
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

@@ -9250,6 +9303,21 @@ class MemoryConjunctionFilterDict(TypedDict, total=False):
92509303
]
92519304

92529305

9306+
class MemoryType(_common.BaseModel):
9307+
"""The type of the memory."""
9308+
9309+
pass
9310+
9311+
9312+
class MemoryTypeDict(TypedDict, total=False):
9313+
"""The type of the memory."""
9314+
9315+
pass
9316+
9317+
9318+
MemoryTypeOrDict = Union[MemoryType, MemoryTypeDict]
9319+
9320+
92539321
class RetrieveAgentEngineMemoriesConfig(_common.BaseModel):
92549322
"""Config for retrieving memories."""
92559323

@@ -9284,6 +9352,13 @@ class RetrieveAgentEngineMemoriesConfig(_common.BaseModel):
92849352
metadata.author = "agent 321"))`.
92859353
""",
92869354
)
9355+
memory_types: Optional[list[MemoryType]] = Field(
9356+
default=None,
9357+
description="""Specifies the types of memories to retrieve. If this field is empty
9358+
or not provided, the request will default to retrieving only memories of
9359+
type `NATURAL_LANGUAGE_COLLECTION`. If populated, the request will
9360+
retrieve memories matching any of the specified `MemoryType` values.""",
9361+
)
92879362

92889363

92899364
class RetrieveAgentEngineMemoriesConfigDict(TypedDict, total=False):
@@ -9318,6 +9393,12 @@ class RetrieveAgentEngineMemoriesConfigDict(TypedDict, total=False):
93189393
metadata.author = "agent 321"))`.
93199394
"""
93209395

9396+
memory_types: Optional[list[MemoryTypeDict]]
9397+
"""Specifies the types of memories to retrieve. If this field is empty
9398+
or not provided, the request will default to retrieving only memories of
9399+
type `NATURAL_LANGUAGE_COLLECTION`. If populated, the request will
9400+
retrieve memories matching any of the specified `MemoryType` values."""
9401+
93219402

93229403
RetrieveAgentEngineMemoriesConfigOrDict = Union[
93239404
RetrieveAgentEngineMemoriesConfig, RetrieveAgentEngineMemoriesConfigDict

0 commit comments

Comments
 (0)