# This file was auto-generated by Fern from our API Definition.

from ..core.pydantic_utilities import UniversalBaseModel
import typing
import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2


class CodeSplitter(UniversalBaseModel):
    """
    Split code using a AST parser.

    Thank you to Kevin Lu / SweepAI for suggesting this elegant code splitting solution.
    https://docs.sweep.dev/blogs/chunking-2m-files
    """

    include_metadata: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Whether or not to consider metadata when splitting.
    """

    include_prev_next_rel: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Include prev/next node relationships.
    """

    callback_manager: typing.Optional[typing.Optional[typing.Any]] = None
    id_func: typing.Optional[str] = pydantic.Field(default=None)
    """
    Function to generate node IDs.
    """

    language: str = pydantic.Field()
    """
    The programming language of the code being split.
    """

    chunk_lines: typing.Optional[int] = pydantic.Field(default=None)
    """
    The number of lines to include in each chunk.
    """

    chunk_lines_overlap: typing.Optional[int] = pydantic.Field(default=None)
    """
    How many lines of code each chunk overlaps with.
    """

    max_chars: typing.Optional[int] = pydantic.Field(default=None)
    """
    Maximum number of characters per chunk.
    """

    class_name: typing.Optional[str] = None

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
