mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-09-07 08:26:06 +00:00
* fix(bm25_index): 修正BM25索引计算中的文档长度归一化问题 修复了在计算BM25相似度时对文档长度进行不正确归一化的bug,确保所有查询都能得到准确的相关性评分。 * up * up * up * up * up * up * up * up * up * up * up * up * up * up * up * up * up * refactor(steps): Rename and adjust indexing step logic - Rename `scan_changes.py` and `reindex.py` to `clear_and_scan.py` - Update implementation details of `ScanChangesStep` and `ClearAndScanStep` - Modify the scheduling mechanism in `WatchChangesStep` - Adjust step registration and parameter configuration in config files - Update related tests to align with the new interface changes * up * feat(daily): replace daily CRUD operations with slug provisioning approach * refactor(tests): migrate CRUD step tests from HTTP server to direct LocalFileStore * up * up * up * up --------- Co-authored-by: huangsen <huangsen.huang@alibaba-inc.com>
68 lines
2.1 KiB
Python
68 lines
2.1 KiB
Python
"""Abstract base for file-graph backends."""
|
|
|
|
from abc import abstractmethod
|
|
|
|
from ..base_component import BaseComponent
|
|
from ...enumeration import ComponentEnum, LinkScopeEnum
|
|
from ...schema import FileLink, FileNode
|
|
|
|
|
|
class BaseFileGraph(BaseComponent):
|
|
"""Abstract base for file-graph backends.
|
|
|
|
Link scope (``get_outlinks`` / ``get_inlinks``):
|
|
REAL edges touching an indexed node
|
|
VIRTUAL edges touching a dangling placeholder
|
|
(referenced but never upserted, or already deleted)
|
|
ALL both
|
|
"""
|
|
|
|
component_type = ComponentEnum.FILE_GRAPH
|
|
|
|
# -- Lifecycle ---------------------------------------------------------
|
|
|
|
async def _start(self) -> None:
|
|
await super()._start()
|
|
await self.load()
|
|
|
|
async def _close(self) -> None:
|
|
await self.dump()
|
|
await super()._close()
|
|
|
|
async def load(self) -> None:
|
|
"""Restore persisted state. No-op for backends without local files."""
|
|
|
|
async def dump(self) -> None:
|
|
"""Persist state. No-op for backends without local files."""
|
|
|
|
# -- Node CRUD ---------------------------------------------------------
|
|
|
|
@abstractmethod
|
|
async def upsert_nodes(self, nodes: list[FileNode]) -> None:
|
|
"""Insert or update nodes."""
|
|
|
|
@abstractmethod
|
|
async def delete_nodes(self, paths: list[str]) -> None:
|
|
"""Remove nodes by path."""
|
|
|
|
@abstractmethod
|
|
async def get_nodes(self, paths: list[str] | None = None) -> list[FileNode]:
|
|
"""Return nodes by paths; ``None`` = all real nodes."""
|
|
|
|
@abstractmethod
|
|
async def rebuild_links(self) -> None:
|
|
"""Rebuild all edges from each node's link payload."""
|
|
|
|
@abstractmethod
|
|
async def clear(self):
|
|
"""Remove all nodes and edges."""
|
|
|
|
# -- Link access -------------------------------------------------------
|
|
|
|
@abstractmethod
|
|
async def get_outlinks(self, path: str, scope: LinkScopeEnum = LinkScopeEnum.REAL) -> list[FileLink]:
|
|
"""Outgoing links from *path*."""
|
|
|
|
@abstractmethod
|
|
async def get_inlinks(self, path: str, scope: LinkScopeEnum = LinkScopeEnum.REAL) -> list[FileLink]:
|
|
"""Inbound links to *path*."""
|