app/core/chunk_payload.py aktualisiert
Some checks failed
Deploy mindnet to llm-node / deploy (push) Failing after 2s
Some checks failed
Deploy mindnet to llm-node / deploy (push) Failing after 2s
This commit is contained in:
parent
0617163c42
commit
c34df96839
|
|
@ -2,7 +2,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
"""
|
"""
|
||||||
Modul: app/core/chunk_payload.py
|
Modul: app/core/chunk_payload.py
|
||||||
Version: 1.1.0
|
Version: 1.1.1
|
||||||
Datum: 2025-09-09
|
Datum: 2025-09-09
|
||||||
|
|
||||||
Kurzbeschreibung
|
Kurzbeschreibung
|
||||||
|
|
@ -29,11 +29,6 @@ Abhängigkeiten
|
||||||
Beispiele (CLI – Sichtprüfung)
|
Beispiele (CLI – Sichtprüfung)
|
||||||
------------------------------
|
------------------------------
|
||||||
python3 -m app.core.chunk_payload --from-file ./vault/demo.md --print
|
python3 -m app.core.chunk_payload --from-file ./vault/demo.md --print
|
||||||
|
|
||||||
Hinweis
|
|
||||||
-------
|
|
||||||
Die CLI ist ein Hilfsmittel zur Sichtprüfung. Im Produktpfad ruft der
|
|
||||||
Importer ``make_chunk_payloads(...)`` direkt auf.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
@ -44,11 +39,11 @@ import os
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Projektinterne Imports
|
# Projektinterne Imports
|
||||||
from app.core.chunker import Chunk
|
from app.core.chunker import Chunk, chunk_markdown
|
||||||
from app.core.parser import extract_wikilinks, parse_markdown
|
from app.core.parser import extract_wikilinks, read_markdown
|
||||||
except Exception: # pragma: no cover - Fallback für relative Ausführung
|
except Exception: # pragma: no cover - Fallback für relative Ausführung
|
||||||
from .chunker import Chunk # type: ignore
|
from .chunker import Chunk, chunk_markdown # type: ignore
|
||||||
from .parser import extract_wikilinks, parse_markdown # type: ignore
|
from .parser import extract_wikilinks, read_markdown # type: ignore
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
@ -98,7 +93,7 @@ def make_chunk_payloads(note_meta: Dict[str, Any], path: str, chunks: List[Chunk
|
||||||
"section_path": getattr(ch, "section_path", None),
|
"section_path": getattr(ch, "section_path", None),
|
||||||
"lang": note_meta.get("lang"),
|
"lang": note_meta.get("lang"),
|
||||||
"wikilinks": wikilinks,
|
"wikilinks": wikilinks,
|
||||||
"external_links": [], # kann später ergänzt werden
|
"external_links": [],
|
||||||
"references": [{"target_id": w, "kind": "wikilink"} for w in wikilinks],
|
"references": [{"target_id": w, "kind": "wikilink"} for w in wikilinks],
|
||||||
"neighbors": {
|
"neighbors": {
|
||||||
"prev": getattr(ch, "neighbors_prev", None),
|
"prev": getattr(ch, "neighbors_prev", None),
|
||||||
|
|
@ -121,7 +116,7 @@ def _cli() -> None:
|
||||||
ap.add_argument("--print", dest="do_print", action="store_true", help="Payload auf stdout ausgeben")
|
ap.add_argument("--print", dest="do_print", action="store_true", help="Payload auf stdout ausgeben")
|
||||||
args = ap.parse_args()
|
args = ap.parse_args()
|
||||||
|
|
||||||
note = parse_markdown(args.src)
|
note = read_markdown(args.src)
|
||||||
note_meta = {
|
note_meta = {
|
||||||
"id": note.frontmatter.get("id") or note.frontmatter.get("note_id"),
|
"id": note.frontmatter.get("id") or note.frontmatter.get("note_id"),
|
||||||
"title": note.frontmatter.get("title"),
|
"title": note.frontmatter.get("title"),
|
||||||
|
|
@ -132,8 +127,6 @@ def _cli() -> None:
|
||||||
"lang": note.frontmatter.get("lang"),
|
"lang": note.frontmatter.get("lang"),
|
||||||
}
|
}
|
||||||
|
|
||||||
# Chunking (benötigt app.core.chunker)
|
|
||||||
from app.core.chunker import chunk_markdown # lazy import
|
|
||||||
chunks = chunk_markdown(note.body or "")
|
chunks = chunk_markdown(note.body or "")
|
||||||
|
|
||||||
# Vault-Root heuristisch relativieren (nur für Demo)
|
# Vault-Root heuristisch relativieren (nur für Demo)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user