Ë
    uPêj¨  ã                   ó¶   — d dl Z d dlZd dlZd dlZd dlmZ d dlmZ d dlZd dl	Z	d dl
mZmZmZmZ  G d„ de«      Z G d„ d«      Z	 	 dd	ed
edededef
d„Zd„ Zy)é    N)ÚCallable)ÚFinal)ÚChoicesÚMessageÚModelResponseÚUsagec                   ó   ‡ — e Zd Zˆ fd„Zˆ xZS )Ú	PalmErrorc                 óØ   •— || _         || _        t        j                  dd¬«      | _        t        j
                  || j                  ¬«      | _        t        ‰| �!  | j                  «       y )NÚPOSTzJhttps://developers.generativeai.google/api/python/google/generativeai/chat)ÚmethodÚurl)Ústatus_codeÚrequest)	r   ÚmessageÚhttpxÚRequestr   ÚResponseÚresponseÚsuperÚ__init__)Úselfr   r   Ú	__class__s      €úk/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/litellm/llms/deprecated_providers/palm.pyr   zPalmError.__init__   sQ   ø€ Ø&ˆÔØˆŒÜ—}‘}ØØ\ô
ˆŒô Ÿ™°;ÈÏÉÔUˆŒÜ‰Ñ˜Ÿ™Õ&ó    )Ú__name__Ú
__module__Ú__qualname__r   Ú__classcell__)r   s   @r   r
   r
      s   ø„ ÷'ð 'r   r
   c                   ó  — e Zd ZU dZdZedz  ed<   dZedz  ed<   dZ	e
dz  ed<   dZedz  ed<   dZedz  ed<   dZe
dz  ed<   dZedz  ed	<   	 	 	 	 	 	 	 ddedz  dedz  de
dz  dedz  dedz  de
dz  d	edz  d
dfd„Zed„ «       Zy)Ú
PalmConfigan  
    Reference: https://developers.generativeai.google/api/python/google/generativeai/chat

    The class `PalmConfig` provides configuration for the Palm's API interface. Here are the parameters:

    - `context` (string): Text that should be provided to the model first, to ground the response. This could be a prompt to guide the model's responses.

    - `examples` (list): Examples of what the model should generate. They are treated identically to conversation messages except that they take precedence over the history in messages if the total input size exceeds the model's input_token_limit.

    - `temperature` (float): Controls the randomness of the output. Must be positive. Higher values produce a more random and varied response. A temperature of zero will be deterministic.

    - `candidate_count` (int): Maximum number of generated response messages to return. This value must be between [1, 8], inclusive. Only unique candidates are returned.

    - `top_k` (int): The API uses combined nucleus and top-k sampling. `top_k` sets the maximum number of tokens to sample from on each step.

    - `top_p` (float): The API uses combined nucleus and top-k sampling. `top_p` configures the nucleus sampling. It sets the maximum cumulative probability of tokens to sample from.

    - `max_output_tokens` (int): Sets the maximum number of tokens to be returned in the output
    NÚcontextÚexamplesÚtemperatureÚcandidate_countÚtop_kÚtop_pÚmax_output_tokensÚreturnc                 ó¤   — t        «       j                  «       }|j                  «       D ]%  \  }	}
|	dk7  sŒ|
€Œt        | j                  |	|
«       Œ' y )Nr   )ÚlocalsÚcopyÚitemsÚsetattrr   )r   r"   r#   r$   r%   r&   r'   r(   Úlocals_ÚkeyÚvalues              r   r   zPalmConfig.__init__7   sF   € ô  ›Ÿ™›ˆØ!Ÿ-™-›/ò 	4‰JˆC�Ø�f‹} Ñ!2Ü˜Ÿ™¨¨UÕ3ñ	4r   c                 óø   — | j                   j                  «       D ��ci c]O  \  }}|j                  d«      s9t        |t        j
                  t        j                  t        t        f«      s|�||“ŒQ c}}S c c}}w )NÚ__)	Ú__dict__r-   Ú
startswithÚ
isinstanceÚtypesÚFunctionTypeÚBuiltinFunctionTypeÚclassmethodÚstaticmethod)ÚclsÚkÚvs      r   Ú
get_configzPalmConfig.get_configF   st   € ð Ÿ™×*Ñ*Ó,÷
á��1Ø—<‘< Ô%ÜØä×&Ñ&Ü×-Ñ-ÜÜ ð	ôð �ð ˆq‰Dó
ð 	
ùó 
s   žAA6)NNNNNNN)r   r   r   Ú__doc__r"   ÚstrÚ__annotations__r#   Úlistr$   Úfloatr%   Úintr&   r'   r(   r   r:   r?   © r   r   r!   r!      s  … ñð( €GˆS�4‰ZÓØ €Hˆd�T‰kÓ Ø $€K�˜‘Ó$Ø"&€O�S˜4‘ZÓ&Ø€Eˆ3�‰:ÓØ€Eˆ5�4‰<ÓØ$(Ð�s˜T‘zÓ(ð #Ø $Ø$(Ø&*Ø Ø"Ø(,ñ4à�t‘ð4ð ˜‘+ð4ð ˜T‘\ð	4ð
 ˜t™ð4ð �T‰zð4ð �t‰|ð4ð  ™:ð4ð 
ó4ð ñ
ó ñ
r   r!   ÚmodelÚmessagesÚmodel_responseÚprint_verboseÚoptional_paramsc
                 ó‚  — 	 dd l m}
 |
j                  |¬«       | } t	        j
                  |«      }|j                  dd «       t        j                  j                  «       }|j                  «       D ]  \  }}||vsŒ|||<   Œ d}|D ]+  }d|v r|d   dk(  r
||d   › z  }Œ||d   › z  }Œ#||d   › z  }Œ- |j                  |dd	d
|ii¬«       	  |
j                  dd|i|¤Ž}|j                  |d|d	i i¬«        |d|› �«       |}	 g }t!        |j"                  «      D ]S  \  }}t%        |d   «      dkD  rt'        |d   ¬«      }nt'        d ¬«      }t)        |dz   |¬«      }|j+                  |«       ŒU ||_        	 |d   d   d   j5                  d«      }t%        |j7                  |«      «      }t%        |j7                  |d   d   d   j5                  dd«      «      «      }t9        t;        j:                  «       «      |_        d| z   |_        tA        ||||z   ¬«      }tC        |d|«       |S # t        $ r t        d«      ‚w xY w# t        $ r}t        t        |«      d¬«      ‚d }~ww xY w# t        $ r* t        t/        j0                  «       |j2                  ¬«      ‚w xY w# t        $ r t        dd|› �¬«      ‚w xY w)Nr   zTImporting google.generativeai failed, please run 'pip install -q google-generativeai)Úapi_keyÚstreamÚ ÚroleÚuserÚcontentÚcomplete_input_dictÚinference_params)ÚinputrM   Úadditional_argsÚpromptiô  )r   r   )rU   rM   Úoriginal_responserV   zraw model_response: Úoutput)rR   é   )Úindexr   Úchoicesr   i�  z*No response received. Original response - )r   r   zpalm/)Úprompt_tokensÚcompletion_tokensÚtotal_tokensÚusagerF   )"Úgoogle.generativeaiÚgenerativeaiÚ	ExceptionÚ	configurer,   ÚdeepcopyÚpopÚlitellmr!   r?   r-   Úpre_callÚgenerate_textr
   rA   Ú	post_callÚ	enumerateÚ
candidatesÚlenr   r   Úappendr\   Ú	tracebackÚ
format_excr   ÚgetÚencoderE   ÚtimeÚcreatedrG   r   r.   )rG   rH   rI   rJ   rM   ÚencodingÚlogging_objrK   Úlitellm_paramsÚ	logger_fnÚpalmrT   Úconfigr=   r>   rW   r   r   ÚeÚcompletion_responseÚchoices_listÚidxÚitemÚmessage_objÚ
choice_objr]   r^   r`   s                               r   Ú
completionr‚   Y   sD  € ðpÝ*ð 	‡N�N˜7€NÔ#à€Eô #Ÿm™m¨OÓ<ÐØ×ÑØ�$ôô ×&Ñ&×1Ñ1Ó3€FØ—‘“ò $‰ˆˆ1àÐ%Ò%à"#Ð˜QÒð	$ð €FØò .ˆØ�WÑØ�v‰ &Ò(Ø˜W YÑ/Ð0Ñ1‘à˜W YÑ/Ð0Ñ1‘à˜ Ñ+Ð,Ñ-‰Fð.ð ×ÑØØØ.Ð1CÐEUÐ0VÐWð ô ð
Ø,˜$×,Ñ,ÑO°FÐOÐ>NÑOˆð ×ÑØØØ"Ø.°Ð3ð	 ô ñ Ð(¨¨
Ð3Ô4à"ÐðZØ ˆÜ"Ð#6×#AÑ#AÓBò 	,‰IˆC�Ü�4˜‘>Ó" QÒ&Ü%¨d°8©nÔ=‘ä%¨dÔ3�Ü  s¨Q¡w¸ÔDˆJØ×Ñ 
Õ+ð	,ð ".ˆÔð
Ø,¨YÑ7¸Ñ:¸9ÑE×IÑIÈ)ÓTÐô ˜xŸ™¨vÓ6Ó7€MÜ" 8§?¡?°>À)Ñ3LÈQÑ3OÐPYÑ3Z×3^Ñ3^Ð_hÐjlÓ3mÓ#nÓoÐä ¤§¡£Ó-€NÔØ" U™?€NÔÜØ#Ø+Ø"Ð%6Ñ6ô€Eô
 ˆN˜G UÔ+ØÐøôm ò pÜÐnÓoÐoðpûôJ ò 
ÜÜ˜“FØô
ð 	
ûð
ûô4 ò ZÜ¤	× 4Ñ 4Ó 6ÀH×DXÑDXÔYÐYðZûô
 ò 
ÜØØ@ÀÀ
ÐKô
ð 	
ð
ús<   ‚H/ ÃI ÄA4I. Å<J$ È/IÉ	I+ÉI&É&I+É.3J!Ê$J>c                   ó   — y )NrF   rF   r   r   Ú	embeddingr„   À   s   € àr   )NN)r,   rs   ro   r7   Úcollections.abcr   Útypingr   r   rg   Úlitellm.utilsr   r   r   r   rc   r
   r!   rA   rC   Údictr‚   r„   rF   r   r   ú<module>r‰      s�   ðÛ Û Û Û Ý $Ý ã ã ß @Ó @ô	'�	ô 	'÷<
ñ <
ðP ØñdØðdàðdð "ðdð ð	dð ódóN	r   