delete_relations
Remove specified connections between entities in the knowledge graph memory to maintain accurate relationship data.
Instructions
Delete multiple relations from the knowledge graph
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| relations | Yes | An array of relations to delete |
Implementation Reference
- The handler function that executes the SQL DELETE operation for relations.
async def delete_relations( self, relations: List[Dict[str, Any]], batch_size: int = 1000 ) -> None: """Remove specific relations using batch processing.""" async with self.pool.get_connection() as conn: async with self.pool.transaction(conn): for i in range(0, len(relations), batch_size): batch = relations[i:i + batch_size] relation_objects = [Relation.from_dict(r) for r in batch] await conn.executemany( """ DELETE FROM relations WHERE from_entity = ? AND to_entity = ? AND relation_type = ? """, [(r.from_, r.to, r.relationType) for r in relation_objects] ) - The definition of the delete_relations tool schema.
name="delete_relations", description="Remove specific relations from the graph", inputSchema={ "type": "object", "properties": { "relations": { "type": "array", "items": { "type": "object", "properties": { "from": {"type": "string"}, "to": {"type": "string"}, "relationType": {"type": "string"} }, "required": ["from", "to", "relationType"], "additionalProperties": False } } }, "required": ["relations"], "additionalProperties": False } ),