From 94f0a391a87b8db5f18a549e85355a6588d09f97 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Sat, 13 Apr 2024 13:06:32 +0000 Subject: [PATCH] feat: Updated agents-api/agents_api/models/agent/u --- .../agents_api/models/agent/update_agent.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/agents-api/agents_api/models/agent/update_agent.py b/agents-api/agents_api/models/agent/update_agent.py index d8bffb0c..ad05805d 100644 --- a/agents-api/agents_api/models/agent/update_agent.py +++ b/agents-api/agents_api/models/agent/update_agent.py @@ -1,3 +1,8 @@ +""" +This module provides functionality for updating agent data in the 'cozodb' database. +It includes the `update_agent_query` function which constructs and executes datalog queries for updating agent and their settings. +""" + from uuid import UUID import pandas as pd @@ -7,6 +12,19 @@ from ...common.utils.cozo import cozo_process_mutate_data +""" +Constructs and executes a datalog query to update an agent and its default settings in the 'cozodb' database. + +Parameters: +- agent_id (UUID): The unique identifier of the agent to be updated. +- developer_id (UUID): The unique identifier of the developer associated with the agent. +- default_settings (dict, optional): A dictionary of default settings to be updated for the agent. Defaults to an empty dict. +- client (CozoClient, optional): The database client used to execute the query. Defaults to a pre-configured client instance. +- **update_data: Variable keyword arguments representing additional agent data to be updated. + +Returns: +- pd.DataFrame: A DataFrame containing the result of the update operation. +""" def update_agent_query( agent_id: UUID, developer_id: UUID, @@ -18,6 +36,7 @@ def update_agent_query( developer_id = str(developer_id) update_data["instructions"] = update_data.get("instructions", []) + # Construct the agent update part of the query with dynamic columns and values based on `update_data`. # Agent update query agent_update_cols, agent_update_vals = cozo_process_mutate_data( { @@ -51,6 +70,7 @@ def update_agent_query( }} """ + # Construct the settings update part of the query if `default_settings` are provided. # Settings update query settings_cols, settings_vals = cozo_process_mutate_data( { @@ -70,6 +90,7 @@ def update_agent_query( }} """ + # Combine agent and settings update queries into a single query string. # Combine the queries queries = [agent_update_query]