updated clean of what implemented on DocStatusStorage

This commit is contained in:
Yannick Stephan
2025-02-16 13:53:59 +01:00
parent 71a18d1de9
commit 882190a515
9 changed files with 164 additions and 168 deletions

View File

@@ -92,22 +92,20 @@ class StorageNameSpace:
class BaseVectorStorage(StorageNameSpace):
embedding_func: EmbeddingFunc
meta_fields: set[str] = field(default_factory=set)
async def query(self, query: str, top_k: int) -> list[dict[str, Any]]:
"""Query the vector storage and retrieve top_k results."""
raise NotImplementedError
async def upsert(self, data: dict[str, dict[str, Any]]) -> None:
"""Use 'content' field from value for embedding, use key as id.
If embedding_func is None, use 'embedding' field from value
"""
"""Insert or update vectors in the storage."""
raise NotImplementedError
async def delete_entity(self, entity_name: str) -> None:
"""Delete a single entity by its name"""
"""Delete a single entity by its name."""
raise NotImplementedError
async def delete_entity_relation(self, entity_name: str) -> None:
"""Delete relations for a given entity by scanning metadata"""
"""Delete relations for a given entity."""
raise NotImplementedError
@@ -116,9 +114,11 @@ class BaseKVStorage(StorageNameSpace):
embedding_func: EmbeddingFunc | None = None
async def get_by_id(self, id: str) -> dict[str, Any] | None:
"""Get value by id"""
raise NotImplementedError
async def get_by_ids(self, ids: list[str]) -> list[dict[str, Any]]:
"""Get values by ids"""
raise NotImplementedError
async def filter_keys(self, keys: set[str]) -> set[str]:
@@ -126,9 +126,11 @@ class BaseKVStorage(StorageNameSpace):
raise NotImplementedError
async def upsert(self, data: dict[str, dict[str, Any]]) -> None:
"""Upsert data"""
raise NotImplementedError
async def drop(self) -> None:
"""Drop the storage"""
raise NotImplementedError
@@ -138,74 +140,62 @@ class BaseGraphStorage(StorageNameSpace):
"""Check if a node exists in the graph."""
async def has_node(self, node_id: str) -> bool:
"""Check if an edge exists in the graph."""
raise NotImplementedError
"""Check if an edge exists in the graph."""
async def has_edge(self, source_node_id: str, target_node_id: str) -> bool:
"""Get the degree of a node."""
raise NotImplementedError
"""Get the degree of a node."""
async def node_degree(self, node_id: str) -> int:
"""Get the degree of an edge."""
raise NotImplementedError
"""Get the degree of an edge."""
async def edge_degree(self, src_id: str, tgt_id: str) -> int:
"""Get a node by its id."""
raise NotImplementedError
"""Get a node by its id."""
async def get_node(self, node_id: str) -> dict[str, str] | None:
"""Get an edge by its source and target node ids."""
raise NotImplementedError
"""Get an edge by its source and target node ids."""
async def get_edge(
self, source_node_id: str, target_node_id: str
) -> dict[str, str] | None:
"""Get all edges connected to a node."""
raise NotImplementedError
"""Get all edges connected to a node."""
async def get_node_edges(self, source_node_id: str) -> list[tuple[str, str]] | None:
"""Upsert a node into the graph."""
raise NotImplementedError
"""Upsert a node into the graph."""
async def upsert_node(self, node_id: str, node_data: dict[str, str]) -> None:
"""Upsert an edge into the graph."""
raise NotImplementedError
"""Upsert an edge into the graph."""
async def upsert_edge(
self, source_node_id: str, target_node_id: str, edge_data: dict[str, str]
) -> None:
"""Delete a node from the graph."""
raise NotImplementedError
"""Delete a node from the graph."""
async def delete_node(self, node_id: str) -> None:
"""Embed nodes using an algorithm."""
raise NotImplementedError
"""Embed nodes using an algorithm."""
async def embed_nodes(
self, algorithm: str
) -> tuple[np.ndarray[Any, Any], list[str]]:
"""Get all labels in the graph."""
raise NotImplementedError("Node embedding is not used in lightrag.")
"""Get all labels in the graph."""
async def get_all_labels(self) -> list[str]:
"""Get a knowledge graph of a node."""
raise NotImplementedError
"""Get a knowledge graph of a node."""
async def get_knowledge_graph(
self, node_label: str, max_depth: int = 5
) -> KnowledgeGraph:
async def get_knowledge_graph(self, node_label: str, max_depth: int = 5) -> KnowledgeGraph:
"""Retrieve a subgraph of the knowledge graph starting from a given node."""
raise NotImplementedError