Allow dpo responses to have tool calls instead of content#280
Merged
connermanuel merged 2 commits intonextfrom Feb 27, 2026
Merged
Allow dpo responses to have tool calls instead of content#280connermanuel merged 2 commits intonextfrom
connermanuel merged 2 commits intonextfrom
Conversation
| if "content" not in example[key][0] and "tool_calls" not in example[key][0]: | ||
| raise InvalidFileFormatError( | ||
| message=f"The dataset is malformed, the first element of `{key}` must have a 'content' field on line {idx + 1}.", | ||
| message=f"The dataset is malformed, the first element of `{key}` must have a 'content' or 'tool_calls' field on line {idx + 1}.", |
Contributor
There was a problem hiding this comment.
the logic above feels confusing when comparing to this message. I had to think it out to realize it is correct. But I wonder if the above could be changed to be:
if ("content" in example[key][0] or "tool_calls" in example[key][0]) == False:
Is that cleaner? open to either decision.
Contributor
Author
There was a problem hiding this comment.
i think for the best readability here, we can do something like
contains_response_field = "content" in example[key][0] or "tool_calls" in example[key][0]
if not contains_response_field:
...
what do you think?
blainekasten
approved these changes
Feb 27, 2026
artek0chumak
approved these changes
Feb 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR allows DPO outputs to have tool calls instead of content.
Since the input uses existing messages validation, it already supports tool calls.
Side note: no changes are needed to together-py to support reasoning in assistant messages.