o
    /if                     @   s   d dl Z d dlZd dlmZmZ d dlmZ d dlmZm	Z	 d dl
mZ d dlmZ d dlmZmZ d dlmZmZ G d	d
 d
eZG dd deZdd Zdd ZdS )    N)EvaluationDatasetGolden)HallucinationMetric)assert_testevaluate)
BaseMetric)LLMTestCase)aggregate_metric_pass_rates
TestResult)AnswerRelevancyMetric
BiasMetricc                   @   P   e Zd ZddedefddZdefdd	Zdefd
dZdd Z	e
dd Z dS )FakeMetric1      ?T	threshold_successc                 C      || _ || _d S Nr   successselfr   r    r   K/var/www/html/corbot_env/lib/python3.10/site-packages/tests/test_dataset.py__init__      
zFakeMetric1.__init__	test_casec                 C   s   d| _ | jS )NThis metric looking good!)reasonscorer   r   r   r   r   measure   s   zFakeMetric1.measurec                       d| _ d| _| j S Nr   zThis async metric looking good!r   r   r    r   r   r   	a_measure      zFakeMetric1.a_measurec                 C      | j S r   r   r   r   r   r   is_successful      zFakeMetric1.is_successfulc                 C      dS NFaker   r)   r   r   r   __name__      zFakeMetric1.__name__Nr   Tr/   
__module____qualname__floatboolr   r   r!   r%   r*   propertyr   r   r   r   r      s    r   c                   @   r   )FakeMetric2r   Tr   r   c                 C   r   r   r   r   r   r   r   r   $   r   zFakeMetric2.__init__r   c                 C   s   d| _ d| _| j S )Nr   r   r$   r    r   r   r   r!   (   s   zFakeMetric2.measurec                    r"   r#   r$   r    r   r   r   r%   -   r&   zFakeMetric2.a_measurec                 C   r'   r   r(   r)   r   r   r   r*   2   r+   zFakeMetric2.is_successfulc                 C   r,   r-   r   r)   r   r   r   r/   5   r0   zFakeMetric2.__name__Nr1   r2   r   r   r   r   r8   #   s    r8   c                  C   s   t  } tjtjt}tj|dd}| j|dddddd t| j	d	ks+J d
tj|dd}| j
|dddddd t| j	dksIJ dd S )Ndatazdataset.csvqueryactual_outputexpected_outputcontext	retrieval)input_col_nameactual_output_col_nameexpected_output_col_namecontext_col_nameretrieval_context_col_name   zTest Cases not loaded from CSVzdataset.json)input_key_nameexpected_output_key_namecontext_key_nameretrieval_context_key_nameactual_output_key_name
   zTest Cases not loaded from JSON)r   ospathdirnamerealpath__file__joinadd_test_cases_from_csv_filelen
test_casesadd_test_cases_from_json_file)datasetmodule_b_dir	file_pathr   r   r   test_create_dataset:   s,   rX   c               
   C   s   t dddd} tdd}t }|j| d |j| d t }t }|j| d |j| d td||gddd	d
gdgdtd||gddddgdgdg}ddd}t|}||ksZJ d S )Nz?What is the primary difference between a comet and an asteroid?av  Comets and asteroids are both celestial bodies found in our solar system but differ in composition and behavior. Comets, made up of ice, dust, and small rocky particles, develop glowing comas and tails when near the Sun. In contrast, asteroids are primarily rocky or metallic and are mostly found in the asteroid belt between Mars and Jupiter. Rabbits are found in the wild.)inputr;   r<   F)r   )r   z
some inputzsome outputzexpected outputr=   zretrieval context)r   metricsrY   r;   r<   r=   retrieval_contextTzanother inputzanother outputzanother expected outputzanother contextzanother retrieval contextr   g      ?)r   r8   )r   r   r8   r!   r
   r	   )r   fake_metric_1_failfake_metric_2_failfake_metric_1_passfake_metric_2_passtest_resultsexpected_resultresultr   r   r    test_aggregate_metric_pass_ratesU   sN   

rc   )rK   pytestdeepeval.datasetr   r   deepeval.metricsr   deepevalr   r   deepeval.metrics.base_metricr   deepeval.test_caser   deepeval.evaluater	   r
   r   r   r   r8   rX   rc   r   r   r   r   <module>   s    