
    j;
                     N    d dl mZmZ ddlmZmZ  G d dej                        Zy)    )AnyOptional   )base_metricscore_resultc            
       p     e Zd ZdZ	 	 	 	 ddedededee   f fdZdeded	ed
e	j                  fdZ xZS )Equalsa  
    A metric that checks if an output string exactly matches an expected output string.

    This metric returns a score of 1.0 if the strings match exactly, and 0.0 otherwise.
    The comparison can be made case-sensitive or case-insensitive.

    Args:
        case_sensitive: Whether the comparison should be case-sensitive. Defaults to False.
        name: The name of the metric. Defaults to "equals_metric".
        track: Whether to track the metric. Defaults to True.
        project_name: Optional project name to track the metric in for the cases when there are no parent span/trace to inherit project name from.

    Example:
        >>> from opik.evaluation.metrics import Equals
        >>> equals_metric = Equals(case_sensitive=True)
        >>> result = equals_metric.score("Hello, World!", "Hello, World!")
        >>> print(result.value)
        1.0
        >>> result = equals_metric.score("Hello, World!", "hello, world!")
        >>> print(result.value)
        0.0
    case_sensitivenametrackproject_namec                 8    t         |   |||       || _        y )N)r   r   r   )super__init___case_sensitive)selfr
   r   r   r   	__class__s        /Users/manta/Documents/Projects/TheRoad-I1/backend/.venv/lib/python3.12/site-packages/opik/evaluation/metrics/heuristics/equals.pyr   zEquals.__init__   s*     	% 	 	

  .    output	referenceignored_kwargsreturnc                 4   t        |      }t        |      }| j                  r|n|j                         }| j                  r|n|j                         }||k(  r!t        j                  d| j
                        S t        j                  d| j
                        S )a  
        Calculate the score based on whether the output exactly matches the expected output.

        Args:
            output: The output to check. Will be converted to string for comparison.
            reference: The expected output to compare against. Will be converted to string for comparison.
            **ignored_kwargs: Additional keyword arguments that are ignored.

        Returns:
            score_result.ScoreResult: A ScoreResult object with a value of 1.0 if the values match,
                0.0 otherwise.
        g      ?)valuer   g        )strr   lowerr   ScoreResultr   )r   r   r   r   
output_strreference_str
value_leftvalue_rights           r   scorezEquals.score,   s|      [
I#'#7#7ZZ=M=M=O
'+';';mATATAV$++#DIIFF''c		BBr   )Fequals_metricTN)__name__
__module____qualname____doc__boolr   r   r   r   r   r   r#   __classcell__)r   s   @r   r	   r	      su    2  %#&*.. . 	.
 sm.CC&)C=@C		!	!Cr   r	   N)typingr   r    r   r   
BaseMetricr	    r   r   <module>r/      s      (?C[## ?Cr   