Skip to content

Commit

Permalink
Merge pull request #60 from sasha0552/exc-fixes
Browse files Browse the repository at this point in the history
Fix exceptions when constructing an exception messages
  • Loading branch information
patrickvonplaten authored Oct 24, 2024
2 parents 21ee9f6 + 4a1d7c2 commit 221cbf4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/mistral_common/protocol/instruct/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def _validate_message_order(self, messages: List[UATS]) -> None:

if current_role not in expected_roles:
raise InvalidMessageStructureException(
f"Unexpected role '{current_role.value}' after role '{previous_role.value}'"
f"Unexpected role '{current_role}' after role '{previous_role}'"
)

previous_role = current_role
Expand All @@ -228,15 +228,15 @@ def _validate_last_message(self, message: UATS) -> None:
if self._mode == ValidationMode.finetuning:
if last_message_role != Roles.assistant:
raise InvalidMessageStructureException(
f"Expected last role Assistant for finetuning but got {last_message_role.value}"
f"Expected last role Assistant for finetuning but got {last_message_role}"
)
else:
bad_assistant = isinstance(message, AssistantMessage) and not message.prefix
bad_role = message.role not in {Roles.user, Roles.tool}
if bad_assistant and bad_role:
raise InvalidMessageStructureException(
f"Expected last role User or Tool (or Assistant with prefix True) for serving"
f" but got {last_message_role.value}"
f" but got {last_message_role}"
)

def _validate_message_list_structure(self, messages: List[UATS]) -> None:
Expand Down

0 comments on commit 221cbf4

Please sign in to comment.