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
92 unmodified lines939495969798991001011029697989992 unmodified lines
function deleteMessage(idx: number) { conversations = conversations.map((conversation) => { const deletedMsg = deleteAndGetItem<ChatCompletionInputMessage>(conversation.messages, idx); // delete messages in user/assistant pairs. otherwise, the chat template will be broken if (deletedMsg) { const { role } = deletedMsg; const pairIdx = role === 'user' ? idx : idx - 1; deleteAndGetItem<ChatCompletionInputMessage>(conversation.messages, pairIdx); } deleteAndGetItem<ChatCompletionInputMessage>(conversation.messages, idx); return conversation; }); }src/lib/components/InferencePlayground/InferencePlayground.svelte+1-7