File size: 883 Bytes
0b53de4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d8c1ecb
0b53de4
 
 
 
 
 
 
 
 
d8c1ecb
0b53de4
 
 
 
 
 
 
 
 
 
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
34
35
36
37
38
39
from pilotcore.chunking.registry import get_chunker


class ChunkingRuntime:
    """
    Entry point for all chunking operations.

    The runtime selects the configured chunking strategy
    and delegates chunk generation to the corresponding
    chunker implementation.
    """

    @staticmethod
    def chunk(
        text: str,
        strategy: str = "fixed",
        **kwargs,
    ) -> list[dict]:
        """
        Generate chunks using the requested strategy.

        Args:
            text: Text to split.
            strategy: Chunking strategy name.
            **kwargs: Strategy-specific arguments.

        Returns:
            List of chunk dictionaries containing text and metadata.
        """

        chunker_class = get_chunker(strategy)

        chunker = chunker_class()

        return chunker.chunk(
            text=text,
            **kwargs,
        )