o
    i,                     @  s   d Z ddlmZ ddlmZmZ ddlmZmZ ddl	m
Z
 ddlmZ ddlmZ d	Ze
d
eddZ	 e
deddZ	 e
deddZ	 eddG dd deeeef ZdS )zThis module defines the EvaluatorContext.

The EvaluatorContext is the context object that is passed to evaluators, containing all the information
needed to evaluate a task execution, including inputs, outputs, metadata, telemetry data, and more.
    )annotations)	dataclassfield)AnyGeneric)TypeVar   )SpanTreeRecordingError)SpanTree)EvaluatorContextInputsTT)default	covariantOutputT	MetadataT)kw_onlyc                   @  s   e Zd ZU dZded< 	 ded< 	 ded< 	 ded	< 	 d
ed< 	 ded< 	 eddZded< 	 ded< 	 ded< 	 edddZdS )r   a#  Context for evaluating a task execution.

    An instance of this class is the sole input to all Evaluators. It contains all the information
    needed to evaluate the task execution, including inputs, outputs, metadata, and telemetry data.

    Evaluators use this context to access the task inputs, actual output, expected output, and other
    information when evaluating the result of the task execution.

    Example:
    ```python
    from dataclasses import dataclass

    from pydantic_evals.evaluators import Evaluator, EvaluatorContext


    @dataclass
    class ExactMatch(Evaluator):
        def evaluate(self, ctx: EvaluatorContext) -> bool:
            # Use the context to access task inputs, outputs, and expected outputs
            return ctx.output == ctx.expected_output
    ```
    z
str | Nonenamer   inputszMetadataT | NonemetadatazOutputT | Noneexpected_outputr   outputfloatdurationF)reprz!SpanTree | SpanTreeRecordingError
_span_treezdict[str, Any]
attributeszdict[str, int | float]metricsreturnr
   c                 C  s   t | jtr	| j| jS )a  Get the `SpanTree` for this task execution.

        The span tree is a graph where each node corresponds to an OpenTelemetry span recorded during the task
        execution, including timing information and any custom spans created during execution.

        Returns:
            The span tree for the task execution.

        Raises:
            SpanTreeRecordingError: If spans were not captured during execution of the task, e.g. due to not having
                the necessary dependencies installed.
        )
isinstancer   r	   )self r    g/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/pydantic_evals/evaluators/context.py	span_treeU   s   zEvaluatorContext.span_treeN)r   r
   )	__name__
__module____qualname____doc____annotations__r   r   propertyr"   r    r    r    r!   r      s,   
 r   N)r&   
__future__r   dataclassesr   r   typingr   r   typing_extensionsr   otel._errorsr	   otel.span_treer
   __all__r   r   r   r   r    r    r    r!   <module>   s      