tests passing

This commit is contained in:
phernandez
2024-12-14 10:00:39 -06:00
parent 1ed4c72faa
commit e63e78950a
6 changed files with 31 additions and 17 deletions
+6 -6
View File
@@ -176,17 +176,17 @@ async def read_entity_file(project_entities_path: Path, entity_id: str) -> Entit
relation_type = parts[0]
context = parts[1] if len(parts) > 1 else None
relations.append(RelationIn(
from_id=entity_id,
to_id=target_id,
relation_type=relation_type,
relations.append(RelationIn( # pyright: ignore [reportCallIssue]
from_id=entity_id, # pyright: ignore [reportCallIssue]
to_id=target_id, # pyright: ignore [reportCallIssue]
relation_type=relation_type, # pyright: ignore [reportCallIssue]
context=context
))
return EntityIn(
return EntityIn( # pyright: ignore [reportCallIssue]
id=entity_id,
name=name,
entity_type=entity_type,
entity_type=entity_type, # pyright: ignore [reportCallIssue]
observations=observations,
relations=relations
)
+10
View File
@@ -97,6 +97,12 @@ class OpenNodesInput(BaseModel):
"""Input schema for open_nodes tool."""
names: Annotated[List[str], Len(min_length=1)]
class AddObservationsInput(BaseModel):
"""Input schema for add_observations tool."""
entity_id: str = Field(alias="entityId")
observations: List[ObservationIn]
model_config = ConfigDict(populate_by_name=True)
class CreateRelationsInput(BaseModel):
"""Input schema for create_relations tool."""
relations: List[RelationIn]
@@ -123,6 +129,10 @@ class OpenNodesResponse(SQLAlchemyOut):
"""Response for open_nodes tool."""
entities: List[EntityOut]
class AddObservationsResponse(SQLAlchemyOut):
"""Response for add_observations tool."""
entity_id: str
added_observations: List[ObservationOut]
class CreateRelationsResponse(SQLAlchemyOut):
"""Response for create_relations tool."""
+5 -1
View File
@@ -96,6 +96,9 @@ class EntityService:
logger.exception(f"Failed to get entity by type/name: {entity_type}/{name}")
raise
async def get_all(self) -> Sequence[Entity]:
return await self.entity_repo.find_all()
async def delete_entity(self, entity_id: str) -> bool:
"""Delete entity from database."""
logger.debug(f"Deleting entity: {entity_id}")
@@ -105,4 +108,5 @@ class EntityService:
return result
except Exception:
logger.exception(f"Failed to delete entity: {entity_id}")
raise
raise
+5 -2
View File
@@ -133,9 +133,12 @@ class MemoryService:
# Write updated entity files (filesystem is source of truth)
logger.debug("Writing updated entity files")
assert from_entity.id is not None
assert to_entity.id is not None
await asyncio.gather(
write_entity_file(self.entities_path, from_entity.id, from_entity),
write_entity_file(self.entities_path, to_entity.id, to_entity)
*[write_entity_file(self.entities_path, from_entity.id, from_entity),
write_entity_file(self.entities_path, to_entity.id, to_entity)]
)
logger.debug("Wrote updated entity files")