@@ -182,7 +182,7 @@ def test_check_jsonl_inconsistent_dataset_format(tmp_path: Path):
182182 # Create a JSONL file with inconsistent dataset formats
183183 file = tmp_path / "inconsistent_format.jsonl"
184184 content = [
185- {"messages" : [{"role" : "user" , "content" : "Hi" }]},
185+ {"messages" : [{"role" : "user" , "content" : "Hi" }, { "role" : "assistant" , "content" : "Hi! How can I help you?" } ]},
186186 {"text" : "How are you?" }, # Missing 'messages'
187187 ]
188188 with file .open ("w" ) as f :
@@ -230,6 +230,19 @@ def test_check_jsonl_non_alternating_roles(tmp_path: Path):
230230 assert "Invalid role turns" in report ["message" ]
231231
232232
233+ def test_check_jsonl_non_alternating_roles (tmp_path : Path ):
234+ # Create a JSONL file with non-alternating user/assistant roles
235+ file = tmp_path / "non_alternating_roles.jsonl"
236+ content = [{"messages" : [{"role" : "user" , "content" : "Hi" }]}]
237+ with file .open ("w" ) as f :
238+ f .write ("\n " .join (json .dumps (item ) for item in content ))
239+
240+ report = check_file (file )
241+
242+ assert not report ["is_check_passed" ]
243+ assert "At least one message with the assistant role must be present" in report ["message" ]
244+
245+
233246def test_check_jsonl_invalid_value_type (tmp_path : Path ):
234247 # Create a JSONL file with an invalid value type
235248 file = tmp_path / "invalid_value_type.jsonl"
0 commit comments