o
    -i6	                     @   s8   d dl mZ d dlmZ d dlmZ G dd deZdS )    )Sequence)DeltaMessage)BaseThinkingReasoningParserc                       sr   e Zd ZdZedefddZedefddZdeded	ed
ee	 dee	 dee	 de
dB f fddZ  ZS )DeepSeekR1ReasoningParserz
    Reasoning parser for DeepSeek R1 model.

    The DeepSeek R1 model uses <think>...</think> tokens to denote reasoning
    text. This parser extracts the reasoning content from the model output.
    returnc                 C      dS )z(The token that starts reasoning content.z<think> selfr   r   h/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/vllm/reasoning/deepseek_r1_reasoning_parser.pystart_token      z%DeepSeekR1ReasoningParser.start_tokenc                 C   r   )z&The token that ends reasoning content.z</think>r   r	   r   r   r   	end_token   r   z#DeepSeekR1ReasoningParser.end_tokenprevious_textcurrent_text
delta_textprevious_token_idscurrent_token_idsdelta_token_idsNc                    s   t  ||||||}|d urP| j|vrP| j|vrP| j|v rA|| j}|d | }	||t| j d  }
t|	|
r=|
dS d dS | j|v rKt|dS t|dS |S )N)	reasoningcontent)r   )r   )superextract_reasoning_streamingstart_token_idend_token_idfindr   lenr   )r
   r   r   r   r   r   r   ret	end_indexr   r   	__class__r   r   r      s2   		





z5DeepSeekR1ReasoningParser.extract_reasoning_streaming)__name__
__module____qualname____doc__propertystrr   r   r   intr   r   __classcell__r   r   r   r   r   
   s*    r   N)collections.abcr   'vllm.entrypoints.openai.engine.protocolr   vllm.reasoning.basic_parsersr   r   r   r   r   r   <module>   s   