Ë
    uPêjŽ(  ã                   ó,  — U d Z ddlmZmZ ddlmZ ddlmZmZ ddl	Z	ddl
mZ  ee«      Zeed<    ei «      Zeeeef      ed<   d	Zeed
<   dZeed<   dZeed<   dZeed<    ed«      Zeed<   deeef   deeef   fd„Zdeeef   deeef   fd„Zdeeef   deedf   dz  fd„Zdededeedf   dz  fd„Zdeeef   dedefd„Zdeeef   dz  deeef   defd „Zdeeef   d!edeedf   dz  fd"„Zd#ee   dz  d$ee   dz  deedf   dz  fd%„Z y)&aÛ  Resolve which reasoning_effort values a deployment, and by intersection a model group, accepts.

An entry that states its levels outright in reasoning_effort_levels is read first and wins
whole, for a model whose set the per-level flags cannot express: Kimi K3 takes low, high and max,
and no flag can drop medium because medium has none. Every other entry answers through the
supports_*_reasoning_effort flags below, whose polarity mirrors how a request path reads that same
flag. medium and high are unconditional for a reasoning model. minimal and low are opt-out:
openai/chat/gpt_5_transformation.py refuses them only when the map says false. xhigh and max are
opt-in. none is opt-out everywhere except the azure gpt-5 family, whose config raises
UnsupportedParamsError without an explicit true.

xhigh is gated on the request path by the openai and azure gpt-5 configs. max is not gated there at
all: every entry carrying supports_max_reasoning_effort is Claude-family, and
anthropic/chat/transformation.py gates max on the output_config path while its reasoning_effort
path maps any level to a thinking budget. Making max opt-in is a deliberate trade, then, since an
explicit flag is the only signal that the tier is a real one rather than litellm rounding the level
to a budget, and a missing flag costs advisory metadata rather than a rejected request.

A deployment the map describes with no effort flags at all resolves to None rather than to the
opt-out defaults. 689 of the map's 854 reasoning entries carry no flag, and the o-series, xai and
bedrock nova entries among them take neither none nor minimal, so composing a set out of the
defaults alone would advertise levels those providers reject.

The advertisement order is the REASONING_EFFORT declaration order, which is presentation only. It
is not a strength scale and does not reconcile with bedrock's output_config ceiling order in
llms/bedrock/common_utils.py, which ranks max below xhigh while the thinking-budget constants rank
it above.
é    )ÚMappingÚSequence)ÚMappingProxyType)ÚFinalÚget_argsN)ÚREASONING_EFFORTÚ$REASONING_EFFORT_ADVERTISEMENT_ORDERÚ_EMPTY_ENTRY))ÚnoneÚsupports_none_reasoning_effort)ÚminimalÚ!supports_minimal_reasoning_effort)ÚlowÚsupports_low_reasoning_effort)ÚxhighÚsupports_xhigh_reasoning_effort)ÚmaxÚsupports_max_reasoning_effortÚ_EFFORT_FLAGSÚreasoning_effort_levelsÚ_DECLARED_EFFORTS_KEY)r   r   Ú_OPT_OUT_EFFORTS)r   r   Ú_OPT_IN_EFFORTS)ÚmediumÚhighÚ_UNCONDITIONAL_EFFORTSÚ
model_infoÚreturnc                 ó0  — | j                  d«      }| j                  d«      }t        |t        «      r$t        |t        «      r|j                  |› d�«      st        S t
        j                  j                  |j                  |› d�«      «      }|�|S t        S )aV  The unprefixed twin of a provider-prefixed map entry, which is where the flags often live:
    azure/gpt-5-mini carries none of them while gpt-5-mini carries all three. The request-path
    gates resolve through the same twin (_supports_factory, #20885), so reading it here is what
    keeps the advertisement and the gate on the same answer.ÚkeyÚlitellm_providerú/)ÚgetÚ
isinstanceÚstrÚ
startswithr
   ÚlitellmÚ
model_costÚremoveprefix)r   r    ÚproviderÚentrys       úu/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/litellm/router_utils/reasoning_effort_capability.pyÚ_bare_model_entryr-   5   sŠ   € ð
 —‘ Ó&€CØ —n‘nÐ%7Ó8€HÜ�cœ3Ô¤z°(¼CÔ'@ÈÏÉÐZbÐYcÐcdÐWeÔHfÜÐÜ07×0BÑ0B×0FÑ0FÀs×GWÑGWÐ[cÐZdÐdeÐXfÓGgÓ0h€EØÐ%ˆ5Ð7¬<Ð7ó    c           
      óÌ   — t        | «      }t        t        D ��ci c]9  \  }}|| j                  |«      �| j                  |«      n|j                  |«      “Œ; c}}«      S c c}}w ©N)r-   r   r   r#   )r   ÚbareÚeffortÚflags       r,   Ú_declared_effort_flagsr4   B   se   € Ü# JÓ/€DÜô !.÷	
á�˜ð ¨J¯N©N¸4Ó,@Ð,L�J—N‘N 4Ô(ÐRV×RZÑRZÐ[_ÓR`Ñ`ó	
óð ùó	
s   š>A 
.c                 ó  ‡— | j                  t        «      }|�|nt        | «      j                  t        «      }t        |t        «      rt        |t
        t        f«      ryt        d„ |D «       «      Št        ˆfd„t        D «       «      S )aà  The entry's own answer, read through the same bare twin as the flags so both spellings of one
    model agree. Present-and-a-list IS the answer, so a declared [] correctly empties the group and
    an unknown level is dropped rather than raised: the bundled map is enum-validated by
    validate-model-prices-json, but an operator can put this key on a config.yaml model_info block
    where that schema never runs, and one mistyped level must not fail every sibling on the proxy.Nc              3   óB   K  — | ]  }t        |t        «      sŒ|–— Œ y ­wr0   )r$   r%   )Ú.0r2   s     r,   ú	<genexpr>z-declared_reasoning_efforts.<locals>.<genexpr>V   s   è ø€ ÒT¨6¼JÀvÌsÕ<S¤ÑTùs   ‚˜c              3   ó,   •K  — | ]  }|‰v sŒ|–— Œ y ­wr0   © )r7   r2   Údeclareds     €r,   r8   z-declared_reasoning_efforts.<locals>.<genexpr>W   s   øè ø€ Òa˜FÈfÐX`ÒN`”Ñaùó   ƒ	�)
r#   r   r-   r$   r   r%   ÚbytesÚ	frozensetÚtupler	   )r   ÚownÚrawr;   s      @r,   Údeclared_reasoning_effortsrB   L   sm   ø€ ð —‘Ô 5Ó6€CØ˜‘Ô->¸zÓ-J×-NÑ-NÔOdÓ-e€CÜ�cœ8Ô$¬
°3¼¼e¸Ô(EØÜÑT°SÔTÓT€HÜÓaÔ&JÔaÓaÐar.   ÚmodelÚcustom_llm_providerc                 óÄ   — t         j                  j                  |› d| › �«      xs t         j                  j                  | «      }t        |t        «      syt        |«      S )aj  The levels an entry declares, resolved from the model string a provider config holds rather
    than from a router deployment's model_info.

    None means the map has no opinion, either because the entry declares nothing or because it
    describes no such model, so a caller keeps whatever it did before the entry was described. The
    entry is read straight off the map rather than through get_model_info, which raises for a model
    it does not know: a provider config runs on the request path for every model it serves, most of
    which the map never named, and a lookup miss there must not fail the call.
    r"   N)r'   r(   r#   r$   ÚdictrB   )rC   rD   r+   s      r,   Ú$declared_reasoning_efforts_for_modelrG   Z   sV   € ô ×%Ñ%×)Ñ)Ð-@Ð,AÀÀ5À'Ð*JÓKÒlÌw×OaÑOa×OeÑOeÐfkÓOl€EÜ�eœTÔ"ØÜ% eÓ,Ð,r.   r3   c                 ó²   — | j                  d«      dk7  r|duS ddlm} | j                  d«      }t        |t        «      r|j                  |«      s|duS |du S )a  Opt-in only where a request path refuses the level. AzureOpenAIGPT5Config raises
    UnsupportedParamsError on reasoning_effort='none' without an explicit true, and it is selected
    only for the gpt-5 family, so every other azure deployment keeps the opt-out default.r!   ÚazureFr   )ÚAzureOpenAIGPT5Configr    T)r#   Ú,litellm.llms.azure.chat.gpt_5_transformationrJ   r$   r%   Úis_model_gpt_5_model)r   r3   rJ   r    s       r,   Ú_supports_none_reasoning_effortrM   j   s`   € ð ‡~�~Ð(Ó)¨WÒ4Ø˜5Ð Ð åRà—‘ Ó&€CÜ�cœ3ÔÐ'<×'QÑ'QÐRUÔ'VØ˜5Ð Ð Ø�4ˆ<Ðr.   Úresolved_model_infoÚoperator_model_infoc                 óP   — | �| j                  d«      €y|j                  d«      du S )a±  Whether the model map described this deployment, as opposed to the operator describing it.

    Every deployment is registered in the cost map under its own id, so a mode the operator wrote
    on an off-map deployment reads back here exactly like one the catalog supplied. Excluding it is
    what stops such a deployment from claiming to be a known non-reasoning model and emptying the
    levels its mapped siblings agree on.
    NÚmodeF)r#   )rN   rO   s     r,   Údeployment_is_catalog_mappedrR   y   s4   € ð Ð"Ð&9×&=Ñ&=¸fÓ&EÐ&MØØ×"Ñ" 6Ó*¨dÐ2Ð2r.   Údeployment_is_mappedc                óö  ‡‡	— | j                  d«      }|du ryt        | «      Š	t        d„ ‰	j                  «       D «       «      }|dur|s|rdS dS t	        | «      }|�|S t        d„ ‰	j                  «       D «       «      ryt        ˆ	fd„t        D «       «      }t        ˆ	fd	„t        D «       «      }t        | ‰	d
   «      rt        d«      n	t        «       }|t        z  |z  |z  Št        ˆfd„t        D «       «      S )aA  None = nothing is known about this deployment, so it must not narrow its group; () = a known
    model that accepts no effort level, which correctly empties the group.

    Telling those apart needs provenance the flattened ModelInfo does not carry. A deployment the
    map does not describe arrives with supports_reasoning None, exactly like a mapped non-reasoning
    model: 2273 of the map's 3165 entries omit the key rather than setting it false, so reading an
    unset flag as () would let one custom deployment empty every level its mapped siblings agree
    on. deployment_is_mapped is that provenance, and an operator who wants either answer for an
    off-map deployment gets it by setting supports_reasoning explicitly.

    If supports_reasoning is unset but at least one per-level flag (e.g.
    supports_minimal_reasoning_effort) is present, treat it as implicitly True, since the
    per-level flags are evidence the model supports reasoning. An explicit False always wins:
    it is the operator's escape hatch and must not be overridden by inherited per-level flags.
    Úsupports_reasoningFr:   c              3   ó$   K  — | ]  }|d u–— Œ
 y ­wr0   r:   ©r7   Úvalues     r,   r8   z6resolve_supported_reasoning_efforts.<locals>.<genexpr>¢   s   è ø€ Ò#R¸% E°Ô$5Ñ#Rùó   ‚TNc              3   ó$   K  — | ]  }|d u –— Œ
 y ­wr0   r:   rW   s     r,   r8   z6resolve_supported_reasoning_efforts.<locals>.<genexpr>ª   s   è ø€ Ò
5˜Uˆ5�DŒ=Ñ
5ùrY   c              3   ó2   •K  — | ]  }‰|   d usŒ|–— Œ y­w)FNr:   ©r7   r2   Úflagss     €r,   r8   z6resolve_supported_reasoning_efforts.<locals>.<genexpr>­   s   øè ø€ Òc¨&ÈÈfÉÐ]bÒHbœvÑcùó   ƒ�c              3   ó2   •K  — | ]  }‰|   d u sŒ|–— Œ y­w)TNr:   r\   s     €r,   r8   z6resolve_supported_reasoning_efforts.<locals>.<genexpr>®   s   øè ø€ Ò\¨ÀeÈFÁmÐW[ÒF[œfÑ\ùr^   r   )r   c              3   ó,   •K  — | ]  }|‰v sŒ|–— Œ y ­wr0   r:   )r7   r2   Úalloweds     €r,   r8   z6resolve_supported_reasoning_efforts.<locals>.<genexpr>³   s   øè ø€ Ò`˜FÈfÐX_ÒN_”Ñ`ùr<   )r#   r4   ÚanyÚvaluesrB   Úallr>   r   r   rM   r   r?   r	   )
r   rS   rU   Úhas_per_level_flagr;   Úopt_outÚopt_inÚ
none_levelra   r]   s
           @@r,   Ú#resolve_supported_reasoning_effortsri   ‰   sð   ù€ ð( !+§¡Ð/CÓ DÐØ˜UÑ"Øä)¨*Ó5€EÜ #Ñ#RÀ5Ç<Á<Ã>Ô#RÓ RÐØ Ñ%Ñ.@Ù)ˆrÐ3¨tÐ3ä0°Ó<€HØÐØˆä
Ñ
5 e§l¡l£nÔ
5Ô5ØäÓcÔ4DÔcÓc€GÜÓ\´?Ô\Ó\€Fä ?À
ÈEÐRXÉMÔ ZŒ	�)ÔÔ`iÓ`kð ð Ô5Ñ5¸Ñ>ÀÑK€GÜÓ`Ô&JÔ`Ó`Ð`r.   ÚcurrentÚresolvedc                 óž   ‡— |€| �t        | «      S dS | €t        |«      S t        | «      t        |«      z  Št        ˆfd„t        D «       «      S )z¹Deployments without metadata (None) never narrow the group; an effort survives only when
    every deployment with metadata accepts it, so the group offers nothing routing could reject.Nc              3   ó,   •K  — | ]  }|‰v sŒ|–— Œ y ­wr0   r:   )r7   r2   Úkeeps     €r,   r8   z8intersect_supported_reasoning_efforts.<locals>.<genexpr>Á   s   øè ø€ Ò]˜FÈfÐX\Ên”Ñ]ùr<   )r?   r>   r	   )rj   rk   rn   s     @r,   Ú%intersect_supported_reasoning_effortsro   ¶   sT   ø€ ð ÐØ!(Ð!4Œu�W‹~Ð>¸$Ð>Ø€Ü�X‹ÐÜ˜GÓ$¤y°Ó':Ñ:€DÜÓ]Ô&JÔ]Ó]Ð]r.   )!Ú__doc__Úcollections.abcr   r   Útypesr   Útypingr   r   r'   Úlitellm.types.llms.openair   r	   Ú__annotations__r
   r%   Úobjectr   r   r   r   r>   r   r-   r4   r?   rB   rG   ÚboolrM   rR   ri   ro   r:   r.   r,   ú<module>rx      s  ðò÷: .Ý "ß "ã Ý 6á.6Ð7GÓ.HÐ $ eÓ HÙ,<¸RÓ,@€ˆe�G˜C ˜KÑ(Ñ)Ó @ð€ˆuó ð  9Ð �uÓ 8Ø,Ð �%Ó ,Ø)€�Ó )Ù )Ð*<Ó =Ð ˜Ó =ð
8 '¨#¨v¨+Ñ"6ð 
8¸7À3ÈÀ;Ñ;Oó 
8ð w¨s°F¨{Ñ';ð ÀÈÈVÈÑ@Tó ðb¨7°3¸°;Ñ+?ð bÀEÈ#ÈsÈ(ÁOÐVZÑDZó bð-°ð -È#ð -ÐRWÐX[Ð]`ÐX`ÑRaÐdhÑRhó -ð °¸¸V¸Ñ0Dð ÈFð ÐW[ó ð3Ø   f Ñ-°Ñ4ð3à   f Ñ-ð3ð 
ó3ð *aØ˜˜V˜Ñ$ð*að ð*að ˆ3�ˆ8�_�tÑó	*aðZ^Ø�c‰]˜TÑ!ð^à�s‰m˜dÑ"ð^ð ˆ3�ˆ8�_�tÑô^r.   