Skip to content

Commit

Permalink
feat: Updated agents-api/agents_api/models/docs/de
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] committed Apr 13, 2024
1 parent 5e53710 commit 895de73
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions agents-api/agents_api/models/docs/delete_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,29 @@ def delete_docs_by_id_query(
doc_id: UUID,
client: CozoClient = client,
) -> pd.DataFrame:
"""Constructs and returns a datalog query for deleting documents and associated information snippets.
This function targets the 'cozodb' database, allowing for the removal of documents and their related information snippets based on the provided document ID and owner (user or agent).
Parameters:
owner_type (Literal["user", "agent"]): The type of the owner, either 'user' or 'agent'.
owner_id (UUID): The UUID of the owner.
doc_id (UUID): The UUID of the document to be deleted.
client (CozoClient): An instance of the CozoClient to execute the query.
Returns:
pd.DataFrame: The result of the executed datalog query.
"""
# Convert UUID parameters to string format for use in the datalog query
owner_id = str(owner_id)
doc_id = str(doc_id)

# The following query is divided into two main parts:
# 1. Deleting information snippets associated with the document
# 2. Deleting the document itself from the owner's collection
query = f"""
{{
# This section constructs the subquery for identifying and deleting all information snippets associated with the given document ID.
# Delete snippets
input[doc_id] <- [[to_uuid($doc_id)]]
?[doc_id, snippet_idx] :=
Expand All @@ -32,6 +50,7 @@ def delete_docs_by_id_query(
snippet_idx
}}
}} {{
# This section constructs the subquery for deleting the document from the specified owner's (user or agent) document collection.
# Delete the docs
?[doc_id, {owner_type}_id] <- [[
to_uuid($doc_id),
Expand Down

0 comments on commit 895de73

Please sign in to comment.