@@ -204,103 +204,32 @@ def test_nonstreaming_generate_content(
204204 assert invoke_span ["data" ][SPANDATA .GEN_AI_REQUEST_MAX_TOKENS ] == 100
205205
206206
207- # Threatened bot to generate as many cases as possible
208207@pytest .mark .parametrize (
209208 "system_instructions,expected_texts" ,
210209 [
211- ("You are a helpful assistant" , ["You are a helpful assistant" ]),
212- (
213- ["You are a translator" , "Translate to French" ],
214- ["You are a translator" , "Translate to French" ],
215- ),
216- (
217- Content (role = "user" , parts = [Part (text = "You are a helpful assistant" )]),
218- ["You are a helpful assistant" ],
219- ),
220- (
221- Content (
222- role = "user" ,
223- parts = [
224- Part (text = "You are a translator" ),
225- Part (text = "Translate to French" ),
226- ],
227- ),
228- ["You are a translator" , "Translate to French" ],
229- ),
230- (
231- {"parts" : [{"text" : "You are a helpful assistant" }], "role" : "user" },
232- ["You are a helpful assistant" ],
233- ),
234- (
235- {
236- "parts" : [
237- {"text" : "You are a translator" },
238- {"text" : "Translate to French" },
239- ],
240- "role" : "user" ,
241- },
242- ["You are a translator" , "Translate to French" ],
243- ),
244- (Part (text = "You are a helpful assistant" ), ["You are a helpful assistant" ]),
245- ({"text" : "You are a helpful assistant" }, ["You are a helpful assistant" ]),
246- (
247- [Part (text = "You are a translator" ), Part (text = "Translate to French" )],
248- ["You are a translator" , "Translate to French" ],
249- ),
250- (
251- [{"text" : "You are a translator" }, {"text" : "Translate to French" }],
252- ["You are a translator" , "Translate to French" ],
253- ),
254- (
255- [Part (text = "First instruction" ), {"text" : "Second instruction" }],
256- ["First instruction" , "Second instruction" ],
257- ),
258- (
259- {
260- "parts" : [
261- Part (text = "First instruction" ),
262- {"text" : "Second instruction" },
263- ],
264- "role" : "user" ,
265- },
266- ["First instruction" , "Second instruction" ],
267- ),
268210 (None , None ),
269211 ("" , []),
270212 ({}, []),
213+ (Content (role = "system" , parts = []), []),
271214 ({"parts" : []}, []),
272- (Content (role = "user" , parts = []), []),
215+ ("You are a helpful assistant." , ["You are a helpful assistant." ]),
216+ (Part (text = "You are a helpful assistant." ), ["You are a helpful assistant." ]),
273217 (
274- {
275- "parts" : [
276- {"text" : "Text part" },
277- {"file_data" : {"file_uri" : "gs://bucket/file.pdf" }},
278- ],
279- "role" : "user" ,
280- },
281- ["Text part" ],
218+ Content (role = "system" , parts = [Part (text = "You are a helpful assistant." )]),
219+ ["You are a helpful assistant." ],
282220 ),
221+ ({"text" : "You are a helpful assistant." }, ["You are a helpful assistant." ]),
283222 (
284- {
285- "parts" : [
286- {"text" : "First" },
287- Part (text = "Second" ),
288- {"text" : "Third" },
289- ],
290- "role" : "user" ,
291- },
292- ["First" , "Second" , "Third" ],
223+ {"parts" : [Part (text = "You are a helpful assistant." )]},
224+ ["You are a helpful assistant." ],
293225 ),
294226 (
295- {
296- "parts" : [
297- Part (text = "First" ),
298- Part (text = "Second" ),
299- Part (text = "Third" ),
300- ],
301- },
302- ["First" , "Second" , "Third" ],
227+ {"parts" : [{"text" : "You are a helpful assistant." }]},
228+ ["You are a helpful assistant." ],
303229 ),
230+ (["You are a helpful assistant." ], ["You are a helpful assistant." ]),
231+ ([Part (text = "You are a helpful assistant." )], ["You are a helpful assistant." ]),
232+ ([{"text" : "You are a helpful assistant." }], ["You are a helpful assistant." ]),
304233 ],
305234)
306235def test_generate_content_with_system_instruction (
0 commit comments