
    gC                         d dl mZmZmZ d dlZd dlmZmZ d dlm	Z	m
Z
 ddlmZ ddlmZ d	d
lmZ  e       Z G d de      Zy)    )CallableOptionalUnionN)AsyncHTTPHandlerHTTPHandler)CustomStreamingDecoderModelResponse   )OpenAILikeChatHandler   )_get_api_params   )IBMWatsonXChatConfigc                        e Zd Z fdZdddddddddd	dedededed	ed
edede	e   dede	e   de	e
eej                  f      de	e
eef      de	e   de	e   def fdZ xZS )WatsonXChatHandlerc                 $    t        |   di | y )N )super__init__)selfkwargs	__class__s     V/var/www/openai/venv/lib/python3.12/site-packages/litellm/llms/watsonx/chat/handler.pyr   zWatsonXChatHandler.__init__   s    "6"    NF)	acompletionlitellm_paramsheaders	logger_fntimeoutclientcustom_endpointstreaming_decoderfake_streammodelmessagesapi_basecustom_llm_providercustom_prompt_dictmodel_responseprint_verboseapi_keyoptional_paramsr   r   r    r!   r"   r#   c                >   t        |      }t        j                  |xs i ||||	      }t        j                  ||||j	                  dd            }t        j                  ||      }|j                  |       t        | !  |||||||||	|
|||||||d|      S )	N)params)r   r$   r%   r,   r+   streamF)r&   r$   r,   r/   )r$   
api_paramsT)r$   r%   r&   r'   r(   r)   r*   encodingr+   logging_objr,   r   r   r   r   r   r    r!   r"   )	r   watsonx_chat_transformationvalidate_environmentget_complete_urlget_prepare_payloadupdater   
completion)r   r$   r%   r&   r'   r(   r)   r*   r1   r+   r2   r,   r   r   r   r   r   r    r!   r"   r#   r0   watsonx_auth_payloadr   s                          r   r9   zWatsonXChatHandler.completion   s    0 %O<
 .BBMr+ C 
 /??+"&&x7	 @ 
  ;KK!  L  
 	34w! 31)'#+#) /' " 
 	
r   )__name__
__module____qualname__r   strlistdictr	   r   r   r   floathttpxTimeoutr   r   boolr   r9   __classcell__)r   s   @r   r   r      s   #" "&9=AE*.>B!-F
 F
 	F

 F
 !F
 !F
 &F
  F
 #F
 F
  $!F
$ %u}} 456%F
& {,<<=>'F
( "$)F
* $$:;+F
, -F
 F
r   r   )typingr   r   r   rB   &litellm.llms.custom_httpx.http_handlerr   r   litellm.types.utilsr   r	   openai_like.chat.handlerr   common_utilsr   transformationr   r3   r   r   r   r   <module>rL      s5    , ,  P E = * 024 J
. J
r   