
    ^hK                         S r SSKJrJrJrJrJrJr  SSKrSSK	J
r
  SSKJr  SSKJr  SSKJr  \(       a	  SS	KJr  \rO\r " S
 S\5      rg)z,
OpenAI-like chat completion transformation
    )TYPE_CHECKINGAnyListOptionalTupleUnionNget_secret_str)ChatCompletionAssistantMessage)ModelResponse   )OpenAIGPTConfig)Loggingc                   $  ^  \ rS rSr SS\\   S\\   S\\   S\\\   \\   4   4S jjr\S\	S\
S\	4S	 j5       r\S\S
\R                  S\S\
S\S\S\\   S\\\4   S\S\
S\S\\   S\4S j5       r SS\S\S\S\
S\
S\4U 4S jjjrSrU =r$ )OpenAILikeChatConfig   api_baseapi_keymodelreturnc                 j    U=(       d    [        S5      nU=(       d    [        S5      =(       d    SnX4$ )NOPENAI_LIKE_API_BASEOPENAI_LIKE_API_KEY r	   )selfr   r   r   dynamic_api_keys        f/home/james-whalen/.local/lib/python3.13/site-packages/litellm/llms/openai_like/chat/transformation.py$_get_openai_compatible_provider_info9OpenAILikeChatConfig._get_openai_compatible_provider_info   s7     E~.DEB~&;<B 	 ((    message	json_modec                     U(       d  U $ U R                  S5      nUb  [        U5      S:w  a  U $ US   S   R                  S5      =(       d    SU S'   SU S'   U $ )	a  
if json_mode is true, convert the returned tool call response to a content with json str

e.g. input:

{"role": "assistant", "tool_calls": [{"id": "call_5ms4", "type": "function", "function": {"name": "json_tool_call", "arguments": "{"key": "question", "value": "What is the capital of France?"}"}}]}

output:

{"role": "assistant", "content": "{"key": "question", "value": "What is the capital of France?"}"}

tool_callsN   r   function	argumentsr   content)getlen)r!   r"   _tool_callss      r   !_convert_tool_response_to_message6OpenAILikeChatConfig._convert_tool_response_to_message$   sc     Nkk,/#k"2a"7N(^J7;;KHNB	 $r    responsemodel_responsestreamlogging_objoptional_paramsdatamessagescustom_llm_provider
base_modelc                 B   UR                  5       nUR                  USUSU0S9  U(       a6  US    H-  n[        R                  UR	                  S5      U5      nUUS'   M/     [        S0 UD6nUS-   UR                  =(       d    S-   Ul        Ub  UUR                  S'   U$ )	Nr   complete_input_dict)inputr   original_responseadditional_argschoicesr!   /r    )json	post_callr   r,   r)   r   r   _hidden_params)r   r.   r/   r0   r1   r2   r   r3   r4   print_verboseencodingr"   r5   r6   response_jsonchoicer!   returned_responses                     r   _transform_response(OpenAILikeChatConfig._transform_response@   s    " !+2D9	 	 	
 '	2.PPJJy)9 %,y!	 3 *:M:  #%):)@)@)FBG 	 !8B,,W5  r    non_default_paramsdrop_params-replace_max_completion_tokens_with_max_tokensc                 v   > [         TU ]  XX45      nSU;   a!  U(       a  US   US'   UR                  SS 5        U$ )Nmax_completion_tokens
max_tokens)supermap_openai_paramspop)r   rI   r2   r   rJ   rK   mapped_params	__class__s          r   rP   &OpenAILikeChatConfig.map_openai_paramsj   sR     1
 $'99=*<'+M,' 5t<r    r>   )N)T)__name__
__module____qualname____firstlineno__r   strr   r   staticmethodr   boolr,   httpxResponser   LiteLLMLoggingObjdictr   r   rG   rP   __static_attributes____classcell__)rS   s   @r   r   r      so   
  $	
)3-
) #
) }	
)
 
x}hsm+	,
) /<@	' 6 '!'!..'! &'! 	'!
 ''! '! #'! D#I'! '! '! !'! SM'! 
'! '!^ ?C   	
  8< 
 r    r   )__doc__typingr   r   r   r   r   r   r\   litellm.secret_managers.mainr
   litellm.types.llms.openair   litellm.types.utilsr   openai.chat.gpt_transformationr   *litellm.litellm_core_utils.litellm_loggingr   _LiteLLMLoggingObjr^   r   r>   r    r   <module>rj      sB    D C  7 D - =X*g? gr    