app/core/derive_edges.py aktualisiert
Some checks failed
Deploy mindnet to llm-node / deploy (push) Failing after 1s
Some checks failed
Deploy mindnet to llm-node / deploy (push) Failing after 1s
This commit is contained in:
parent
da2bbf72a6
commit
38fd7420ff
|
|
@ -4,20 +4,26 @@
|
||||||
Name: app/core/derive_edges.py
|
Name: app/core/derive_edges.py
|
||||||
Version: v1.1.0 (2025-09-05)
|
Version: v1.1.0 (2025-09-05)
|
||||||
|
|
||||||
Kurzbeschreibung:
|
Kurzbeschreibung
|
||||||
Leitet Edges aus Wikilinks ([[...]]) ab.
|
Leitet Edges aus Wikilinks ([[…]]) ab und löst Zielnoten robust auf.
|
||||||
- Unterstützt Auflösung über note_id, Title-Slug, File-Slug.
|
Erzeugt:
|
||||||
- Erzeugt Edges:
|
- "references" (Note -> Note) mit seq="body", pro Match eine eigene Occurrence 'occ'
|
||||||
* "references" (Note->Note) + "backlink" (inverse)
|
- "backlink" (inverse zu "references", gleiche seq/occ)
|
||||||
* "references_at" (Chunk->Note) mit seq = chunk_index
|
- "references_at" (Chunk -> Note) mit seq=<chunk_index> und eigener 'occ' je Match
|
||||||
- **NEU**: pro Match ein Occurrence-Zähler 'occ' für eindeutige Edge-IDs.
|
|
||||||
|
|
||||||
Kompatibilität:
|
Aufruf
|
||||||
- Vorherige Payload-Felder bleiben erhalten.
|
from app.core.derive_edges import build_note_index, derive_wikilink_edges
|
||||||
- Zusätzliche Felder: 'seq' für Volltext ("body"), 'occ' überall.
|
|
||||||
|
|
||||||
Changelog:
|
Parameter / Felder
|
||||||
v1.1.0: 'occ' eingeführt; 'references' erhalten jetzt seq="body".
|
- note_payload: {"note_id","title","path","fulltext": <body> , …}
|
||||||
|
- chunks_payloads: [{"chunk_id","text",…}, …]
|
||||||
|
- note_index: build_note_index([...]) -> (by_id, by_slug, by_file_slug)
|
||||||
|
|
||||||
|
Kompatibilität
|
||||||
|
- Rückwärtskompatible Payload-Felder, nur erweitert um 'seq' und 'occ'.
|
||||||
|
|
||||||
|
Changelog
|
||||||
|
v1.1.0: Occurrence-Zählung ('occ') je Match; 'seq="body"' für references.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
@ -85,7 +91,7 @@ def derive_wikilink_edges(note_payload: dict, chunks_payloads: List[dict], note_
|
||||||
e.update(extra)
|
e.update(extra)
|
||||||
return e
|
return e
|
||||||
|
|
||||||
# Links im Volltext (gesamter Body)
|
# Volltext (Note-Ebene)
|
||||||
fulltext = note_payload.get("fulltext") or note_payload.get("body") or ""
|
fulltext = note_payload.get("fulltext") or note_payload.get("body") or ""
|
||||||
if fulltext:
|
if fulltext:
|
||||||
for k, m in enumerate(WIKILINK_RE.finditer(fulltext), start=1):
|
for k, m in enumerate(WIKILINK_RE.finditer(fulltext), start=1):
|
||||||
|
|
@ -100,7 +106,7 @@ def derive_wikilink_edges(note_payload: dict, chunks_payloads: List[dict], note_
|
||||||
extra["target_label"] = raw_target
|
extra["target_label"] = raw_target
|
||||||
edges.append(_make_edge("references", source_note_id, raw_target, seq="body", occ=k, extra=extra))
|
edges.append(_make_edge("references", source_note_id, raw_target, seq="body", occ=k, extra=extra))
|
||||||
|
|
||||||
# Links in Chunks (wenn übergeben)
|
# Chunks (Chunk-Ebene)
|
||||||
for i, ch in enumerate(chunks_payloads, start=1):
|
for i, ch in enumerate(chunks_payloads, start=1):
|
||||||
txt = ch.get("text") or ch.get("content") or ""
|
txt = ch.get("text") or ch.get("content") or ""
|
||||||
if not txt:
|
if not txt:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user