modify knowledge writer

This commit is contained in:
phernandez
2025-01-07 21:45:18 -06:00
parent 1c6836d83f
commit 286addb221
4 changed files with 177 additions and 60 deletions
@@ -115,14 +115,22 @@ async def add_observations(
@router.get("/entities/{path_id:path}", response_model=EntityResponse)
async def get_entity(path_id: PathId, knowledge_service: KnowledgeServiceDep) -> EntityResponse:
"""Get a specific entity by ID."""
async def get_entity(
knowledge_service: KnowledgeServiceDep,
path_id: PathId,
content: bool = False, # New parameter
) -> EntityResponse:
"""Get a specific entity by ID.
Args:
path_id: Entity path ID
content: If True, include full file content
"""
try:
entity = await knowledge_service.get_entity_by_path_id(path_id)
entity_response = EntityResponse.model_validate(entity)
# if the entity is a note, we add the content via reading from the file
if entity_response.entity_type == "note":
if content: # Load content if requested
content = await knowledge_service.read_entity_content(entity)
entity_response.content = content
@@ -130,7 +138,6 @@ async def get_entity(path_id: PathId, knowledge_service: KnowledgeServiceDep) ->
except EntityNotFoundError:
raise HTTPException(status_code=404, detail=f"Entity with {path_id} not found")
@router.post("/nodes", response_model=EntityListResponse)
async def open_nodes(
data: OpenNodesRequest, entity_service: EntityServiceDep