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 12cec2c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions agents-api/agents_api/models/session/create_session.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
This module contains the functionality for creating a new session in the 'cozodb' database.
It constructs and executes a datalog query to insert session data.
"""
from uuid import UUID

import pandas as pd
Expand All @@ -6,6 +10,21 @@
from ...clients.cozo import client


"""
Constructs and executes a datalog query to create a new session in the database.
Parameters:
- session_id (UUID): The unique identifier for the session.
- developer_id (UUID): The unique identifier for the developer.
- agent_id (UUID): The unique identifier for the agent.
- user_id (UUID | None): The unique identifier for the user, if applicable.
- situation (str | None): The situation/context of the session.
- metadata (dict): Additional metadata for the session.
- client (CozoClient): The database client used to execute the query.
Returns:
- pd.DataFrame: The result of the query execution.
"""
def create_session_query(
session_id: UUID,
developer_id: UUID,
Expand All @@ -15,6 +34,7 @@ def create_session_query(
metadata: dict = {},
client: CozoClient = client,
) -> pd.DataFrame:
# Construct the datalog query for creating a new session and its lookup.
query = """
{
# Create a new session lookup
Expand Down Expand Up @@ -47,6 +67,7 @@ def create_session_query(
:returning
}"""

# Execute the constructed query with the provided parameters and return the result.
return client.run(
query,
{
Expand Down

0 comments on commit 12cec2c

Please sign in to comment.