Coverage for src/qdrant_loader/config/chunking.py: 90%
10 statements
« prev ^ index » next coverage.py v7.8.2, created at 2025-06-04 05:50 +0000
« prev ^ index » next coverage.py v7.8.2, created at 2025-06-04 05:50 +0000
1"""Configuration for text chunking."""
3from pydantic import BaseModel, Field, ValidationInfo, field_validator
6class ChunkingConfig(BaseModel):
7 """Configuration for text chunking."""
9 chunk_size: int = Field(
10 default=1000,
11 description="Size of text chunks in characters",
12 gt=0,
13 title="Chunk Size",
14 )
15 chunk_overlap: int = Field(
16 default=200,
17 description="Overlap between chunks in characters",
18 ge=0,
19 title="Chunk Overlap",
20 )
22 @field_validator("chunk_overlap")
23 def validate_chunk_overlap(cls, v: int, info: ValidationInfo) -> int:
24 """Validate that chunk overlap is less than chunk size."""
25 chunk_size = info.data.get("chunk_size", 1000)
26 if v >= chunk_size:
27 raise ValueError("Chunk overlap must be less than chunk size")
28 return v