mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-09-21 00:22:45 +00:00
Some checks failed
Pre-commit / run (ubuntu-latest) (push) Has been cancelled
docs: add ReMe2 architecture design documentation - Add comprehensive design document (reme2.md) detailing the three-layer architecture (L1/L2/L3) for the vault system - Document new protocols for folder notes and memory management - Specify interface contracts for memory_* and vault_* tools - Outline implementation phases from current state to target refactor: fix typo in personal retriever class - Correct spelling error: 'retri eved_nodes' -> 'retrieved_nodes' in PersonalRetriever.result assignment chore: update gitignore with vault-related patterns - Add '/vault' to ignore vault directory - Add '/reme-plugin' to ignore plugin files - Add '/reme2/vault' to ignore new vault implementation ```
43 lines
1.7 KiB
Python
43 lines
1.7 KiB
Python
"""FileEdge — typed wikilink edge between vault files.
|
|
|
|
Replaces the prior `link: list[str]` model on FileMetadata. An edge
|
|
captures both the bare wikilink shape (`target` + optional anchor /
|
|
alias / embed prefix) AND the typed-edge predicate that turns a plain
|
|
`[[X]]` reference into a graph relation.
|
|
|
|
Sources:
|
|
"regex" — extracted from inline syntax (`[[X]]`, `[pred:: [[X]]]`)
|
|
"frontmatter" — inferred from a frontmatter key acting as predicate
|
|
(e.g. `author: "[[John]]"` → predicate="author")
|
|
"llm" — produced by an IE pipeline; should set `confidence`
|
|
|
|
The `target` field stays raw (e.g. `"X"` or `"topics/X"`) — resolution
|
|
to an absolute path is done by the file_store via `resolve_wikilink`.
|
|
"""
|
|
|
|
from typing import Literal
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class FileEdge(BaseModel):
|
|
target: str = Field(..., description="Raw wikilink target as written in source.")
|
|
predicate: str | None = Field(
|
|
default=None,
|
|
description="Typed-edge predicate (Dataview-style). None for plain wikilinks.",
|
|
)
|
|
anchor: str | None = Field(default=None, description="Heading or block anchor (after #).")
|
|
alias: str | None = Field(default=None, description="Display alias (after |).")
|
|
embed: bool = Field(default=False, description="True for `![[X]]` embed prefix.")
|
|
source: Literal["regex", "frontmatter", "llm"] = Field(
|
|
default="regex",
|
|
description="Provenance of this edge.",
|
|
)
|
|
confidence: float | None = Field(
|
|
default=None,
|
|
description="LLM confidence (0..1). None for regex/frontmatter.",
|
|
)
|
|
|
|
@property
|
|
def is_typed(self) -> bool:
|
|
return self.predicate is not None
|