o
    -i
                     @   s8   d dl mZ d dlmZ d dlmZ G dd deZdS )    )ChatCompletionRequest)ResponsesRequest)BaseThinkingReasoningParserc                	   @   s^   e Zd ZdZedefddZedefddZdedee	B de
ed	B ed	B f fd
dZd	S )Qwen3ReasoningParserau  
    Reasoning parser for the Qwen3 model.

    The Qwen3 model uses <think>...</think> tokens to denote reasoning text
    within its output. The model provides a strict switch to disable reasoning
    output via the 'enable_thinking=False' parameter. This parser extracts the
    reasoning content enclosed by <think> and </think> tokens from the model's
    output.
    returnc                 C      dS )z(The token that starts reasoning content.z<think> selfr   r   b/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/vllm/reasoning/qwen3_reasoning_parser.pystart_token      z Qwen3ReasoningParser.start_tokenc                 C   r   )z&The token that ends reasoning content.z</think>r   r	   r   r   r   	end_token   r   zQwen3ReasoningParser.end_tokenmodel_outputrequestNc                 C   st   | j |vs
| j|vrd|fS || j }|d r|d n|d }| j|vr)d|fS || j\}}}|p5d}||fS )a  
        Extract reasoning content from the model output.

        Qwen3 has stricter requirements - it needs both start and end tokens
        to be present, unlike other models that work with just the end token.

        For text <think>abc</think>xyz:
        - 'abc' goes to reasoning
        - 'xyz' goes to content

        Returns:
            tuple[Optional[str], Optional[str]]: reasoning content and content
        N      r   )r   r   	partition)r
   r   r   model_output_parts	reasoning_contentfinal_contentr   r   r   extract_reasoning"   s   
z&Qwen3ReasoningParser.extract_reasoning)__name__
__module____qualname____doc__propertystrr   r   r   r   tupler   r   r   r   r   r      s    
r   N)0vllm.entrypoints.openai.chat_completion.protocolr   *vllm.entrypoints.openai.responses.protocolr   vllm.reasoning.basic_parsersr   r   r   r   r   r   <module>   s   