
    q[i              
          U d dl Z d dlZddlmZ ddlmZ ddlmZ ddlmZ dd	lmZ  ej                  d
 ej                  d      g      Z e j                  e      Zd ej                  d      ie_         e j                  e      Zddi igie_         e j                  e      Zdddiie_         e j                  e      Zdej$                  ie_         e j                  e      Zdej(                  ie_         ej*                  de       ej*                  ded       ej*                  ded       ej*                  dde       ej*                  dde       ej*                  d de      gZeej*                     ed!<    ej2                  e e       d"e#      Zej:                  j<                  d$        Zd% Z d& Z!y)'    N   )_transformers)errors)types   )pytest_helper   )	constantsgemini-2.5-flashzTell me a story in 300 words.modelcontentssystem_instructionyou are a chatbot.toolsgoogle_search_retrievalgeneration_configmax_output_tokens2   http_optionstest_count_tokens)name
parameters#test_count_tokens_vertex_custom_url404)r   r   exception_if_mldev"test_count_tokens_mldev_custom_url)r   r   exception_if_vertex)test_count_tokens_with_system_instructionznot supported)r   r   r   test_count_tokens_with_tools(test_count_tokens_with_generation_config
test_tablezmodels.count_tokens)fileglobals_for_filetest_methodr"   c                    K   | j                   j                  j                  t        j                  t        j
                         d {   }|sJ y 7 	w)Nr   )aiomodelscount_tokens_COUNT_TOKENS_PARAMSr   r   )clientresponses     d/mnt/data/GridWatch/venv/lib/python3.12/site-packages/google/genai/tests/models/test_count_tokens.py
test_asyncr.   d   sJ     ::$$11 &&1E1N1N 2  ( 
/s   AA	A

Ac                    | j                   j                  r| j                  j                  dt        j
                        }|sJ | j                  j                  dt        j
                        }|sJ | j                  j                  dt        j
                        }|sJ y | j                  j                  dt        j
                        }|sJ | j                  j                  dt        j
                        }|sJ y )Nr   r   z)publishers/google/models/gemini-2.5-flashzRprojects/vertexsdk/locations/us-central1/publishers/google/models/gemini-2.5-flashzmodels/gemini-2.5-flash)_api_clientvertexair(   r)   r*   r   )r+   	response1	response3	response4	response2s        r-   test_different_model_namesr6   l   s      ** +?+H+H + I 9**9%.. + I 9**b%.. + I 9** +?+H+H + I 9**'2F2O2O + I 9    c                    dddddigddiii}| j                   j                  rI| j                  j                  t        j
                  t        j                  |      }|j                  sJ y t        j                  t        j                        5  | j                  j                  t        j
                  t        j                  |       d d d        y # 1 sw Y   y xY w)	Nr   
extra_bodysystemInstructiontextr   user)partsrole)r   r   config)r0   r1   r(   r)   r*   r   r   total_tokenspytestraisesr   ClientError)r+   r?   r,   s      r-   test_extra_bodyrD      s    
!#%9:; $	&   }}))"((%.. * H
     	v))	* mm  $**'00 !   s   ;CC)"copyrA    r   tr   r   r   r
   _CountTokensParameters	t_contentr*   deepcopy,_COUNT_TOKENS_PARAMS_WITH_SYSTEM_INSTRUCTIONr?   _COUNT_TOKENS_PARAMS_WITH_TOOLS+_COUNT_TOKENS_PARAMS_WITH_GENERATION_CONFIG&_COUNT_TOKENS_PARAMS_VERTEX_CUSTOM_URLVERTEX_HTTP_OPTIONS%_COUNT_TOKENS_PARAMS_MLDEV_CUSTOM_URLMLDEV_HTTP_OPTIONSTestTableItemr"   list__annotations__setup__file__globals
pytestmarkmarkasyncior.   r6   rD    r7   r-   <module>r\      s)  "   "    3u33
akk9:; 
 0=t}}0 , +!++&:;7 , 3 #0$--0D"E ("-.*  & /<dmm/ + -r26 + 2 *77K)L &I111 & - )66J(K %I000 % ,  M '  M29 
  M18!
  M8*?
  M+*2
  M7*>31
D,,- > !]  	Y%	
  6r7   