From 79eae2de276c813e4bc3dced986e6b2db9649007 Mon Sep 17 00:00:00 2001 From: whiterabbit1983 Date: Wed, 17 Apr 2024 15:02:12 +0000 Subject: [PATCH] fix: Set metadata to an empty dict by default (#217) --- agents-api/agents_api/activities/types.py | 6 ++++-- agents-api/agents_api/clients/worker/types.py | 6 ++++-- agents-api/agents_api/models/agent/patch_agent.py | 2 +- agents-api/agents_api/models/session/patch_session.py | 2 +- agents-api/agents_api/models/user/patch_user.py | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/agents-api/agents_api/activities/types.py b/agents-api/agents_api/activities/types.py index 37fd8015d..4fa1d4d46 100644 --- a/agents-api/agents_api/activities/types.py +++ b/agents-api/agents_api/activities/types.py @@ -25,10 +25,12 @@ class ChatML(BaseModel): token_count: Optional[int] = None -class BaseTask(BaseModel): ... +class BaseTask(BaseModel): + ... -class BaseTaskArgs(BaseModel): ... +class BaseTaskArgs(BaseModel): + ... class AddPrinciplesTaskArgs(BaseTaskArgs): diff --git a/agents-api/agents_api/clients/worker/types.py b/agents-api/agents_api/clients/worker/types.py index 86bf564dd..16fa8404b 100644 --- a/agents-api/agents_api/clients/worker/types.py +++ b/agents-api/agents_api/clients/worker/types.py @@ -25,10 +25,12 @@ class ChatML(BaseModel): token_count: Optional[int] = None -class BaseTask(BaseModel): ... +class BaseTask(BaseModel): + ... -class BaseTaskArgs(BaseModel): ... +class BaseTaskArgs(BaseModel): + ... class MemoryManagementTaskArgs(BaseTaskArgs): diff --git a/agents-api/agents_api/models/agent/patch_agent.py b/agents-api/agents_api/models/agent/patch_agent.py index f296bbf8a..e4f995041 100644 --- a/agents-api/agents_api/models/agent/patch_agent.py +++ b/agents-api/agents_api/models/agent/patch_agent.py @@ -26,7 +26,7 @@ def patch_agent_query( """ # Construct the query for updating agent information in the database. # Agent update query - metadata = update_data.pop("metadata", {}) + metadata = update_data.pop("metadata", {}) or {} agent_update_cols, agent_update_vals = cozo_process_mutate_data( { **{k: v for k, v in update_data.items() if v is not None}, diff --git a/agents-api/agents_api/models/session/patch_session.py b/agents-api/agents_api/models/session/patch_session.py index da6cd5f18..60c5885e2 100644 --- a/agents-api/agents_api/models/session/patch_session.py +++ b/agents-api/agents_api/models/session/patch_session.py @@ -45,7 +45,7 @@ def patch_session_query( :assert some """ - metadata = update_data.pop("metadata", {}) + metadata = update_data.pop("metadata", {}) or {} session_update_cols, session_update_vals = cozo_process_mutate_data( {k: v for k, v in update_data.items() if v is not None} diff --git a/agents-api/agents_api/models/user/patch_user.py b/agents-api/agents_api/models/user/patch_user.py index 681be820a..f0c4429ee 100644 --- a/agents-api/agents_api/models/user/patch_user.py +++ b/agents-api/agents_api/models/user/patch_user.py @@ -24,7 +24,7 @@ def patch_user_query(developer_id: UUID, user_id: UUID, **update_data) -> pd.DataFrame: # Prepare data for mutation by filtering out None values and adding system-generated fields. - metadata = update_data.pop("metadata", {}) + metadata = update_data.pop("metadata", {}) or {} user_update_cols, user_update_vals = cozo_process_mutate_data( { **{k: v for k, v in update_data.items() if v is not None},