Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions agentplatform/_genai/agent_engines.py
Original file line number Diff line number Diff line change
Expand Up @@ -1950,6 +1950,17 @@ def create(
if context_spec is not None:
# Conversion to a dict for _create_config
context_spec = json.loads(context_spec.model_dump_json())
context_spec_obj = types.ReasoningEngineContextSpec(**context_spec)
for schema in context_spec_obj.memory_bank_config.structured_memory_configs:
for schema_config in schema.schema_configs:
schema_config.memory_schema = genai_types.Schema.from_json_schema(
json_schema=genai_types.JSONSchema(
**schema_config.memory_schema
)
)
context_spec = json.loads(context_spec_obj.model_dump_json())
print(f"context_spec: {context_spec}")

developer_connect_source = config.developer_connect_source
if developer_connect_source is not None:
developer_connect_source = json.loads(
Expand Down
4 changes: 2 additions & 2 deletions agentplatform/_genai/types/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -7528,7 +7528,7 @@ class ReasoningEngineContextSpecMemoryBankConfigTtlConfigDict(TypedDict, total=F
class StructuredMemorySchemaConfig(_common.BaseModel):
"""Represents the OpenAPI schema of the structured memories."""

memory_schema: Optional[genai_types.Schema] = Field(
memory_schema: Optional[Any] = Field(
default=None,
description="""Required. Represents the OpenAPI schema of the structured memories.""",
)
Expand All @@ -7545,7 +7545,7 @@ class StructuredMemorySchemaConfig(_common.BaseModel):
class StructuredMemorySchemaConfigDict(TypedDict, total=False):
"""Represents the OpenAPI schema of the structured memories."""

memory_schema: Optional[genai_types.SchemaDict]
memory_schema: Optional[Any]
"""Required. Represents the OpenAPI schema of the structured memories."""

id: Optional[str]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,22 @@
#
# pylint: disable=protected-access,bad-continuation,missing-function-docstring

import pydantic

from tests.unit.agentplatform.genai.replays import pytest_helper
from agentplatform._genai import types


def test_generate_and_retrieve_profile(client):
# TODO: Use prod once available.
client._api_client._http_options.base_url = (
"https://us-central1-autopush-aiplatform.sandbox.googleapis.com"
)

class ProfileSchema(pydantic.BaseModel):

class NestedProfileSchema(pydantic.BaseModel):
hometown: str

name: list[str]
profile: NestedProfileSchema

customization_config = {"disable_natural_language_memories": True}
memory_bank_customization_config = types.MemoryBankCustomizationConfig(
**customization_config
Expand All @@ -32,12 +39,7 @@ def test_generate_and_retrieve_profile(client):
"schema_configs": [
{
"id": "user-profile",
"memory_schema": {
"properties": {
"name": {"description": "User's name", "type": "string"}
},
"type": "object",
},
"memory_schema": ProfileSchema.model_json_schema(),
}
],
}
Expand Down
Loading