- Updated provenance priorities and introduced a mapping from internal provenance values to EdgeDTO-compliant literals. - Added a new function `normalize_provenance` to standardize internal provenance strings. - Enhanced the `_edge` function to include an `is_internal` flag and provenance normalization. - Modified the `EdgeDTO` model to include a new `source_hint` field for detailed provenance information and an `is_internal` flag for intra-note edges. - Reduced the provenance options in `EdgeDTO` to valid literals, improving data integrity.
49 lines
1.8 KiB
Python
49 lines
1.8 KiB
Python
"""
|
|
FILE: app/core/chunking/chunking_models.py
|
|
DESCRIPTION: Datenklassen für das Chunking-System.
|
|
WP-26 v1.0: Erweiterung um section_type für typ-spezifische Sektionen.
|
|
"""
|
|
from dataclasses import dataclass, field
|
|
from typing import List, Dict, Optional, Any
|
|
|
|
@dataclass
|
|
class RawBlock:
|
|
"""
|
|
Repräsentiert einen logischen Block aus dem Markdown-Parsing.
|
|
WP-26 v1.0: Erweitert um section_type für typ-spezifische Sektionen.
|
|
"""
|
|
kind: str
|
|
text: str
|
|
level: Optional[int]
|
|
section_path: str
|
|
section_title: Optional[str]
|
|
exclude_from_chunking: bool = False # WP-24c v4.2.0: Flag für Edge-Zonen, die nicht gechunkt werden sollen
|
|
is_meta_content: bool = False # WP-24c v4.2.6: Flag für Meta-Content (Callouts), der später entfernt wird
|
|
# WP-26 v1.0: Section-Type für typ-spezifische Sektionen
|
|
section_type: Optional[str] = None # z.B. "insight", "decision", "experience"
|
|
# WP-26 v1.0: Block-ID für Intra-Note-Links (z.B. "^sit" aus "## Situation ^sit")
|
|
block_id: Optional[str] = None
|
|
|
|
@dataclass
|
|
class Chunk:
|
|
"""
|
|
Das finale Chunk-Objekt für Embedding und Graph-Speicherung.
|
|
WP-26 v1.0: Erweitert um section_type für effektiven Typ.
|
|
"""
|
|
id: str
|
|
note_id: str
|
|
index: int
|
|
text: str
|
|
window: str
|
|
token_count: int
|
|
section_title: Optional[str]
|
|
section_path: str
|
|
neighbors_prev: Optional[str]
|
|
neighbors_next: Optional[str]
|
|
candidate_pool: List[Dict[str, Any]] = field(default_factory=list)
|
|
suggested_edges: Optional[List[str]] = None
|
|
# WP-26 v1.0: Section-Type für typ-spezifische Sektionen
|
|
# Wenn gesetzt, wird dieser als "effektiver Typ" verwendet statt note_type
|
|
section_type: Optional[str] = None
|
|
# WP-26 v1.0: Block-ID für Intra-Note-Links
|
|
block_id: Optional[str] = None |