Spaces:
Runtime error
Runtime error
Stop deleteing messages in pairs automatically (#24)
Browse filesIf 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 |
-
|
| 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 |
}
|