
    PL
j                        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           dS )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)ProviderProfilemodel
str | Nonereturnboolc                    | pd                                                                 }|sdS |                    d          r|                    d          sdS |dk    rdS dS )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)r   ms     M/home/kuhnn/.hermes/hermes-agent/plugins/model-providers/deepseek/__init__.py_model_supports_thinkingr      sv     
"##%%A u||L!! !,,}*E*E  tt5    c                  "    e Zd ZdZddddd
ZdS )DeepSeekProfileu>   DeepSeek — extra_body.thinking + top-level reasoning_effort.N)reasoning_configr   r   dict | Noner   r   r	   %tuple[dict[str, Any], dict[str, Any]]c                  i }i }t          |          s||fS d}t          |t                    r|                    d          du rd}d|rdndi|d<   |s||fS t          |t                    rN|                    d          pd                                                                }|d	v rd
|d<   n	|dv r||d<   ||fS )NTenabledFtypedisabledthinkingeffortr   >   max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((
 &-- 	2B2F2Fy2Q2QUZ2Z2ZG"(w*N))J!O
: 	)y((
 &-- 	7&**844:AACCIIKKF)))05	,--44406	,-9$$r   )r   r   r   r   r	   r   )__name__
__module____qualname____doc__r-    r   r   r   r   /   s?        HH 264 %  %  %  %  %  %  %  %r   r   deepseek)deepseek-chat)DEEPSEEK_API_KEYDeepSeeku    DeepSeek — native DeepSeek APIzhttps://platform.deepseek.com/)r4   r   zhttps://api.deepseek.com/v1r4   )	namealiasesenv_varsdisplay_namedescription
signup_urlfallback_modelsbase_urldefault_aux_modelN)r   r   r	   r
   )r1   
__future__r   typingr   	providersr   providers.baser   r   r   r3   r2   r   r   <module>rD      s    & # " " " " "       ' ' ' ' ' ' * * * * * *   &#% #% #% #% #%o #% #% #%L ?	"2/ +%    (     r   