mirror of
https://github.com/basicmachines-co/basic-memory
synced 2026-06-21 13:47:35 +00:00
add list_by_type tool
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"""Service for managing entities in the database."""
|
||||
|
||||
from typing import Dict, Any, Sequence, List
|
||||
from typing import Dict, Any, Sequence, List, Optional
|
||||
|
||||
from loguru import logger
|
||||
|
||||
@@ -72,6 +72,19 @@ class EntityService(BaseService[EntityRepository]):
|
||||
"""Get list of all distinct entity types in the system."""
|
||||
logger.debug("Getting all distinct entity types")
|
||||
return await self.repository.get_entity_types()
|
||||
|
||||
async def list_entities(
|
||||
self,
|
||||
entity_type: Optional[str] = None,
|
||||
sort_by: Optional[str] = "updated_at",
|
||||
include_related: bool = False,
|
||||
) -> Sequence[EntityModel]:
|
||||
"""List entities with optional filtering and sorting."""
|
||||
logger.debug(f"Listing entities: type={entity_type} sort={sort_by}")
|
||||
return await self.repository.list_entities(
|
||||
entity_type=entity_type,
|
||||
sort_by=sort_by
|
||||
)
|
||||
|
||||
async def delete_entity(self, path_id: str) -> bool:
|
||||
"""Delete entity from database."""
|
||||
@@ -88,4 +101,4 @@ class EntityService(BaseService[EntityRepository]):
|
||||
"""Delete entities and their files."""
|
||||
logger.debug(f"Deleting entities: {path_ids}")
|
||||
deleted_count = await self.repository.delete_by_path_ids(path_ids)
|
||||
return deleted_count > 0
|
||||
return deleted_count > 0
|
||||
Reference in New Issue
Block a user