o
    }oi                     @   s   d dl mZmZ d dlZd dlZd dlmZ d dlmZ ej	deeeef fddZ
ejdg d	d
d Zdd Zdd ZdS )    )Any	GeneratorN)create_server_process)AdapterConfigreturnc                 c   s.    t dddd}t|\}}|V  |  d S )Nz)http://localhost:3300/v1/chat/completionsTz</think>)api_urluse_reasoningend_reasoning_token)r   r   	terminate)fake_openai_endpointadapter_configp r   \/home/ubuntu/.local/lib/python3.10/site-packages/tests/evaluation/adapters/test_reasoning.pyadapter_server   s   r   zinput_content,expected_content))zuLet me think about this...
<think>This is my reasoning process that should be removed</think>
Here's my final answer.zHere's my final answer.)%No reasoning tokens in this response.r   )za<think>First I'll analyze the problem
Then I'll solve it step by step</think>Here's the solution.zHere's the solution.c           
      C   sv   d| j  }ddd|digi}ddd|d	}tj||d
}|jdks%J | }|d d d d }	|	|ks9J d S )Nhttp://localhost:choicesmessage	assistantrolecontentThis is a test promptd         ?prompt
max_tokenstemperaturefake_responsejson   r   r   
local_portrequestspoststatus_coder"   )
r   r   input_contentexpected_contenturlresponse_datadataresponsecleaned_datacleaned_contentr   r   r   test_reasoning_responses*   s&   r1   c                 C   s   d| j  }dddddiddddigi}dd	d
|d}tj||d}|jdks+J | }|d d d d dks=J |d d d d dksKJ d S )Nr   r   r   r   z"<think>Reasoning 1</think>Answer 1r   z"<think>Reasoning 2</think>Answer 2r   r   r   r   r!   r#   r   r   zAnswer 1   zAnswer 2r$   r   r   r+   r,   r-   r.   r/   r   r   r   test_multiple_choices\   s0    r4   c                 C   sd   d| j  }dddddigi}ddd	|d
}tj||d}| }|d d d d dks0J d S )Nr   r   r   systemz9<think>This should not be processed</think>System messager   r   r   r   r   r!   r   r   )r%   r&   r'   r"   r3   r   r   r   test_non_assistant_role   s"    r6   )typingr   r   pytestr&   /nemo.collections.llm.evaluation.adapters.serverr   #nemo.collections.llm.evaluation.apir   fixturer   markparametrizer1   r4   r6   r   r   r   r   <module>   s   
!%