Skip to content

Commit

Permalink
feat: Updated agents-api/agents_api/models/agent/u
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] committed Apr 13, 2024
1 parent ddd39cc commit 94f0a39
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions agents-api/agents_api/models/agent/update_agent.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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,
Expand All @@ -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(
{
Expand Down Expand Up @@ -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(
{
Expand All @@ -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]

Expand Down

0 comments on commit 94f0a39

Please sign in to comment.