Ryanhub - file viewer
filename: chat/__pycache__/model.cpython-314.pyc
branch: main
back to repo
+
ݝi�����^RIt^RIt^RItRt]PP]PP
]4RR4t]PP]4'dA]
!]RRR7;_uu_4t]P!]4t
]
PR4tRRR4RtR	tRR
RlltRtRR
RlltR# +'giL+;i ]dRtL9i;i)�N�agentzconfig.json�rzutf-8)�encoding�MODELSc�"�\V\4'g\R4hVPR4;'gVPR4pV'g\R4hRV9gVR,'g\R4h\V4pWR&V#)z$model config entry must be an object�name�modelz'model config requires 'name' or 'model'�urlzmodel config requires 'url')�
isinstance�dict�
ValueError�get)�cfg�
model_name�outs&  �model.py�_normalize_cfgrs{���c�4� � ��?�@�@������4�4�C�G�G�G�$4�J���B�C�C��C��s�5�z�z��6�7�7�
�s�)�C���K��J�c�J�\\\4'd>\'d2\\	\P444p\
V4#\\\\34'd#\'d\
\^,4#\R4h)rz'MODELS must be a non-empty dict or list)
rrr�next�iter�valuesr�list�tupler
)�firsts r�_first_model_cfgr!sc���&�$���F�F��T�&�-�-�/�*�+���e�$�$��&�4��-�(�(�V�V��f�Q�i�(�(�
�>�
?�?rc�$�V^8�dQhR\/#)��task)�str)�formats"r�__annotate__r"*s�����rc���\\\4'dO\'dCV\9d\\V,4#R\9d\\R,4#\	4#)z�
Resolve model config by logical task name with graceful fallback.

Task lookup order:
1) MODELS[task] when MODELS is a dict and key exists
2) MODELS["chat"] when present
3) first configured model entry
�chat)rrrrr�rs&r�_get_model_cfgr&*sK���&�$���F�F��6�>�!�&��,�/�/��V��!�&��.�1�1���rc��VfR#\V\4'd&VP4P4R8XdR#VR8Xd\	V4#\V4# \dTR8Xd\R4h\R4hi;i)N�NONE�
max_tokenszmax_tokens must be an integerztemperature must be a number)rr �strip�upper�int�float�	Exceptionr
)�valuers&&r�_coerce_optional_numberr0;s����}���%����%�+�+�-�"5�"5�"7�6�"A��9��<���u�:���U�|����9��<���<�=�=��7�8�8�9�s�A �
A � )B	c�<�V^8�dQhR\R\R\/#)rrr)�temperature)r r,r-)r!s"rr"r"Js"��9�9�s�9��9�RW�9rc�l�\VR7p\VR4pVf\VPR4R4p\VR4pVf\VPR4R4pRVR,RVRR/pVR9dR	VR
&VeWWR&VeWgR&\P!VR,V^xR7pVP4VP
4p	\V	\4'dHV	PR
4p
\V
\4'dRV
9d
V
R,#RV	9d
V	R,#\V	4#)a]
Send chat-style messages to the model endpoint.

Args:
  messages: list of chat message objects (role/content)
  task: logical task key used to pick a model from MODELS (e.g. router/chat/code/critic)
  max_tokens: optional int, maximum tokens for the model response
  temperature: optional float, sampling temperature

Returns assistant text only.
r%r)r2r	r�messages�streamF�jsonr!r
)r6�timeout�message�content)�router�planner)
r&r0r�requests�post�raise_for_statusr6rrr )r4rr)r2r�resolved_max_tokens�resolved_temperature�payloadr�data�msgs&&&&       r�
call_modelrDJs5���d�
#�C�1�*�l�K���"�5�c�g�g�l�6K�\�Z��2�;�
�N���#�6�s�w�w�}�7M�}�]��	��V���H��%��G��$�$�"�����&� 3����'�!5�
���
�
�c�%�j�w��<�A������6�6�8�D��$�����h�h�y�!���c�4� � �Y�#�%5��y�>�!�����	�?�"��t�9�r)r$)r$NN)r<r6�osr�path�join�dirname�__file__�	_cfg_path�exists�open�_f�load�_jrr.rrr&r0rD�rr�<module>rQs�����	�
���G�G�L�L�������2�G�]�K�	��7�7�>�>�)����
�)�S�7�
3�
3�r����2��B��V�V�H�%�F�4��"@��"9�9�9�A4�
3�������s0�'C�:$C�C�C	�C�C�	C �C