
    .`i6	                     F    d dl mZ d dlmZ d dlmZ  G d de          ZdS )    )Sequence)DeltaMessage)BaseThinkingReasoningParserc                        e Zd ZdZedefd            Zedefd            Zdedededee	         d	ee	         d
ee	         de
dz  f fdZ x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                     dS )z(The token that starts reasoning content.z<think> selfs    /home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/vllm/reasoning/deepseek_r1_reasoning_parser.pystart_tokenz%DeepSeekR1ReasoningParser.start_token   s	     y    c                     dS )z&The token that ends reasoning content.z</think>r
   r   s    r   	end_tokenz#DeepSeekR1ReasoningParser.end_token   s	     zr   previous_textcurrent_text
delta_textprevious_token_idscurrent_token_idsdelta_token_idsNc                    t                                          ||||||          }|| j        |vr| j        |vr| j        |v rX|                    | j                  }|d |         }	||t          | j                  z   d          }
t          |	|
r|
nd           S | j        |v rt          |          S t          |          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__s              r   r   z5DeepSeekR1ReasoningParser.extract_reasoning_streaming   s    gg11
 
 O#+===#?:: O33 'OODN;;	&z	z2	$YT^1D1D%D%F%FG#''.8GGD    "&888#J7777 $j9999
r   )__name__
__module____qualname____doc__propertystrr   r   r   intr   r   __classcell__)r#   s   @r   r   r   
   s          S    X 3    X'' ' 	'
 %SM' $C=' "#' 
	' ' ' ' ' ' ' ' ' 'r   r   N)collections.abcr   'vllm.entrypoints.openai.engine.protocolr   vllm.reasoning.basic_parsersr   r   r
   r   r   <module>r/      sr    % $ $ $ $ $ @ @ @ @ @ @ D D D D D D9 9 9 9 9 ; 9 9 9 9 9r   