MCPcopy Create free account
hub / github.com/NanGePlus/LightRAGTest / delete_relation

Method delete_relation

LightRAG/lightrag/storage.py:144–163  ·  view source on GitHub ↗
(self, entity_name: str)

Source from the content-addressed store, hash-verified

142 logger.error(f"Error while deleting entity {entity_name}: {e}")
143
144 async def delete_relation(self, entity_name: str):
145 try:
146 relations = [
147 dp
148 for dp in self.client_storage["data"]
149 if dp["src_id"] == entity_name or dp["tgt_id"] == entity_name
150 ]
151 ids_to_delete = [relation["__id__"] for relation in relations]
152
153 if ids_to_delete:
154 self._client.delete(ids_to_delete)
155 logger.info(
156 f"All relations related to entity {entity_name} have been deleted."
157 )
158 else:
159 logger.info(f"No relations found for entity {entity_name}.")
160 except Exception as e:
161 logger.error(
162 f"Error while deleting relations for entity {entity_name}: {e}"
163 )
164
165 async def index_done_callback(self):
166 self._client.save()

Callers 1

adelete_by_entityMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected