Skip to content

Commit

Permalink
feat: Updated agents-api/agents_api/models/session
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 6afdac6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions agents-api/agents_api/models/session/patch_session.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""This module contains functions for patching session data in the 'cozodb' database using datalog queries."""

from uuid import UUID

import pandas as pd
Expand All @@ -21,6 +23,16 @@ def patch_session_query(
developer_id: UUID,
**update_data,
) -> pd.DataFrame:
"""Patch session data in the 'cozodb' database.
Parameters:
- session_id (UUID): The unique identifier for the session to be updated.
- developer_id (UUID): The unique identifier for the developer making the update.
- **update_data: Arbitrary keyword arguments representing the data to update.
Returns:
pd.DataFrame: A pandas DataFrame containing the result of the update operation.
"""
session_update_cols, session_update_vals = cozo_process_mutate_data(
{
**{k: v for k, v in update_data.items() if v is not None},
Expand All @@ -37,6 +49,7 @@ def patch_session_query(
)
)

# Constructing a datalog query for updating session data based on provided parameters.
session_update_query = f"""
{{
input[{session_update_cols}] <- $session_update_vals
Expand All @@ -58,6 +71,7 @@ def patch_session_query(
}}
"""

# Execute the constructed datalog query and return the result as a pandas DataFrame.
return client.run(
session_update_query,
{
Expand Down

0 comments on commit 6afdac6

Please sign in to comment.