@@ -276,25 +276,30 @@ def test_get_prompt_with_placeholders():
276276 "Help me with coding" ,
277277 ], # None = placeholder
278278 ),
279- # 5. Placeholder with non-list value (should log warning and create invalid dict )
279+ # 5. Placeholder with non-list value (should log warning and append as string )
280280 (
281281 {"role" : "helpful" , "task" : "coding" },
282282 {"examples" : "not a list" },
283283 3 ,
284284 [
285285 "You are a helpful assistant" ,
286- "{' not a list'} " , # Invalid dict becomes string when checked
286+ "not a list" , # String value appended directly
287287 "Help me with coding" ,
288288 ],
289289 ),
290290 # 6. Placeholder with invalid message structure (should log warning and include both)
291291 (
292292 {"role" : "helpful" , "task" : "coding" },
293- {"examples" : ["invalid message" , {"role" : "user" , "content" : "valid message" }]},
293+ {
294+ "examples" : [
295+ "invalid message" ,
296+ {"role" : "user" , "content" : "valid message" },
297+ ]
298+ },
294299 4 ,
295300 [
296301 "You are a helpful assistant" ,
297- "{ \" ['invalid message', {'role': 'user', 'content': 'valid message'}]\" } " , # Invalid structure becomes string
302+ "['invalid message', {'role': 'user', 'content': 'valid message'}]" , # Invalid structure becomes string
298303 "valid message" , # Valid message processed normally
299304 "Help me with coding" ,
300305 ],
@@ -330,9 +335,9 @@ def test_compile_with_placeholders(
330335 if expected_content is None :
331336 # This should be an unresolved placeholder
332337 assert "type" in result [i ] and result [i ]["type" ] == "placeholder"
333- elif expected_content . startswith ( "{" ) and expected_content . endswith ( "}" ):
334- # This is an invalid dictionary that becomes a string representation
335- assert str ( result [i ]) == expected_content
338+ elif isinstance ( result [ i ], str ):
339+ # This is a string value from invalid placeholder
340+ assert result [i ] == expected_content
336341 else :
337342 # This should be a regular message
338343 assert "content" in result [i ]
0 commit comments