diff --git a/vertexai/_genai/memories.py b/vertexai/_genai/memories.py index 2d4b1b180c..792a51cf68 100644 --- a/vertexai/_genai/memories.py +++ b/vertexai/_genai/memories.py @@ -329,6 +329,9 @@ def _RetrieveAgentEngineMemoriesConfig_to_vertex( [item for item in getv(from_object, ["filter_groups"])], ) + if getv(from_object, ["memory_types"]) is not None: + setv(parent_object, ["memoryTypes"], getv(from_object, ["memory_types"])) + return to_object diff --git a/vertexai/_genai/types/__init__.py b/vertexai/_genai/types/__init__.py index 937e8fe43f..5e5fb564e2 100644 --- a/vertexai/_genai/types/__init__.py +++ b/vertexai/_genai/types/__init__.py @@ -661,9 +661,13 @@ from .common import MemoryRevision from .common import MemoryRevisionDict from .common import MemoryRevisionOrDict +from .common import MemoryStructuredContent +from .common import MemoryStructuredContentDict +from .common import MemoryStructuredContentOrDict from .common import MemoryTopicId from .common import MemoryTopicIdDict from .common import MemoryTopicIdOrDict +from .common import MemoryType from .common import Message from .common import MessageDict from .common import Metadata @@ -1682,6 +1686,9 @@ "AgentEngineMemoryConfig", "AgentEngineMemoryConfigDict", "AgentEngineMemoryConfigOrDict", + "MemoryStructuredContent", + "MemoryStructuredContentDict", + "MemoryStructuredContentOrDict", "Memory", "MemoryDict", "MemoryOrDict", @@ -2138,6 +2145,7 @@ "ManagedTopicEnum", "IdentityType", "AgentServerMode", + "MemoryType", "Operator", "Language", "MachineConfig", diff --git a/vertexai/_genai/types/common.py b/vertexai/_genai/types/common.py index d549c5490c..af39fd7ab8 100644 --- a/vertexai/_genai/types/common.py +++ b/vertexai/_genai/types/common.py @@ -280,6 +280,17 @@ class AgentServerMode(_common.CaseInSensitiveEnum): """Experimental agent server mode. This mode contains experimental features.""" +class MemoryType(_common.CaseInSensitiveEnum): + """The type of the memory.""" + + MEMORY_TYPE_UNSPECIFIED = "MEMORY_TYPE_UNSPECIFIED" + """Represents an unspecified memory type. This value should not be used.""" + NATURAL_LANGUAGE_COLLECTION = "NATURAL_LANGUAGE_COLLECTION" + """Indicates belonging to a collection of natural language memories.""" + STRUCTURED_PROFILE = "STRUCTURED_PROFILE" + """Indicates belonging to a structured profile.""" + + class Operator(_common.CaseInSensitiveEnum): """Operator to apply to the filter. If not set, then EQUAL will be used.""" @@ -8269,6 +8280,34 @@ class _CreateAgentEngineMemoryRequestParametersDict(TypedDict, total=False): ] +class MemoryStructuredContent(_common.BaseModel): + """Represents the structured value of the memory.""" + + data: Optional[dict[str, Any]] = Field( + default=None, + description="""Required. Represents the structured value of the memory.""", + ) + schema_id: Optional[str] = Field( + default=None, + description="""Required. Represents the schema ID for which this structured memory belongs to.""", + ) + + +class MemoryStructuredContentDict(TypedDict, total=False): + """Represents the structured value of the memory.""" + + data: Optional[dict[str, Any]] + """Required. Represents the structured value of the memory.""" + + schema_id: Optional[str] + """Required. Represents the schema ID for which this structured memory belongs to.""" + + +MemoryStructuredContentOrDict = Union[ + MemoryStructuredContent, MemoryStructuredContentDict +] + + class Memory(_common.BaseModel): """A memory.""" @@ -8329,6 +8368,14 @@ class Memory(_common.BaseModel): default=None, description="""Output only. Timestamp when this Memory was most recently updated.""", ) + memory_type: Optional[MemoryType] = Field( + default=None, + 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.""", + ) + structured_content: Optional[MemoryStructuredContent] = Field( + default=None, + description="""Optional. Represents the structured content of the memory.""", + ) class MemoryDict(TypedDict, total=False): @@ -8379,6 +8426,12 @@ class MemoryDict(TypedDict, total=False): update_time: Optional[datetime.datetime] """Output only. Timestamp when this Memory was most recently updated.""" + memory_type: Optional[MemoryType] + """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.""" + + structured_content: Optional[MemoryStructuredContentDict] + """Optional. Represents the structured content of the memory.""" + MemoryOrDict = Union[Memory, MemoryDict] @@ -9284,6 +9337,13 @@ class RetrieveAgentEngineMemoriesConfig(_common.BaseModel): metadata.author = "agent 321"))`. """, ) + memory_types: Optional[list[MemoryType]] = Field( + default=None, + description="""Specifies the types of memories to retrieve. If this field is empty + or not provided, the request will default to retrieving only memories of + type `NATURAL_LANGUAGE_COLLECTION`. If populated, the request will + retrieve memories matching any of the specified `MemoryType` values.""", + ) class RetrieveAgentEngineMemoriesConfigDict(TypedDict, total=False): @@ -9318,6 +9378,12 @@ class RetrieveAgentEngineMemoriesConfigDict(TypedDict, total=False): metadata.author = "agent 321"))`. """ + memory_types: Optional[list[MemoryType]] + """Specifies the types of memories to retrieve. If this field is empty + or not provided, the request will default to retrieving only memories of + type `NATURAL_LANGUAGE_COLLECTION`. If populated, the request will + retrieve memories matching any of the specified `MemoryType` values.""" + RetrieveAgentEngineMemoriesConfigOrDict = Union[ RetrieveAgentEngineMemoriesConfig, RetrieveAgentEngineMemoriesConfigDict