Ë
    ÿ`gjÉ  ã                   ól   — d Z ddlmZ ddlmZ ddlmZ  G d„ de«      Z eddd	d
d¬«      Z ee«       y)u­  Custom / Ollama (local) provider profile.

Covers any endpoint registered as provider="custom", including local
Ollama instances and OpenAI-compatible reasoning endpoints (GLM-5.2 on
Volcengine ARK, vLLM, llama.cpp). Key quirks:
  - ollama_num_ctx â†’ extra_body.options.num_ctx (local context window)
  - reasoning_config disabled â†’ top-level reasoning_effort="none"
    (Ollama /v1/chat/completions ignores think=False â€” ollama#14820)
    + extra_body.think = False for /api/chat and proxies
  - reasoning_config enabled + effort â†’ top-level reasoning_effort
    (the native OpenAI-compatible format GLM/ARK expect; unset omits it
    so the endpoint's server default applies)
é    )ÚAny)Úregister_provider)ÚProviderProfilec                   ó    ‡ — e Zd ZdZdddœdedz  dedz  dedeeeef   eeef   f   fd„Z	ddd	d
œdedz  dedz  de
dee   dz  fˆ fd„Zˆ xZS )ÚCustomProfileuA   Custom/Ollama local provider â€” think=false and num_ctx support.N)Úreasoning_configÚollama_num_ctxr   r	   ÚctxÚreturnc                ó4  — i }i }|r|j                  di «      }||d<   ||d<   |rqt        |t        «      ra|j                  d«      xs dj                  «       j	                  «       }|j                  dd«      }|dk(  s|du rd|d	<   d|d
<   ||fS |r||d	<   ||fS )NÚoptionsÚnum_ctxÚeffortÚ ÚenabledTÚnoneFÚreasoning_effortÚthink)ÚgetÚ
isinstanceÚdictÚstripÚlower)	Úselfr   r	   r
   Ú
extra_bodyÚ	top_levelr   Ú_effortÚ_enableds	            úZ/root/.hermes/venv/lib/python3.12/site-packages/plugins/model-providers/custom/__init__.pyÚbuild_api_kwargs_extrasz%CustomProfile.build_api_kwargs_extras   sÍ   € ð &(ˆ
Ø$&ˆ	ñ Ø —n‘n Y°Ó3ˆGØ!/ˆGIÑØ$+ˆJyÑ!ñ  ¤
Ð+;¼TÔ BØ'×+Ñ+¨HÓ5Ò;¸×BÑBÓD×JÑJÓLˆGØ'×+Ñ+¨I°tÓ<ˆHØ˜&Ò  H°Ñ$5ð 17	Ð,Ñ-Ø&+
˜7Ñ#ð ˜9Ð$Ð$ñ Ø07	Ð,Ñ-à˜9Ð$Ð$ó    g       @©Úapi_keyÚbase_urlÚtimeoutr#   r$   r%   c                óF   •— |s| j                   syt        ‰| 	  |||¬«      S )z9Custom/Ollama: base_url is user-configured; fetch if set.Nr"   )r$   ÚsuperÚfetch_models)r   r#   r$   r%   Ú	__class__s       €r   r(   zCustomProfile.fetch_modelsG   s)   ø€ ñ ˜DŸMšMØÜ‰wÑ#¨G¸hÐPWÐ#ÓXÐXr!   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úintr   ÚtupleÚstrr    ÚfloatÚlistr(   Ú__classcell__)r)   s   @r   r   r      s²   ø„ ÙKð
 )-Ø%)ò	-%ð  ™+ð-%ð ˜d™
ð	-%ð
 ð-%ð 
ˆtC˜H‰~˜t C¨ H™~Ð-Ñ	.ó-%ðd #Ø#Øò
Yð t‘ð
Yð ˜‘*ð	
Yð
 ð
Yð 
ˆc‰TÑ	÷
Yñ 
Yr!   r   Úcustom)ÚollamaÚlocalÚvllmÚllamacppz	llama.cppz	llama-cpp© r   i   )ÚnameÚaliasesÚenv_varsr$   Údefault_max_tokensN)	r-   Útypingr   Ú	providersr   Úproviders.baser   r   r4   r9   r!   r   ú<module>rA      sO   ðñõ å 'Ý *ô<YOô <Yñ~ 
Ø	ðð Øð
 ô!
€ñ& &Õ r!   