|
22 | 22 |
|
23 | 23 | test_table: list[pytest_helper.TestTableItem] = [ |
24 | 24 | pytest_helper.TestTableItem( |
25 | | - name='test_generate_content_thought', |
| 25 | + name='test_disable_thinking', |
26 | 26 | parameters=types._GenerateContentParameters( |
27 | | - model='gemini-2.5-pro-preview-03-25', |
| 27 | + model='gemini-2.5-flash', |
28 | 28 | contents=t.t_contents('Explain the monty hall problem.'), |
29 | 29 | config={ |
30 | 30 | 'thinking_config': { |
31 | | - 'include_thoughts': True, |
32 | | - 'thinking_budget': 10000}, |
| 31 | + 'thinking_budget': 0}, |
33 | 32 | }, |
34 | 33 | ), |
35 | 34 | ), |
36 | | - pytest_helper.TestTableItem( |
37 | | - name='test_generate_content_thought_v1alpha', |
38 | | - parameters=types._GenerateContentParameters( |
39 | | - model='gemini-2.5-pro-preview-03-25', |
40 | | - contents=t.t_contents( |
41 | | - 'What is the sum of natural numbers from 1 to 100?' |
42 | | - ), |
43 | | - config={ |
44 | | - 'thinking_config': { |
45 | | - 'include_thoughts': True, |
46 | | - 'thinking_budget': 10000 |
47 | | - }, |
48 | | - 'http_options': { |
49 | | - 'api_version': 'v1alpha' |
50 | | - }, |
51 | | - }, |
52 | | - ), |
53 | | - exception_if_vertex='404', |
54 | | - ), |
55 | 35 | ] |
56 | 36 |
|
57 | 37 |
|
|
63 | 43 | ) |
64 | 44 |
|
65 | 45 |
|
66 | | -def test_thought_signature_with_thinking_budget(client): |
67 | | - with pytest_helper.exception_if_vertex(client, errors.ClientError): |
| 46 | +def test_thinking_budget(client): |
68 | 47 | response = client.models.generate_content( |
69 | | - model='gemini-2.5-pro-preview-03-25', |
| 48 | + model='gemini-2.5-pro', |
70 | 49 | contents='What is the sum of natural numbers from 1 to 100?', |
71 | 50 | config={ |
72 | 51 | 'thinking_config': { |
73 | 52 | 'include_thoughts': True, |
74 | 53 | 'thinking_budget': 10000, |
75 | 54 | }, |
76 | | - 'http_options': {'api_version': 'v1alpha'}, |
77 | 55 | }, |
78 | 56 | ) |
79 | 57 | has_thought = False |
80 | 58 | if response.candidates: |
81 | | - for candidate in response.candidates: |
82 | | - for part in candidate.content.parts: |
83 | | - if part.thought: |
84 | | - has_thought = True |
85 | | - break |
| 59 | + for candidate in response.candidates: |
| 60 | + for part in candidate.content.parts: |
| 61 | + if part.thought: |
| 62 | + has_thought = True |
| 63 | + break |
86 | 64 | assert has_thought |
87 | | - |
88 | | - |
89 | | -def test_thought_with_include_thoughts_v1alpha(client): |
90 | | - # Thoughts have been disabled in the API. |
91 | | - with pytest_helper.exception_if_vertex(client, errors.ClientError): |
92 | | - response = client.models.generate_content( |
93 | | - model='gemini-2.0-flash-thinking-exp', |
94 | | - contents='What is the sum of natural numbers from 1 to 100?', |
95 | | - config={ |
96 | | - 'thinking_config': {'include_thoughts': True}, |
97 | | - 'http_options': {'api_version': 'v1alpha'}, |
98 | | - }, |
99 | | - ) |
100 | | - has_thought = False |
101 | | - if response.candidates: |
102 | | - for candidate in response.candidates: |
103 | | - for part in candidate.content.parts: |
104 | | - if part.thought: |
105 | | - has_thought = True |
106 | | - break |
107 | | - assert has_thought |
108 | | - |
109 | | - |
110 | | -def test_no_thought_with_default_config(client): |
111 | | - with pytest_helper.exception_if_vertex(client, errors.ClientError): |
112 | | - response = client.models.generate_content( |
113 | | - model='gemini-2.0-flash-thinking-exp', |
114 | | - contents='What is the sum of natural numbers from 1 to 100?', |
115 | | - ) |
116 | | - has_thought = False |
117 | | - for candidate in response.candidates: |
118 | | - for part in candidate.content.parts: |
119 | | - if part.thought: |
120 | | - has_thought = True |
121 | | - break |
122 | | - assert not has_thought |
0 commit comments