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

from __future__ import annotations

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs
from ..core.unchecked_base_model import UncheckedBaseModel
from .conversation_history_transcript_common_model_output import ConversationHistoryTranscriptCommonModelOutput
from .conversation_initiation_source import ConversationInitiationSource
from .llm import Llm
from .simulation_tool_mock_behavior_config import SimulationToolMockBehaviorConfig
from .test_from_conversation_metadata_output import TestFromConversationMetadataOutput
from .tool_response_mock_config_output import ToolResponseMockConfigOutput


class SimulationTestModel(UncheckedBaseModel):
    from_conversation_metadata: typing.Optional[TestFromConversationMetadataOutput] = pydantic.Field(default=None)
    """
    Metadata of a conversation this test was created from (if applicable).
    """

    dynamic_variables: typing.Optional[typing.Dict[str, typing.Any]] = pydantic.Field(default=None)
    """
    Dynamic variables to replace in the agent config during testing
    """

    chat_history: typing.Optional[typing.List[ConversationHistoryTranscriptCommonModelOutput]] = None
    conversation_initiation_source: typing.Optional[ConversationInitiationSource] = pydantic.Field(default=None)
    """
    Simulate the test as if the conversation originated from this channel.
    """

    success_condition: typing.Optional[str] = pydantic.Field(default=None)
    """
    Deprecated legacy single success criterion. Use success_conditions instead. At least one of success_condition or success_conditions is required.
    """

    success_conditions: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
    """
    List of prompts that evaluate whether the simulation was successful. If provided, all criteria are evaluated and merged into a final result. Capped at the maximum number of evaluation criteria.
    """

    simulation_scenario: typing.Optional[str] = pydantic.Field(default=None)
    """
    Description of the simulation scenario and user persona for simulation tests.
    """

    simulation_max_turns: typing.Optional[int] = pydantic.Field(default=None)
    """
    Maximum number of conversation turns for simulation tests.
    """

    simulation_environment: typing.Optional[str] = pydantic.Field(default=None)
    """
    The environment to use when running this simulation test. If not provided, defaults to 'production'.
    """

    tool_mock_config: typing.Optional[SimulationToolMockBehaviorConfig] = pydantic.Field(default=None)
    """
    Configuration for which tools to mock and fallback behavior.
    """

    tool_mock_overrides: typing.Optional[typing.Dict[str, typing.List[ToolResponseMockConfigOutput]]] = pydantic.Field(
        default=None
    )
    """
    Test-specific response mocks, keyed by tool ID. Applied ahead of the tool's shared mocks and only within this test. Only take effect for tools that are mocked (see tool_mock_config).
    """

    evaluation_model: typing.Optional[Llm] = pydantic.Field(default=None)
    """
    LLM model to use for evaluating simulation results. Defaults to Claude Sonnet 4.6.
    """

    simulated_user_model: typing.Optional[Llm] = pydantic.Field(default=None)
    """
    LLM model for the simulated user. Defaults to Claude Sonnet 4.6.
    """

    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


update_forward_refs(SimulationTestModel)
