mishig HF staff commited on
Commit
e779e06
1 Parent(s): 1189124

Stop deleteing messages in pairs automatically (#24)

Browse files

If a user breaks chat template by deleting messages erroneously, then be
it

src/lib/components/InferencePlayground/InferencePlayground.svelte CHANGED
@@ -93,13 +93,7 @@
93
 
94
  function deleteMessage(idx: number) {
95
  conversations = conversations.map((conversation) => {
96
- const deletedMsg = deleteAndGetItem<ChatCompletionInputMessage>(conversation.messages, idx);
97
- // delete messages in user/assistant pairs. otherwise, the chat template will be broken
98
- if (deletedMsg) {
99
- const { role } = deletedMsg;
100
- const pairIdx = role === 'user' ? idx : idx - 1;
101
- deleteAndGetItem<ChatCompletionInputMessage>(conversation.messages, pairIdx);
102
- }
103
  return conversation;
104
  });
105
  }
 
93
 
94
  function deleteMessage(idx: number) {
95
  conversations = conversations.map((conversation) => {
96
+ deleteAndGetItem<ChatCompletionInputMessage>(conversation.messages, idx);
 
 
 
 
 
 
97
  return conversation;
98
  });
99
  }