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

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2
from ..core.unchecked_base_model import UncheckedBaseModel
from .analysis_property_constant_value import AnalysisPropertyConstantValue
from .analysis_property_type import AnalysisPropertyType
from .llm import Llm


class AnalysisProperty(UncheckedBaseModel):
    """
    Data collection property with optional per-item LLM override for post-call analysis.

    TODO: migrate to composition (value_schema: LiteralJsonSchemaProperty + llm) instead of
    inheritance, so this generalizes cleanly to object/array schemas in the future.
    """

    type: AnalysisPropertyType
    description: typing.Optional[str] = pydantic.Field(default=None)
    """
    The description of the property. When set, the LLM will provide the value based on this description. Mutually exclusive with dynamic_variable, is_system_provided, constant_value, and is_omitted.
    """

    enum: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
    """
    List of allowed string values for string type parameters
    """

    is_system_provided: typing.Optional[bool] = pydantic.Field(default=None)
    """
    If true, the value will be populated by the system at runtime. Used by API Integration Webhook tools for templating. Mutually exclusive with description, dynamic_variable, constant_value, and is_omitted.
    """

    dynamic_variable: typing.Optional[str] = pydantic.Field(default=None)
    """
    The name of the dynamic variable to use for this property's value. Mutually exclusive with description, is_system_provided, constant_value, and is_omitted.
    """

    allowed_values_dynamic_variable: typing.Optional[str] = pydantic.Field(default=None)
    """
    When set, the LLM provides the value but the runtime rejects any value not present in the list held by this dynamic variable. Use to let the LLM pick from a server-verified set (e.g. the IDs the current user is allowed to access). Requires description; mutually exclusive with dynamic_variable, is_system_provided, constant_value, and is_omitted.
    """

    constant_value: typing.Optional[AnalysisPropertyConstantValue] = pydantic.Field(default=None)
    """
    A constant value to use for this property. Mutually exclusive with description, dynamic_variable, is_system_provided, and is_omitted.
    """

    is_omitted: typing.Optional[bool] = pydantic.Field(default=None)
    """
    If true, this parameter will be completely omitted from the request. Only valid for optional parameters. Mutually exclusive with description, dynamic_variable, is_system_provided, and constant_value.
    """

    llm: typing.Optional[Llm] = pydantic.Field(default=None)
    """
    LLM model to use for this analysis item. If not set, uses agent's analysis_llm default.
    """

    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
