File size: 703 Bytes
0b53de4
 
 
 
 
 
 
 
d8c1ecb
0b53de4
 
 
 
 
 
 
d8c1ecb
0b53de4
 
 
 
 
 
 
 
d8c1ecb
 
 
 
 
 
0b53de4
d8c1ecb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from abc import ABC, abstractmethod
from typing import List, Dict, Any


class BaseChunker(ABC):
    """
    Base interface for all chunking strategies.

    Every chunker returns a list of chunk objects.
    """

    @abstractmethod
    def chunk(
        self,
        text: str,
        **kwargs: Any,
    ) -> List[Dict[str, Any]]:
        """
        Split text into chunks.

        Args:
            text: Input text to split.
            **kwargs: Optional strategy-specific configuration.

        Returns:
            List[Dict[str, Any]] where each item has the form:

            {
                "text": "<chunk text>",
                "metadata": {}
            }
        """
        pass