Ë
    ÷¾™hù  ã                   ó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	m
Z
 d dlmZ ddlmZ ddlmZ  G d	„ d
e«      Zy)é    )ÚListÚOptional)Ú/convert_generic_image_chunk_to_openai_image_objÚconvert_to_anthropic_image_obj)ÚAllMessageValues)ÚContentTypeÚPartType)Úsupports_reasoningé   )Ú%_gemini_convert_messages_with_history)ÚVertexGeminiConfigc                   ó~  ‡ — e Zd ZU dZdZee   ed<   dZee	   ed<   dZ
ee   ed<   dZee	   ed<   dZee   ed<   dZee   ed<   dZee	   ed	<   dZee   ed
<   	 	 	 	 	 	 	 	 ddee   dee	   dee   dee	   dee   dee   d	ee	   d
ee   ddfd„Zeˆ fd„«       Zdedefd„Zdedee   fd„Zdee   dee   fd„Zˆ xZS )ÚGoogleAIStudioGeminiConfigaî  
    Reference: https://ai.google.dev/api/rest/v1beta/GenerationConfig

    The class `GoogleAIStudioGeminiConfig` provides configuration for the Google AI Studio's Gemini API interface. Below are the parameters:

    - `temperature` (float): This controls the degree of randomness in token selection.

    - `max_output_tokens` (integer): This sets the limitation for the maximum amount of token in the text output. In this case, the default value is 256.

    - `top_p` (float): The tokens are selected from the most probable to the least probable until the sum of their probabilities equals the `top_p` value. Default is 0.95.

    - `top_k` (integer): The value of `top_k` determines how many of the most probable tokens are considered in the selection. For example, a `top_k` of 1 means the selected token is the most probable among all tokens. The default value is 40.

    - `response_mime_type` (str): The MIME type of the response. The default value is 'text/plain'. Other values - `application/json`.

    - `response_schema` (dict): Optional. Output response schema of the generated candidate text when response mime type can have schema. Schema can be objects, primitives or arrays and is a subset of OpenAPI schema. If set, a compatible response_mime_type must also be set. Compatible mimetypes: application/json: Schema for JSON response.

    - `candidate_count` (int): Number of generated responses to return.

    - `stop_sequences` (List[str]): The set of character sequences (up to 5) that will stop output generation. If specified, the API will stop at the first appearance of a stop sequence. The stop sequence will not be included as part of the response.

    Note: Please make sure to modify the default parameters as required for your use case.
    NÚtemperatureÚmax_output_tokensÚtop_pÚtop_kÚresponse_mime_typeÚresponse_schemaÚcandidate_countÚstop_sequencesÚreturnc	                 ó¤   — t        «       j                  «       }	|	j                  «       D ]%  \  }
}|
dk7  sŒ|€Œt        | j                  |
|«       Œ' y )NÚself)ÚlocalsÚcopyÚitemsÚsetattrÚ	__class__)r   r   r   r   r   r   r   r   r   Úlocals_ÚkeyÚvalues               úc/var/www/Befach/backend/env/lib/python3.12/site-packages/litellm/llms/gemini/chat/transformation.pyÚ__init__z#GoogleAIStudioGeminiConfig.__init__1   sA   € ô “(—-‘-“/ˆØ!Ÿ-™-ž/‰JˆCØf‹} Ñ!2Ü˜Ÿ™¨¨UÕ3ñ *ó    c                 ó    •— t         ‰|   «       S )N)ÚsuperÚ
get_config)Úclsr   s    €r#   r(   z%GoogleAIStudioGeminiConfig.get_configA   s   ø€ ä‰wÑ!Ó#Ð#r%   Úmodelc                 ó
   — d|v S )NÚtts© )r   r*   s     r#   Úis_model_gemini_audio_modelz6GoogleAIStudioGeminiConfig.is_model_gemini_audio_modelE   s   € Ø˜ˆ~Ðr%   c                 ó¬   — g d¢}t        |«      r"|j                  d«       |j                  d«       | j                  |«      r|j                  d«       |S )N)r   r   Ú
max_tokensÚmax_completion_tokensÚstreamÚtoolsÚtool_choiceÚ	functionsÚresponse_formatÚnÚstopÚlogprobsÚfrequency_penaltyÚ
modalitiesÚparallel_tool_callsÚweb_search_optionsÚreasoning_effortÚthinkingÚaudio)r
   Úappendr.   )r   r*   Úsupported_paramss      r#   Úget_supported_openai_paramsz6GoogleAIStudioGeminiConfig.get_supported_openai_paramsH   sS   € ò
Ðô$ ˜eÔ$Ø×#Ñ#Ð$6Ô7Ø×#Ñ# JÔ/Ø×+Ñ+¨EÔ2Ø×#Ñ# GÔ,ØÐr%   Úmessagesc                 ó²  — |D ]Ç  }|j                  d«      }|€Œt        |t        «      sŒ(g }|D ]™  }|j                  d«      dk(  sŒ|}d}d}t        |j                  d«      t        «      r)|d   j                  d«      }|d   j                  d«      }n|j                  d«      }|sŒzd|v sŒt	        ||¬«      }	t        |	«      |d<   Œ› ŒÉ t        |¬	«      S )
zR
        Google AI Studio Gemini does not support image urls in messages.
        ÚcontentNÚtypeÚ	image_urlÚurlÚformatzhttps://)rJ   )rD   )ÚgetÚ
isinstanceÚlistÚdictr   r   r   )
r   rD   ÚmessageÚ_message_contentÚ_partsÚelementÚimg_elementÚ
_image_urlrJ   Ú	image_objs
             r#   Ú_transform_messagesz.GoogleAIStudioGeminiConfig._transform_messagesb   så   € ó  ˆGØ&Ÿ{™{¨9Ó5ÐØÑ+´
Ð;KÌTÕ0RØ)+Û/GØ—{‘{ 6Ó*¨kÓ9Ø&-˜Ø48˜
Ø04˜Ü% k§o¡o°kÓ&BÄDÔIØ)4°[Ñ)A×)EÑ)EÀeÓ)L˜JØ%0°Ñ%=×%AÑ%AÀ(Ó%K™Fà)4¯©¸Ó)E˜JÚ%¨*¸
Ò*BÜ(FØ *°6ô)˜Iô !PØ$-ó!"ð (¨Ò4ñ  0ð	  ô. 5¸hÔGÐGr%   )NNNNNNNN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   ÚfloatÚ__annotations__r   Úintr   r   r   Ústrr   rN   r   r   rM   r$   Úclassmethodr(   Úboolr.   r   rC   r   r   rV   Ú__classcell__)r   s   @r#   r   r      st  ø… ñð0 $(€K˜%‘Ó'Ø'+Ðx ‘}Ó+Ø!€Eˆ8E‰?Ó!Ø€Eˆ8C‰=ÓØ(,Ð˜ ™Ó,Ø&*€OX˜d‘^Ó*Ø%)€OX˜c‘]Ó)Ø%)€NH˜T‘NÓ)ð (,Ø+/Ø!%Ø#Ø,0Ø*.Ø)-Ø)-ñ4à˜e‘_ð4ð $ C™=ð4ð ˜‰ð	4ð
 ˜‰}ð4ð % S™Mð4ð " $™ð4ð " #™ð4ð ! ™ð4ð 
ó4ð  ó$ó ð$ð°ð ¸ó ð °ð  ¸¸c¹ó  ð4HØÐ-Ñ.ðHà	ˆkÑ	÷Hr%   r   N)Útypingr   r   Ú3litellm.litellm_core_utils.prompt_templates.factoryr   r   Úlitellm.types.llms.openair   Úlitellm.types.llms.vertex_air   r	   Úlitellm.utilsr
   Úvertex_ai.gemini.transformationr   Ú3vertex_ai.gemini.vertex_and_google_ai_studio_geminir   r   r-   r%   r#   ú<module>ri      s/   ðß !÷õ 7ß >Ý ,å TÝ UôpHÐ!3õ pHr%   