
    i                    @    d Z ddlmZ ddlmZmZ h dZdddZddZdS )a  LM Studio reasoning-effort resolution shared by the chat-completions
transport and run_agent's iteration-limit summary path.

LM Studio publishes per-model ``capabilities.reasoning.allowed_options`` (e.g.
``["off","on"]`` for toggle-style models, ``["off","minimal","low"]`` for
graduated models). We map the user's ``reasoning_config`` onto LM Studio's
OpenAI-compatible vocabulary, then clamp against the model's allowed set so
the server doesn't 400 on an unsupported effort.
    )annotations)ListOptional>   lowhighnonexhighmediumminimalr   r
   )offonreasoning_configOptional[dict]allowed_optionsOptional[List[str]]returnOptional[str]c                V   d}| rt          | t                    r{|                     d          du rd}na|                     d          pd                                                                }t
                              ||          }|t          v r|}|rd |D             }||vrdS |S )	a  Return the ``reasoning_effort`` string to send to LM Studio, or ``None``.

    ``None`` means "omit the field": the user picked a level the model can't
    honor, so let LM Studio fall back to the model's declared default rather
    than silently substituting a different effort. When ``allowed_options`` is
    falsy (probe failed), skip clamping and send the resolved effort anyway.
    r
   enabledFr   effort c                D    h | ]}t                               ||          S  )_LM_EFFORT_ALIASESget).0opts     =/home/ubuntu/.hermes/hermes-agent/agent/lmstudio_reasoning.py	<setcomp>z*resolve_lmstudio_effort.<locals>.<setcomp>-   s)    OOO%))#s33OOO    N)
isinstancedictr   striplowerr   _LM_VALID_EFFORTS)r   r   r   rawalloweds        r   resolve_lmstudio_effortr(      s     F J'7>> 	**e33FF#''117R>>@@FFHHC$((c22C''' OOOOO  4Mr    N)r   r   r   r   r   r   )	__doc__
__future__r   typingr   r   r%   r   r(   r   r    r   <module>r,      sx     # " " " " " ! ! ! ! ! ! ! ! JII  $844      r    