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

import datetime as dt
import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .comment import Comment
from .dataset_version_summary import DatasetVersionSummary
from .experiment_evaluation_method import ExperimentEvaluationMethod
from .experiment_score import ExperimentScore
from .experiment_status import ExperimentStatus
from .experiment_type import ExperimentType
from .feedback_score_average import FeedbackScoreAverage
from .json_list_string import JsonListString
from .percentage_values import PercentageValues
from .prompt_version_link import PromptVersionLink


class Experiment(UniversalBaseModel):
    id: typing.Optional[str] = None
    dataset_name: typing.Optional[str] = None
    dataset_id: typing.Optional[str] = None
    project_id: typing.Optional[str] = None
    project_name: typing.Optional[str] = None
    name: typing.Optional[str] = None
    metadata: typing.Optional[JsonListString] = None
    tags: typing.Optional[typing.List[str]] = None
    type: typing.Optional[ExperimentType] = None
    evaluation_method: typing.Optional[ExperimentEvaluationMethod] = None
    optimization_id: typing.Optional[str] = None
    feedback_scores: typing.Optional[typing.List[FeedbackScoreAverage]] = None
    comments: typing.Optional[typing.List[Comment]] = None
    trace_count: typing.Optional[int] = None
    dataset_item_count: typing.Optional[int] = None
    created_at: typing.Optional[dt.datetime] = None
    duration: typing.Optional[PercentageValues] = None
    total_estimated_cost: typing.Optional[float] = None
    total_estimated_cost_avg: typing.Optional[float] = None
    usage: typing.Optional[typing.Dict[str, float]] = None
    last_updated_at: typing.Optional[dt.datetime] = None
    created_by: typing.Optional[str] = None
    last_updated_by: typing.Optional[str] = None
    status: typing.Optional[ExperimentStatus] = None
    experiment_scores: typing.Optional[typing.List[ExperimentScore]] = None
    prompt_version: typing.Optional[PromptVersionLink] = None
    prompt_versions: typing.Optional[typing.List[PromptVersionLink]] = None
    dataset_version_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    ID of the dataset version this experiment is linked to. If not provided at creation, experiment will be automatically linked to the latest version.
    """

    dataset_version_summary: typing.Optional[DatasetVersionSummary] = None
    pass_rate: typing.Optional[float] = pydantic.Field(default=None)
    """
    Pass rate for evaluation suite experiments (0.0-1.0). Null for regular experiments.
    """

    passed_count: typing.Optional[int] = pydantic.Field(default=None)
    """
    Number of items that passed for evaluation suite experiments. Null for regular experiments.
    """

    total_count: typing.Optional[int] = pydantic.Field(default=None)
    """
    Total number of items for evaluation suite experiments. Null for regular experiments.
    """

    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
