
    ^h                         S SK r S SKrS SKJrJrJrJrJr  S SKrS SK	J
r
  S SKJrJr  S SKJr  S SKJrJr  SSKJr  \(       a	  S S	KJr  \rO\r " S
 S\5      rg)    N)TYPE_CHECKINGAnyListOptionalUnionconvert_content_list_to_str)
BaseConfigBaseLLMException)AllMessageValues)ModelResponseUsage   NLPCloudError)Loggingc                     ^  \ rS rSr% SrSr\\   \S'   Sr	\\
   \S'   Sr\\   \S'   Sr\\
   \S'   Sr\\
   \S'   Sr\\   \S	'   Sr\\   \S
'   Sr\\   \S'   Sr\\   \S'   Sr\\   \S'   Sr\\   \S'   Sr\\   \S'               S*S\\   S\\
   S\\   S\\
   S\\
   S	\\   S
\\   S\\   S\\   S\\   S\\   S\\   SS4S jjr\U 4S j5       r S+S\S\S\\   S\S\\   S\4S jjrS\S\4S jrS\S\S\S\
S\4
S jr S\S\S\!\\"RF                  4   S\$4S jr%S\S\\   S\S \S\S\4S! jr&  S,S\S"\"RN                  S#\(S$\)S%\S\\   S\S \S&\*S\\   S'\\
   S\(4S( jjr+S)r,U =r-$ )-NLPCloudConfig   a4  
Reference: https://docs.nlpcloud.com/#generation

- `max_length` (int): Optional. The maximum number of tokens that the generated text should contain.

- `length_no_input` (boolean): Optional. Whether `min_length` and `max_length` should not include the length of the input text.

- `end_sequence` (string): Optional. A specific token that should be the end of the generated sequence.

- `remove_end_sequence` (boolean): Optional. Whether to remove the `end_sequence` string from the result.

- `remove_input` (boolean): Optional. Whether to remove the input text from the result.

- `bad_words` (list of strings): Optional. List of tokens that are not allowed to be generated.

- `temperature` (float): Optional. Temperature sampling. It modulates the next token probabilities.

- `top_p` (float): Optional. Top P sampling. Below 1, only the most probable tokens with probabilities that add up to top_p or higher are kept for generation.

- `top_k` (int): Optional. Top K sampling. The number of highest probability vocabulary tokens to keep for top k filtering.

- `repetition_penalty` (float): Optional. Prevents the same word from being repeated too many times.

- `num_beams` (int): Optional. Number of beams for beam search.

- `num_return_sequences` (int): Optional. The number of independently computed returned sequences.
N
max_lengthlength_no_inputend_sequenceremove_end_sequenceremove_input	bad_wordstemperaturetop_ptop_krepetition_penalty	num_beamsnum_return_sequencesreturnc                     [        5       nUR                  5        H(  u  pUS:w  d  M  Uc  M  [        U R                  X5        M*     g )Nself)localsitemssetattr	__class__)r$   r   r   r   r   r   r   r   r   r   r   r    r!   locals_keyvalues                   d/home/james-whalen/.local/lib/python3.13/site-packages/litellm/llms/nlp_cloud/chat/transformation.py__init__NLPCloudConfig.__init__B   s7     (!--/JCf}!23 *    c                     > [         TU ]  5       $ N)super
get_config)clsr(   s    r,   r3   NLPCloudConfig.get_configV   s    w!##r/   headersmodelmessagesoptional_paramsapi_keyc                 .    SSS.nU(       a  SU 3US'   U$ )Nzapplication/json)acceptzcontent-typezToken Authorization )r$   r6   r7   r8   r9   r:   s         r,   validate_environment#NLPCloudConfig.validate_environmentZ   s,     ).
 )/y'9GO$r/   c                 
    / SQ$ )N)
max_tokensstreamr   r   presence_penaltyfrequency_penaltynstopr>   )r$   r7   s     r,   get_supported_openai_params*NLPCloudConfig.get_supported_openai_paramsj   s    	
 		
r/   non_default_paramsdrop_paramsc                     UR                  5        HW  u  pVUS:X  a  XbS'   US:X  a  XbS'   US:X  a  XbS'   US:X  a  XbS'   US:X  a  XbS'   US:X  a  XbS'   US:X  a  XbS	'   US
:X  d  MS  XbS'   MY     U$ )NrB   r   rC   r   r   rD   rE   rF   r!   rG   stop_sequences)r&   )r$   rJ   r9   r7   rK   paramr+   s          r,   map_openai_params NLPCloudConfig.map_openai_paramsv   s     /446LE$05- ,1)%16.+0(**6; 23++7< 34|:? 6749 01! 7" r/   error_messagestatus_codec                     [        X!US9$ )N)rR   messager6   r   )r$   rQ   rR   r6   s       r,   get_error_classNLPCloudConfig.get_error_class   s     #G
 	
r/   litellm_paramsc                 B    SR                  S U 5       5      nSU0UEnU$ )N c              3   8   #    U  H  n[        U5      v   M     g 7fr1   r   ).0rT   s     r,   	<genexpr>3NLPCloudConfig.transform_request.<locals>.<genexpr>   s     UH3G<<Hs   text)join)r$   r7   r8   r9   rW   r6   r^   datas           r,   transform_request NLPCloudConfig.transform_request   s5     xxUHUU D


 r/   raw_responsemodel_responselogging_objrequest_dataencoding	json_modec                 d   UR                  S U
UR                  SU0S9   UR                  5       nSU;   a  [	        US   UR
                  S9e [        US   5      S:  a!  US   UR                  S   R                  l	        US   nUS   n[        [        R                  " 5       5      Ul        Xl        [        UUX-   S	9n[!        US
U5        U$ ! [         a    [	        UR                  UR
                  S9ef = f! [         a)    [	        [        R                  " U5      UR
                  S9ef = f)Ncomplete_input_dict)inputr:   original_responseadditional_args)rT   rR   errorgenerated_textr   nb_input_tokensnb_generated_tokens)prompt_tokenscompletion_tokenstotal_tokensusage)	post_callr^   json	Exceptionr   rR   lenchoicesrT   contentdumpsinttimecreatedr7   r   r'   )r$   r7   rc   rd   re   rf   r8   r9   rW   rg   r:   rh   completion_responserr   rs   ru   s                   r,   transform_response!NLPCloudConfig.transform_response   se    	*//2LA	 	 	
	"."3"3"5
 ))+G4(44 
	*+;<=A+,<= #**1-55= ,,=>/0EF!$TYY[!1$'/&:

 	/C  	$))|7O7O 	  # JJ':; , 8 8 s   C 3C< )C9<3D/r>   )NNNNNNNNNNNNr1   )NN).__name__
__module____qualname____firstlineno____doc__r   r   r}   __annotations__r   boolr   strr   r   r   listr   floatr   r   r   r    r!   r-   classmethodr3   dictr   r   r?   rH   rO   r   httpxHeadersr   rU   ra   Responser   LoggingClassr   r   __static_attributes____classcell__)r(   s   @r,   r   r      sL   8 !%J$&*OXd^*"&L(3-&*.$.#'L(4.' $Ix~$#'K%'!E8E?!E8C=*..#Ix}#*.(3-. %)*.&*.2'+$('+!%#.2#'.24SM4 "$4 sm	4
 &d^4 tn4 D>4 e_4 4 }4 %UO4 C=4 'sm4 
4( $ $ "&  '(	
  # 
 

 

 

   	
  
4
 
/2
=B4CV=W
	
 '( 	
   
8 "&$(:: nn: &	:
 ": : '(: : : : #: D>: 
: :r/   r   )rw   r~   typingr   r   r   r   r   r   8litellm.litellm_core_utils.prompt_templates.common_utilsr	   )litellm.llms.base_llm.chat.transformationr
   r   litellm.types.llms.openair   litellm.utilsr   r   common_utilsr   *litellm.litellm_core_utils.litellm_loggingr   LiteLLMLoggingObjr   r   r>   r/   r,   <module>r      sF      < <  S 6 . (W$LLJZ Jr/   