Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
emrgnt-cmplxty committed Dec 2, 2024
1 parent 6ca9fa3 commit cfae71f
Show file tree
Hide file tree
Showing 3 changed files with 266 additions and 170 deletions.
25 changes: 23 additions & 2 deletions py/core/main/api/v3/documents_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,10 @@ async def extract(

settings = settings.dict() if settings else None # type: ignore
if not auth_user.is_superuser:
logger.warning("Implement permission checks here.")
raise R2RException(
"Only a superuser can extract entities and relationships from a document.",
403,
)

# If no run type is provided, default to estimate
if not run_type:
Expand Down Expand Up @@ -1376,6 +1379,15 @@ async def get_entities(
Results are returned in the order they were extracted from the document.
"""
if (
not auth_user.is_superuser
and id not in auth_user.collection_ids
):
raise R2RException(
"The currently authenticated user does not have access to the specified collection.",
403,
)

# First check if the document exists and user has access
documents_overview_response = await self.services[
"management"
Expand Down Expand Up @@ -1470,7 +1482,7 @@ async def get_entities(
},
)
@self.base_endpoint
async def list_relationships(
async def get_relationships(
id: UUID = Path(
...,
description="The ID of the document to retrieve relationships for.",
Expand Down Expand Up @@ -1505,6 +1517,15 @@ async def list_relationships(
Results are returned in the order they were extracted from the document.
"""
if (
not auth_user.is_superuser
and id not in auth_user.collection_ids
):
raise R2RException(
"The currently authenticated user does not have access to the specified collection.",
403,
)

# First check if the document exists and user has access
documents_overview_response = await self.services[
"management"
Expand Down
Loading

0 comments on commit cfae71f

Please sign in to comment.