@@ -154,7 +154,7 @@ def test_streaming_with_python_native_no_afc_config(client):
154154 return
155155 with pytest .raises (ValueError ) as e :
156156 for chunk in client .models .generate_content_stream (
157- model = 'gemini-2.5 -pro' ,
157+ model = 'gemini-3 -pro-preview ' ,
158158 contents = generate_content_prompt ,
159159 config = types .GenerateContentConfig (
160160 tools = [
@@ -179,55 +179,36 @@ def test_streaming_with_python_afc_disabled_false(client):
179179 return
180180 with pytest .raises (ValueError ) as e :
181181 for chunk in client .models .generate_content_stream (
182- model = 'gemini-2.5-pro' ,
183- contents = 'What is the price of GOOG? And what is the weather in Boston?' ,
184- config = types .GenerateContentConfig (
185- tools = [
186- test_generate_content_tools .get_weather ,
187- test_generate_content_tools .get_stock_price ,
188- ],
189- automatic_function_calling = types .AutomaticFunctionCallingConfig (
190- disable = False ,
191- ),
192- tool_config = types .ToolConfig (
193- function_calling_config = {
194- 'stream_function_call_arguments' : True ,
195- }
196- ),
197- ),
198- ):
199- pass
200- assert 'not compatible with automatic function calling (AFC)' in str (e .value )
201-
202-
203- def test_streaming_with_json_parameters_without_history (client ):
204- """Tests streaming function calls with FunctionDeclaration withJSON parameters."""
205-
206- with pytest_helper .exception_if_mldev (client , ValueError ):
207- for chunk in client .models .generate_content_stream (
208- model = 'gemini-2.5-pro' ,
209- contents = generate_content_prompt ,
182+ model = 'gemini-3-pro-preview' ,
183+ contents = (
184+ 'What is the price of GOOG? And what is the weather in Boston?'
185+ ),
210186 config = types .GenerateContentConfig (
211- tools = [{'function_declarations' : json_function_declarations }],
187+ tools = [
188+ test_generate_content_tools .get_weather ,
189+ test_generate_content_tools .get_stock_price ,
190+ ],
191+ automatic_function_calling = types .AutomaticFunctionCallingConfig (
192+ disable = False ,
193+ ),
212194 tool_config = types .ToolConfig (
213195 function_calling_config = {
214196 'stream_function_call_arguments' : True ,
215197 }
216198 ),
217199 ),
218200 ):
219- assert chunk is not None
220- assert chunk .candidates is not None
221- assert chunk .candidates [0 ].content is not None
222- assert chunk .candidates [0 ].content .parts is not None
201+ pass
202+ assert 'not compatible with automatic function calling (AFC)' in str (e .value )
223203
224204
225- def test_streaming_with_json_parameters_with_history (client ):
205+ def test_streaming_with_json_parameters_without_history (client ):
226206 """Tests streaming function calls with FunctionDeclaration withJSON parameters."""
207+
227208 with pytest_helper .exception_if_mldev (client , ValueError ):
228209 for chunk in client .models .generate_content_stream (
229- model = 'gemini-2.5 -pro' ,
230- contents = previous_generate_content_history ,
210+ model = 'gemini-3 -pro-preview ' ,
211+ contents = generate_content_prompt ,
231212 config = types .GenerateContentConfig (
232213 tools = [{'function_declarations' : json_function_declarations }],
233214 tool_config = types .ToolConfig (
@@ -242,12 +223,13 @@ def test_streaming_with_json_parameters_with_history(client):
242223 assert chunk .candidates [0 ].content is not None
243224 assert chunk .candidates [0 ].content .parts is not None
244225
226+
245227@pytest .mark .asyncio
246228async def test_streaming_with_json_parameters_async (client ):
247229 """Tests streaming function calls with FunctionDeclaration withJSON parameters."""
248230 with pytest_helper .exception_if_mldev (client , ValueError ):
249231 async for chunk in await client .aio .models .generate_content_stream (
250- model = 'gemini-2.5 -pro' ,
232+ model = 'gemini-3 -pro-preview ' ,
251233 contents = generate_content_prompt ,
252234 config = types .GenerateContentConfig (
253235 tools = [{'function_declarations' : json_function_declarations }],
@@ -268,7 +250,7 @@ def test_streaming_with_gemini_parameters_without_history(client):
268250 """Tests streaming function calls with FunctionDeclaration withJSON parameters."""
269251 with pytest_helper .exception_if_mldev (client , ValueError ):
270252 for chunk in client .models .generate_content_stream (
271- model = 'gemini-2.5 -pro' ,
253+ model = 'gemini-3 -pro-preview ' ,
272254 contents = generate_content_prompt ,
273255 config = types .GenerateContentConfig (
274256 tools = [{
@@ -291,7 +273,7 @@ def test_streaming_with_gemini_parameters_with_response(client):
291273 with pytest_helper .exception_if_mldev (client , ValueError ):
292274 streaming_function_call_content = []
293275 for chunk in client .models .generate_content_stream (
294- model = 'gemini-2.5 -pro' ,
276+ model = 'gemini-3 -pro-preview ' ,
295277 contents = [
296278 types .Content (
297279 role = 'user' ,
@@ -335,7 +317,7 @@ def test_streaming_with_gemini_parameters_with_response(client):
335317 )
336318
337319 for chunk in client .models .generate_content_stream (
338- model = 'gemini-2.5 -pro' ,
320+ model = 'gemini-3 -pro-preview ' ,
339321 contents = streaming_function_call_content ,
340322 config = types .GenerateContentConfig (
341323 tools = [{'function_declarations' : json_function_declarations }],
@@ -348,41 +330,41 @@ def test_streaming_with_gemini_parameters_with_response(client):
348330 ):
349331 pass
350332
351- def test_streaming_with_gemini_parameters_with_history (client ):
352- """Tests streaming function calls with FunctionDeclaration withJSON parameters."""
353- with pytest_helper .exception_if_mldev (client , ValueError ):
354- for chunk in client .models .generate_content_stream (
355- model = 'gemini-2.5-pro' ,
356- contents = previous_generate_content_history ,
357- config = types .GenerateContentConfig (
358- tools = [{
359- 'function_declarations' : gemini_function_declarations
360- }],
361- tool_config = types .ToolConfig (
362- function_calling_config = {
363- 'stream_function_call_arguments' : True ,
364- }
365- ),
366- ),
367- ):
368- assert chunk is not None
369- assert chunk .candidates is not None
370- assert chunk .candidates [0 ].content is not None
371- assert chunk .candidates [0 ].content .parts is not None
372-
373333def test_chat_streaming_with_json_parameters_with_history (client ):
374334 """Tests streaming function calls with FunctionDeclaration withJSON parameters."""
375335 with pytest_helper .exception_if_mldev (client , ValueError ):
376- messages = [
377- """
378- get the current weather in boston in celsius, the country is U.S., the purpose is to know what to wear today.
379- """ ,
380- """
381- get the current weather in new brunswick in celsius, the country is U.S., the purpose is to know what to prepare an event today.
382- """ ,
336+ test_parts = [
337+ types .Part (
338+ text = (
339+ 'get the current weather in boston in celsius, the'
340+ ' country should be US, the purpose is to know'
341+ ' what to wear today?'
342+ )
343+ ),
344+ types .Part .from_function_response (
345+ name = 'get_current_weather' ,
346+ response = {
347+ 'temperature' : 21 ,
348+ 'unit' : 'C' ,
349+ },
350+ ),
351+ types .Part (
352+ text = (
353+ 'get the current weather in new brunswick in celsius, the'
354+ ' country should be US, the purpose is to know'
355+ ' what to prepare an event today?'
356+ )
357+ ),
358+ types .Part .from_function_response (
359+ name = 'get_current_weather' ,
360+ response = {
361+ 'temperature' : 21 ,
362+ 'unit' : 'C' ,
363+ },
364+ ),
383365 ]
384366 chat = client .chats .create (
385- model = 'gemini-2.5 -pro' ,
367+ model = 'gemini-3 -pro-preview ' ,
386368 history = previous_generate_content_history ,
387369 config = types .GenerateContentConfig (
388370 tools = [{
@@ -395,7 +377,7 @@ def test_chat_streaming_with_json_parameters_with_history(client):
395377 ),
396378 ),
397379 )
398- for message in messages :
380+ for message in test_parts :
399381 result = chat .send_message_stream (message )
400382 for chunk in result :
401383 assert chunk is not None
@@ -409,17 +391,39 @@ def test_chat_streaming_with_json_parameters_with_history(client):
409391@pytest .mark .asyncio
410392async def test_chat_streaming_with_json_parameters_with_history_async (client ):
411393 """Tests streaming function calls with FunctionDeclaration withJSON parameters."""
412- messages = [
413- """
414- get the current weather in boston in celsius, the country is U.S., the purpose is to know what to wear today.
415- """ ,
416- """
417- get the current weather in new brunswick in celsius, the country is U.S., the purpose is to know what to prepare an event today.
418- """ ,
394+ test_parts = [
395+ types .Part (
396+ text = (
397+ 'get the current weather in boston in celsius, the'
398+ ' country should be US, the purpose is to know'
399+ ' what to wear today?'
400+ )
401+ ),
402+ types .Part .from_function_response (
403+ name = 'get_current_weather' ,
404+ response = {
405+ 'temperature' : 21 ,
406+ 'unit' : 'C' ,
407+ },
408+ ),
409+ types .Part (
410+ text = (
411+ 'get the current weather in new brunswick in celsius, the'
412+ ' country should be US, the purpose is to know'
413+ ' what to prepare an event today?'
414+ )
415+ ),
416+ types .Part .from_function_response (
417+ name = 'get_current_weather' ,
418+ response = {
419+ 'temperature' : 21 ,
420+ 'unit' : 'C' ,
421+ },
422+ ),
419423 ]
420424 with pytest_helper .exception_if_mldev (client , ValueError ):
421425 chat = client .aio .chats .create (
422- model = 'gemini-2.5 -pro' ,
426+ model = 'gemini-3 -pro-preview ' ,
423427 history = previous_generate_content_history ,
424428 config = types .GenerateContentConfig (
425429 tools = [{'function_declarations' : gemini_function_declarations }],
@@ -430,13 +434,9 @@ async def test_chat_streaming_with_json_parameters_with_history_async(client):
430434 ),
431435 ),
432436 )
433- async for chunk in await chat .send_message_stream (messages [0 ]):
434- assert chunk is not None
435- assert chunk .candidates is not None
436- assert chunk .candidates [0 ].content is not None
437- assert chunk .candidates [0 ].content .parts is not None
438- async for chunk in await chat .send_message_stream (messages [1 ]):
439- assert chunk is not None
440- assert chunk .candidates is not None
441- assert chunk .candidates [0 ].content is not None
442- assert chunk .candidates [0 ].content .parts is not None
437+ for message in test_parts :
438+ async for chunk in await chat .send_message_stream (message ):
439+ assert chunk is not None
440+ assert chunk .candidates is not None
441+ assert chunk .candidates [0 ].content is not None
442+ assert chunk .candidates [0 ].content .parts is not None
0 commit comments