get entity content via tool

This commit is contained in:
phernandez
2025-01-09 14:52:41 -06:00
parent 4cb654a4fb
commit b68e7461ef
3 changed files with 46 additions and 7 deletions
+9 -3
View File
@@ -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(