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

import typing

import pydantic
from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .extract_request_config_chunking_method import ExtractRequestConfigChunkingMethod
from .extract_request_config_validation_method import ExtractRequestConfigValidationMethod


class ExtractRequestConfig(UniversalBaseModel):
    chunking_method: typing.Optional[ExtractRequestConfigChunkingMethod] = pydantic.Field(default=None)
    """
    Method for splitting input text into chunks before code extraction
    """

    max_codes_per_chunk: typing.Optional[int] = pydantic.Field(default=None)
    """
    Maximum number of codes to extract per chunk. If not specified, uses system-specific defaults:
    * SNOMED: 10
    * LOINC, HPO, RXNORM: 20
    * All other systems: 5
    """

    code_similarity_filter: typing.Optional[float] = pydantic.Field(default=None)
    """
    Threshold for filtering similar codes (0.0-1.0)
    """

    validation_method: typing.Optional[ExtractRequestConfigValidationMethod] = pydantic.Field(default=None)
    """
    Method for validating extracted codes:
    * none - No validation, returns all candidate codes
    * simple - LLM-based validation
    * medication_search - LLM-based validation tailored for medication concepts
    """

    include_rationale: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Whether to include explanations for why each code was extracted
    """

    include_ancestors: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Whether to include ancestor/parent codes in the results
    """

    include_invalid: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Whether to include codes that failed validation in the results
    """

    include_citations: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Whether to include source text citations for each extracted code.
    Citations show the exact text spans (with character offsets) that led to each code.
    Only available when using chunking_method: "sentences".
    The "none" method returns full text as one chunk (not useful for citations).
    LLM-based chunking (paragraphs, topics) does not support citations.
    """

    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
