mirror of
https://github.com/basicmachines-co/basic-memory
synced 2026-06-21 13:47:35 +00:00
tests passing
This commit is contained in:
@@ -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
|
||||
)
|
||||
|
||||
@@ -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."""
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user