mirror of
https://github.com/basicmachines-co/basic-memory
synced 2026-06-21 13:47:35 +00:00
get entity content via tool
This commit is contained in:
@@ -146,11 +146,17 @@ for dep in deps:
|
||||
],
|
||||
output_model=EntityResponse
|
||||
)
|
||||
async def get_entity(path_id: PathId) -> EntityResponse:
|
||||
"""Get a specific entity by its path_id."""
|
||||
async def get_entity(path_id: PathId, content: bool = False) -> EntityResponse:
|
||||
"""Get a specific entity by its path_id.
|
||||
|
||||
Args:
|
||||
path_id: Path identifier for the entity
|
||||
content: If True, includes the full markdown content of the entity
|
||||
"""
|
||||
try:
|
||||
url = f"/knowledge/entities/{path_id}"
|
||||
response = await client.get(url)
|
||||
params = {"content": "true"} if content else {}
|
||||
response = await client.get(url, params=params)
|
||||
if response.status_code == 404:
|
||||
raise EntityNotFoundError(f"Entity not found: {path_id}")
|
||||
response.raise_for_status()
|
||||
|
||||
@@ -57,8 +57,11 @@ class EntityOperations:
|
||||
# 1. Create entity in DB
|
||||
db_entity = await self.entity_service.create_entity(entity)
|
||||
|
||||
# if content is provided use that, otherwise write the entity info
|
||||
content = entity.content or None
|
||||
|
||||
# 2. Write file and get checksum
|
||||
_, checksum = await self.file_operations.write_entity_file(db_entity, content=entity.content)
|
||||
_, checksum = await self.file_operations.write_entity_file(db_entity, content=content)
|
||||
|
||||
# 3. Update DB with checksum
|
||||
updated = await self.entity_service.update_entity(
|
||||
|
||||
Reference in New Issue
Block a user