Ë
    uPêjå0  ã                   óº   — 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	„ Z	 	 	 dd
e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 )ÚAlephAlphaErrorc                 óØ   •— || _         || _        t        j                  dd¬«      | _        t        j
                  || j                  ¬«      | _        t        ‰| �!  | j                  «       y )NÚPOSTz$https://api.aleph-alpha.com/complete)ÚmethodÚurl)Ústatus_codeÚrequest)	r   ÚmessageÚhttpxÚRequestr   ÚResponseÚresponseÚsuperÚ__init__)Úselfr   r   Ú	__class__s      €úr/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/litellm/llms/deprecated_providers/aleph_alpha.pyr   zAlephAlphaError.__init__   sL   ø€ Ø&ˆÔØˆŒÜ—}‘}¨FÐ8^Ô_ˆŒÜŸ™°;ÈÏÉÔUˆŒÜ‰Ñ˜Ÿ™Õ&ó    )Ú__name__Ú
__module__Ú__qualname__r   Ú__classcell__)r   s   @r   r
   r
      s   ø„ ÷'ð 'r   r
   c            A       ó$  — e Zd ZU dZej
                  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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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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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
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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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edz  d edz  d!edz  d"df@d#„Z+e,d$„ «       Z-y)&ÚAlephAlphaConfigaš  
    Reference: https://docs.aleph-alpha.com/api/complete/

    The `AlephAlphaConfig` class represents the configuration for the Aleph Alpha API. Here are the properties:

    - `maximum_tokens` (integer, required): The maximum number of tokens to be generated by the completion. The sum of input tokens and maximum tokens may not exceed 2048.

    - `minimum_tokens` (integer, optional; default value: 0): Generate at least this number of tokens before an end-of-text token is generated.

    - `echo` (boolean, optional; default value: false): Whether to echo the prompt in the completion.

    - `temperature` (number, nullable; default value: 0): Adjusts how creatively the model generates outputs. Use combinations of temperature, top_k, and top_p sensibly.

    - `top_k` (integer, nullable; default value: 0): Introduces randomness into token generation by considering the top k most likely options.

    - `top_p` (number, nullable; default value: 0): Adds randomness by considering the smallest set of tokens whose cumulative probability exceeds top_p.

    - `presence_penalty`, `frequency_penalty`, `sequence_penalty` (number, nullable; default value: 0): Various penalties that can reduce repetition.

    - `sequence_penalty_min_length` (integer; default value: 2): Minimum number of tokens to be considered as a sequence.

    - `repetition_penalties_include_prompt`, `repetition_penalties_include_completion`, `use_multiplicative_presence_penalty`,`use_multiplicative_frequency_penalty`,`use_multiplicative_sequence_penalty` (boolean, nullable; default value: false): Various settings that adjust how the repetition penalties are applied.

    - `penalty_bias` (string, nullable): Text used in addition to the penalized tokens for repetition penalties.

    - `penalty_exceptions` (string[], nullable): Strings that may be generated without penalty.

    - `penalty_exceptions_include_stop_sequences` (boolean, nullable; default value: true): Include all stop_sequences in penalty_exceptions.

    - `best_of` (integer, nullable; default value: 1): The number of completions will be generated on the server side.

    - `n` (integer, nullable; default value: 1): The number of completions to return.

    - `logit_bias` (object, nullable): Adjust the logit scores before sampling.

    - `log_probs` (integer, nullable): Number of top log probabilities for each token generated.

    - `stop_sequences` (string[], nullable): List of strings that will stop generation if they're generated.

    - `tokens` (boolean, nullable; default value: false): Flag indicating whether individual tokens of the completion should be returned or not.

    - `raw_completion` (boolean; default value: false): if True, the raw completion of the model will be returned.

    - `disable_optimizations` (boolean, nullable; default value: false): Disables any applied optimizations to both your prompt and completion.

    - `completion_bias_inclusion`, `completion_bias_exclusion` (string[], default value: []): Set of strings to bias the generation of tokens.

    - `completion_bias_inclusion_first_token_only`, `completion_bias_exclusion_first_token_only` (boolean; default value: false): Consider only the first token for the completion_bias_inclusion/exclusion.

    - `contextual_control_threshold` (number, nullable): Control over how similar tokens are controlled.

    - `control_log_additive` (boolean; default value: true): Method of applying control to attention scores.
    NÚmaximum_tokensÚminimum_tokensÚechoÚtemperatureÚtop_kÚtop_pÚpresence_penaltyÚfrequency_penaltyÚsequence_penaltyÚsequence_penalty_min_lengthÚ#repetition_penalties_include_promptÚ'repetition_penalties_include_completionÚ#use_multiplicative_presence_penaltyÚ$use_multiplicative_frequency_penaltyÚ#use_multiplicative_sequence_penaltyÚpenalty_biasÚ)penalty_exceptions_include_stop_sequencesÚbest_ofÚnÚ
logit_biasÚ	log_probsÚstop_sequencesÚtokensÚraw_completionÚdisable_optimizationsÚcompletion_bias_inclusionÚcompletion_bias_exclusionÚ*completion_bias_inclusion_first_token_onlyÚ*completion_bias_exclusion_first_token_onlyÚcontextual_control_thresholdÚcontrol_log_additiveÚreturnc                  ó¤   — t        «       j                  «       } | j                  «       D ]%  \  }!}"|!dk7  sŒ|"€Œt        | j                  |!|"«       Œ' y )Nr   )ÚlocalsÚcopyÚitemsÚsetattrr   )#r   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   Úlocals_ÚkeyÚvalues#                                      r   r   zAlephAlphaConfig.__init__m   sG   € ôD  ›Ÿ™›ˆØ!Ÿ-™-›/ò 	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__rE   Ú
startswithÚ
isinstanceÚtypesÚFunctionTypeÚBuiltinFunctionTypeÚclassmethodÚstaticmethod)ÚclsÚkÚvs      r   Ú
get_configzAlephAlphaConfig.get_config”   st   € ð Ÿ™×*Ñ*Ó,÷
á��1Ø—<‘< Ô%ÜØä×&Ñ&Ü×-Ñ-ÜÜ ð	ôð �ð ˆq‰Dó
ð 	
ùó 
s   žAA6)NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN).r   r   r   Ú__doc__ÚlitellmÚ
max_tokensr"   ÚintÚ__annotations__r#   r$   Úboolr%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   Ústrr2   r3   r4   r5   Údictr6   r7   Úlistr8   r9   r:   r;   r<   r=   r>   r?   r@   r   rR   rW   © r   r   r!   r!      s  … ñ4ðl ")×!3Ñ!3€N�C˜$‘JÓ3Ø!%€N�C˜$‘JÓ%Ø€Dˆ$�‰+ÓØ"€K��t‘Ó"Ø€Eˆ3�‰:ÓØ€Eˆ3�‰:ÓØ#'Ð�c˜D‘jÓ'Ø$(Ð�s˜T‘zÓ(Ø#'Ð�c˜D‘jÓ'Ø.2Ð  t¡Ó2Ø7;Ð'¨°©Ó;Ø;?Ð+¨T°D©[Ó?Ø7;Ð'¨°©Ó;Ø8<Ð(¨$°©+Ó<Ø7;Ð'¨°©Ó;Ø#€L�#˜‘*Ó#Ø=AÐ-¨t°d©{ÓAØ€GˆS�4‰ZÓØ€A€sˆT�zÓØ"€J��t‘Ó"Ø €Iˆs�T‰zÓ Ø"&€N�D˜4‘KÓ&Ø€FˆD�4‰KÓØ"&€N�D˜4‘KÓ&Ø)-Ð˜4 $™;Ó-Ø-1Ð˜t d™{Ó1Ø-1Ð˜t d™{Ó1Ø>BÐ.°°t±ÓBØ>BÐ.°°t±ÓBØ/3Ð  #¨¡*Ó3Ø(,Ð˜$ ™+Ó,ð &*Ø%)Ø Ø"&Ø Ø Ø'+Ø(,Ø'+Ø26Ø;?Ø?CØ;?Ø<@Ø;?Ø#'ØAEØ"ØØ"&Ø $Ø&*Ø"Ø&*Ø-1Ø15Ø15ØBFØBFØ37Ø,0ñA%4à˜d™
ð%4ð ˜d™
ð%4ð �T‰kð	%4ð
 ˜4‘Zð%4ð �T‰zð%4ð �T‰zð%4ð  ™*ð%4ð  ™:ð%4ð  ™*ð%4ð &)¨4¡Zð%4ð .2°D©[ð%4ð 26¸±ð%4ð .2°D©[ð%4ð /3°T©kð%4ð  .2°D©[ð!%4ð" ˜D‘jð#%4ð$ 48¸$±;ð%%4ð& �t‘ð'%4ð( �‰:ð)%4ð* ˜4‘Kð+%4ð, ˜‘:ð-%4ð. ˜t™ð/%4ð0 �t‘ð1%4ð2 ˜t™ð3%4ð4  $ d™{ð5%4ð6 $(¨$¡;ð7%4ð8 $(¨$¡;ð9%4ð: 59¸4±Kð;%4ð< 59¸4±Kð=%4ð> '*¨D¡jð?%4ð@ # T™kðA%4ðB 
óC%4ðN ñ
ó ñ
r   r!   c                 ó$   — dddœ}| rd| › �|d<   |S )Nzapplication/json)Úacceptzcontent-typezBearer ÚAuthorizationra   )Úapi_keyÚheaderss     r   Úvalidate_environmentrg   §   s*   € à$Ø*ñ€Gñ Ø%,¨W¨IÐ#6ˆ�Ñ Ø€Nr   ÚmodelÚmessagesÚapi_baseÚmodel_responseÚprint_verboseÚoptional_paramsc                 óÆ  — t        |«      }t        j                  j                  «       }|j	                  «       D ]  \  }}||vsŒ|||<   Œ |}| } d}d| v rft        |«      D ]W  \  }}d|v rE|dk(  r|d|d   › �z  }Œ|d   dk(  r|d|d   › �z  }Œ/|d   dk(  r|d	|d   › �z  }ŒC|d
|d   › �z  }ŒO||d   › z  }ŒY ndj                  d„ |D «       «      }| |dœ|¥}|j                  ||d|i¬«       t        j                  j                  ||t        j                  |«      d|v r|d   nd¬«      }d|v r|d   du r|j                  «       S |j                  |||j                  d|i¬«        |d|j                  › �«       |j                  «       }d|v rt        |d   |j                   ¬«      ‚	 g }t        |d   «      D ]W  \  }}t#        |d   «      dkD  rt%        |d   ¬«      }nt%        d ¬«      }t'        |d   |dz   |¬«      }|j)                  |«       ŒY ||_        t#        |j/                  |«      «      }t#        |j/                  |d   d   d   d   d ¬!«      «      }t1        t3        j2                  «       «      |_        | |_        t9        ||||z   ¬"«      }t;        |d#|«       |S # t,        $ r+ t        t        j                  |«      |j                   ¬«      ‚w xY w)$NÚ ÚcontrolÚroler   z###Instruction: ÚcontentÚsystemÚuserz
###Input: z###Response: ú c              3   ó&   K  — | ]	  }|d    –— Œ y­w)rr   Nra   )Ú.0r   s     r   ú	<genexpr>zcompletion.<locals>.<genexpr>Û   s   è ø€ ÒE°˜' )Õ,ÑEùs   ‚)rh   ÚpromptÚcomplete_input_dict)Úinputre   Úadditional_argsÚstreamF)rf   Údatar}   T)r{   re   Úoriginal_responser|   zraw model_response: Úerror)r   r   ÚcompletionsÚ
completion)rr   Úfinish_reasoné   )rƒ   Úindexr   Úchoicesr   ra   )Údisallowed_special)Úprompt_tokensÚcompletion_tokensÚtotal_tokensÚusage)rg   rY   r!   rW   rE   Ú	enumerateÚjoinÚpre_callÚmodule_level_clientÚpostÚjsonÚdumpsÚ
iter_linesÚ	post_callÚtextr
   r   Úlenr   r   Úappendr†   Ú	ExceptionÚencoder[   ÚtimeÚcreatedrh   r   rF   )rh   ri   rj   rk   rl   Úencodingre   Úlogging_objrm   Úlitellm_paramsÚ	logger_fnÚdefault_max_tokens_to_samplerf   ÚconfigrU   rV   Úcompletion_urlry   Úidxr   r~   r   Úcompletion_responseÚchoices_listÚitemÚmessage_objÚ
choice_objrˆ   r‰   r‹   s                                 r   r‚   r‚   ±   s‘  € ô *¨'Ó2€Gô ×,Ñ,×7Ñ7Ó9€FØ—‘“ò #‰ˆˆ1à�_Ò$à!"ˆO˜AÒð	#ð %€NØ€EØ€FØ�EÑÜ% hÓ/ò 	2‰LˆC�Ø˜Ñ Ø˜!’8ØÐ 0°¸Ñ1CÐ0DÐEÑE‘Fà˜v‘¨(Ò2ØÐ$4°W¸YÑ5GÐ4HÐ"IÑI™Ø  ™¨FÒ2Ø J¨w°yÑ/AÐ.BÐ"CÑC™à M°'¸)Ñ2DÐ1EÐ"FÑF™à˜W YÑ/Ð0Ñ1‘ñ	2ð —‘ÑE¸HÔEÓEˆàØñð ð€Dð ×ÑØØØ.°Ð5ð ô ô ×1Ñ1×6Ñ6ØØÜ�Z‰Z˜ÓØ,4¸Ñ,Gˆ˜xÒ(ÈUð	 7ó €Hð �?Ñ" °xÑ'@ÀDÑ'HØ×"Ñ"Ó$Ð$ð 	×ÑØØØ&Ÿm™mØ2°DÐ9ð	 	ô 	
ñ 	Ð,¨X¯]©]¨OÐ<Ô=à%-§]¡]£_ÐØÐ)Ñ)Ü!Ø+¨GÑ4Ø$×0Ñ0ôð ð
Ø&(�Ü!*Ð+>¸}Ñ+MÓ!Nò 
4‘I�C˜Ü˜4 Ñ-Ó.°Ò2Ü&-°d¸<Ñ6HÔ&I™ä&-°dÔ&;˜Ü!(Ø&*¨?Ñ&;Ø! A™gØ +ô"�Jð
 !×'Ñ'¨
Õ3ð
4ð *6�Ô&ô  # 8§?¡?°6Ó#:Ó;ˆÜ#&Ø�O‰OØ˜yÑ)¨!Ñ,¨YÑ7¸	ÑBØ#%ð ó ó$
Ðô "%¤T§Y¡Y£[Ó!1ˆÔØ$ˆÔÜØ'Ø/Ø&Ð):Ñ:ô
ˆô
 	� ¨Ô/ØÐøô/ ò Ü%Ü ŸJ™JÐ':Ó;Ø (× 4Ñ 4ôð ðús   Æ0A1J, Ê,4K c                   ó   — y )Nra   ra   r   r   Ú	embeddingrª   *  s   € àr   )NNN)r‘   rš   rO   Úcollections.abcr   Útypingr   r   rY   Úlitellm.utilsr   r   r   r   r˜   r
   r!   rg   r^   r`   r_   r‚   rª   ra   r   r   ú<module>r®      s“   ðÛ Û Û Ý $Ý ã ã ß @Ó @ô'�iô '÷N
ñ N
òbð( ØØ!%ñvØðvàðvð ðvð "ð	vð
 ðvð óvór	r   