jenbenarye commited on
Commit
1353a4a
·
1 Parent(s): 0ac617e

fixed convo processing logic

Browse files
Files changed (1) hide show
  1. ml/kto_dataset_processor.py +3 -3
ml/kto_dataset_processor.py CHANGED
@@ -46,10 +46,10 @@ def transform_conversation(
46
  current_idx = i - 1
47
  while current_idx >= 0 and pairs < max_history_turns:
48
  # We need both user and assistant messages to form a pair
49
- if current_idx > 0 and conversation[current_idx]["role"] == "user" and conversation[current_idx-1]["role"] == "assistant":
50
  # Add the pair to history
51
- formatted_history.insert(0, conversation[current_idx-1]) # assistant
52
- formatted_history.insert(1, conversation[current_idx]) # user
53
 
54
  # Check token limit
55
  try:
 
46
  current_idx = i - 1
47
  while current_idx >= 0 and pairs < max_history_turns:
48
  # We need both user and assistant messages to form a pair
49
+ if current_idx > 0 and conversation[current_idx]["role"] == "assistant" and conversation[current_idx-1]["role"] == "user":
50
  # Add the pair to history
51
+ formatted_history.insert(0, conversation[current_idx-1]) # user
52
+ formatted_history.insert(1, conversation[current_idx]) # assistant
53
 
54
  # Check token limit
55
  try: