Skip to content

Commit

Permalink
feat: Updated agents-api/agents_api/models/entry/g
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] committed Apr 13, 2024
1 parent 4199c15 commit 444342f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions agents-api/agents_api/models/entry/get_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@
def get_entries_query(
session_id: UUID, limit: int = 100, offset: int = 0, client: CozoClient = client
) -> pd.DataFrame:
"""
Constructs and executes a query to retrieve entries from the 'cozodb' database.
Parameters:
session_id (UUID): The session ID to filter entries.
limit (int): The maximum number of entries to return. Defaults to 100.
offset (int): The offset from which to start returning entries. Defaults to 0.
client (CozoClient): The CozoClient instance to use for the query.
Returns:
pd.DataFrame: The query results as a pandas DataFrame.
"""
# Construct the query string to select specific fields from the 'entries' relation
# where the source is either "api_request" or "api_response", sorted by timestamp.
# The query uses placeholders for session_id, limit, and offset to prevent SQL injection.
query = """
{
?[
Expand Down Expand Up @@ -44,4 +59,5 @@ def get_entries_query(
query, {"session_id": str(session_id), "limit": limit, "offset": offset}
)

# Execute the constructed query against the 'cozodb' database using the provided parameters and return the results.
return results

0 comments on commit 444342f

Please sign in to comment.