20 lines
651 B
Python
20 lines
651 B
Python
"""Note ingestion — whole-document chunks."""
|
|
|
|
|
|
def chunk_note(text: str) -> list[dict]:
|
|
"""Return note text as a single chunk."""
|
|
return [{"text": text, "metadata": {}, "chunk_index": 0}]
|
|
|
|
|
|
def auto_title(text: str, max_len: int = 80) -> str:
|
|
"""Generate a title from the first line of text, truncated at word boundary."""
|
|
first_line = text.strip().split("\n")[0].strip()
|
|
if len(first_line) <= max_len:
|
|
return first_line
|
|
truncated = first_line[:max_len]
|
|
# Truncate at last space
|
|
last_space = truncated.rfind(" ")
|
|
if last_space > 0:
|
|
truncated = truncated[:last_space]
|
|
return truncated + "..."
|