o
    PL
j                     @  st   d Z ddlmZ ddlmZ ddlmZ ddlmZ dd
dZ	G dd deZ
e
d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                 C  s@   | 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   m r   M/home/kuhnn/.hermes/hermes-agent/plugins/model-providers/deepseek/__init__.py_model_supports_thinking   s   r   c                   @  s"   e Zd ZdZd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                K  s   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rP|dp7d  }|d	v rHd
|d< ||fS |dv rP||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   r   r   r   build_api_kwargs_extras2   s$   
z'DeepSeekProfile.build_api_kwargs_extras)r   r   r   r   r   r   )__name__
__module____qualname____doc__r)   r   r   r   r   r   /   s    r   deepseek)deepseek-chat)DEEPSEEK_API_KEYDeepSeeku    DeepSeek — native DeepSeek APIzhttps://platform.deepseek.com/)r/   r   zhttps://api.deepseek.com/v1r/   )	namealiasesenv_varsdisplay_namedescription
signup_urlfallback_modelsbase_urldefault_aux_modelN)r   r   r   r	   )r-   
__future__r   typingr   	providersr   providers.baser   r   r   r.   r   r   r   r   <module>   s&    
&