
    `gj                        d Z ddlmZ ddlmZ ddlmZ ddlmZ ddZ	 G d de      Z
 e
d	d
ddddddd	      Z ee       y)aC  DeepSeek provider profile.

DeepSeek's V4 family (and the legacy ``deepseek-reasoner``) defaults to
thinking-mode ON when ``extra_body.thinking`` is unset.  The API then returns
``reasoning_content`` and starts enforcing the contract that subsequent turns
echo it back; combined with how Hermes replays history this lands on the
notorious HTTP 400 ``reasoning_content must be passed back`` error after the
first tool call (#15700, #17212, #17825).

This profile overrides :meth:`build_api_kwargs_extras` to mirror the Kimi /
Moonshot wire shape that DeepSeek's OpenAI-compat endpoint expects:

    {"reasoning_effort": "<low|medium|high|max>",
     "extra_body": {"thinking": {"type": "enabled" | "disabled"}}}

Non-thinking models (only ``deepseek-chat`` today, which is V3) are left as
no-ops so we don't perturb the V3 wire format.
    )annotations)Any)register_provider)ProviderProfilec                    | xs dj                         j                         }|sy|j                  d      r|j                  d      sy|dk(  ryy)a  DeepSeek thinking-capable model families.

    Currently covers the V4 family (``deepseek-v4-pro``, ``deepseek-v4-flash``,
    and any future ``deepseek-v4-*`` variants) and the legacy
    ``deepseek-reasoner`` (R1).  ``deepseek-chat`` is V3 with no thinking mode.
     Fz
deepseek-vzdeepseek-v3Tdeepseek-reasoner)striplower
startswith)modelms     \/root/.hermes/venv/lib/python3.12/site-packages/plugins/model-providers/deepseek/__init__.py_model_supports_thinkingr      sP     
"##%A||L!!,,}*E     c                  *    e Zd ZdZddd	 	 	 	 	 ddZy)DeepSeekProfileu>   DeepSeek — extra_body.thinking + top-level reasoning_effort.N)reasoning_configr   c               N   i }i }t        |      s||fS d}t        |t              r|j                  d      du rd}d|rdndi|d<   |s||fS t        |t              rG|j                  d      xs dj	                         j                         }|d	v r	d
|d<   ||fS |dv r||d<   ||fS )NTenabledFtypedisabledthinkingeffortr   >   maxultraxhighr   reasoning_effort>   lowhighmedium)r   
isinstancedictgetr
   r   )selfr   r   context
extra_body	top_levelr   r   s           r   build_api_kwargs_extrasz'DeepSeekProfile.build_api_kwargs_extras2   s     &(
$&	'.y((
 &-2B2F2Fy2QUZ2ZG"(w)J!O
:y((
 &-&**84:AACIIKF2205	,- 9$$ 4406	,-9$$r   )r   zdict | Noner   
str | Nonereturnz%tuple[dict[str, Any], dict[str, Any]])__name__
__module____qualname____doc__r)    r   r   r   r   /   s)    H 264 %#. %>H %	. %r   r   deepseek)deepseek-chat)DEEPSEEK_API_KEYDeepSeeku    DeepSeek — native DeepSeek APIzhttps://platform.deepseek.com/)r2   r	   zhttps://api.deepseek.com/v1r2   )	namealiasesenv_varsdisplay_namedescription
signup_urlfallback_modelsbase_urldefault_aux_modelN)r   r*   r+   bool)r/   
__future__r   typingr   	providersr   providers.baser   r   r   r1   r0   r   r   <module>rC      s_   & #  ' *&#%o #%L 	"2/ +% ( r   