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

import datetime as dt
import typing

from ..core.datetime_utils import serialize_datetime
from .metadata_mode import MetadataMode
from .summary_extractor_llm import SummaryExtractorLlm

try:
    import pydantic.v1 as pydantic  # type: ignore
except ImportError:
    import pydantic  # type: ignore


class SummaryExtractor(pydantic.BaseModel):
    """
    Summary extractor. Node-level extractor with adjacent sharing.
    Extracts `section_summary`, `prev_section_summary`, `next_section_summary`
    metadata fields.

    Args:
    llm (Optional[LLM]): LLM
    summaries (List[str]): list of summaries to extract: 'self', 'prev', 'next'
    prompt_template (str): template for summary extraction
    """

    is_text_node_only: typing.Optional[bool]
    show_progress: typing.Optional[bool] = pydantic.Field(description="Whether to show progress.")
    metadata_mode: typing.Optional[MetadataMode] = pydantic.Field(
        description="Metadata mode to use when reading nodes."
    )
    node_text_template: typing.Optional[str] = pydantic.Field(
        description="Template to represent how node text is mixed with metadata text."
    )
    disable_template_rewrite: typing.Optional[bool] = pydantic.Field(description="Disable the node template rewrite.")
    in_place: typing.Optional[bool] = pydantic.Field(description="Whether to process nodes in place.")
    num_workers: typing.Optional[int] = pydantic.Field(
        description="Number of workers to use for concurrent async processing."
    )
    llm: SummaryExtractorLlm = pydantic.Field(description="The LLM to use for generation.")
    summaries: typing.List[str] = pydantic.Field(description="List of summaries to extract: 'self', 'prev', 'next'")
    prompt_template: typing.Optional[str] = pydantic.Field(description="Template to use when generating summaries.")
    class_name: typing.Optional[str]

    def json(self, **kwargs: typing.Any) -> str:
        kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
        return super().json(**kwargs_with_defaults)

    def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
        kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
        return super().dict(**kwargs_with_defaults)

    class Config:
        frozen = True
        smart_union = True
        json_encoders = {dt.datetime: serialize_datetime}
