mirror of
https://github.com/TencentCloud/Octop.git
synced 2026-10-20 06:19:17 +08:00
Introduce document indexing, embedding (ONNX/remote), and chat/IM injection with default-open selection in the dashboard composer. Co-authored-by: Cursor <cursoragent@cursor.com>
20 lines
540 B
Python
20 lines
540 B
Python
"""Unit tests for document chunking."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
from octop.infra.knowledge.chunk import chunk_text
|
|
|
|
|
|
def test_chunk_text_preserves_content_with_configured_overlap() -> None:
|
|
chunks = chunk_text("abcdefghij", size=4, overlap=1)
|
|
|
|
assert chunks == ["abcd", "defg", "ghij"]
|
|
|
|
|
|
def test_chunk_text_strips_empty_content_and_rejects_invalid_window() -> None:
|
|
assert chunk_text(" \n\t ") == []
|
|
with pytest.raises(ValueError, match="overlap"):
|
|
chunk_text("text", size=4, overlap=4)
|