Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reset current conversation #556

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion public/locales/da/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@
"cloneChat": "Klon Chat",
"cloned": "Klonet",
"enterToSubmit": "Tryk Enter for at sende",
"submitPlaceholder": "Skriv en besked eller klik på [/] for opgave..."
"submitPlaceholder": "Skriv en besked eller klik på [/] for opgave...",
"resetThisConversation": "Reset This Conversation"
}
3 changes: 2 additions & 1 deletion public/locales/de/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@
"cloneChat": "Chat klonen",
"cloned": "Klonen erfolgreich",
"enterToSubmit": "Drücke Enter zum absenden",
"submitPlaceholder": "Verfasse eine Nachricht oder klicke auf [/] für gespeicherte Prompts..."
"submitPlaceholder": "Verfasse eine Nachricht oder klicke auf [/] für gespeicherte Prompts...",
"resetThisConversation": "Reset This Conversation"
}
3 changes: 2 additions & 1 deletion public/locales/en-US/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@
"cloneChat": "Clone Chat",
"cloned": "Cloned",
"enterToSubmit": "Enter to submit",
"submitPlaceholder": "Type a message or click [/] for prompts..."
"submitPlaceholder": "Type a message or click [/] for prompts...",
"resetThisConversation": "Reset This Conversation"
}
3 changes: 2 additions & 1 deletion public/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@
"cloneChat": "Clone Chat",
"cloned": "Cloned",
"enterToSubmit": "Enter to submit",
"submitPlaceholder": "Type a message or click [/] for prompts..."
"submitPlaceholder": "Type a message or click [/] for prompts...",
"resetThisConversation": "Reset This Conversation"
}
3 changes: 2 additions & 1 deletion public/locales/es/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@
"cloneChat": "Clone Chat",
"cloned": "Cloned",
"enterToSubmit": "Enter to submit",
"submitPlaceholder": "Escribe un mensaje o haz clic en [/] para prompt..."
"submitPlaceholder": "Escribe un mensaje o haz clic en [/] para prompt...",
"resetThisConversation": "Reset This Conversation"
}
3 changes: 2 additions & 1 deletion public/locales/fr/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@
"cloneChat": "Cloner la Conversation",
"cloned": "Clonée",
"enterToSubmit": "Entrée pour soumettre",
"submitPlaceholder": "Saisissez un message ou cliquez sur [/] pour des prompts..."
"submitPlaceholder": "Saisissez un message ou cliquez sur [/] pour des prompts...",
"resetThisConversation": "Reset This Conversation"
}
3 changes: 2 additions & 1 deletion public/locales/it/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@
"cloneChat": "Duplica Conversazione",
"cloned": "Duplicata",
"enterToSubmit": "Invio per inviare",
"submitPlaceholder": "Digita un messaggio o fai clic su [/] per prompt..."
"submitPlaceholder": "Digita un messaggio o fai clic su [/] per prompt...",
"resetThisConversation": "Reset This Conversation"
}
3 changes: 2 additions & 1 deletion public/locales/ja/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@
"cloneChat": "チャットのコピーを作成",
"cloned": "完了しました",
"enterToSubmit": "Enterキーを押して送信",
"submitPlaceholder": "メッセージを入力するか、[/] をクリックしてプロンプトを表示します..."
"submitPlaceholder": "メッセージを入力するか、[/] をクリックしてプロンプトを表示します...",
"resetThisConversation": "この会話をリセット"
}
3 changes: 2 additions & 1 deletion public/locales/ms/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@
"cloneChat": "Buat salinan perbualan ini",
"cloned": "Dicipta",
"enterToSubmit": "Tekan Enter untuk hantar",
"submitPlaceholder": "Taip mesej atau klik [/] untuk arahan..."
"submitPlaceholder": "Taip mesej atau klik [/] untuk arahan...",
"resetThisConversation": "Reset This Conversation"
}
3 changes: 2 additions & 1 deletion public/locales/nb/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@
"cloneChat": "Klone chat",
"cloned": "Klonet",
"enterToSubmit": "Trykk enter for å sende",
"submitPlaceholder": "Skriv en melding eller klikk på [/] for oppgave..."
"submitPlaceholder": "Skriv en melding eller klikk på [/] for oppgave...",
"resetThisConversation": "Reset This Conversation"
}
3 changes: 2 additions & 1 deletion public/locales/ro/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@
"cloneChat": "Clone Chat",
"cloned": "Clonat",
"enterToSubmit": "Intrați pentru a trimite",
"submitPlaceholder": "Tastați un mesaj sau faceți clic pe [/] pentru solicitări..."
"submitPlaceholder": "Tastați un mesaj sau faceți clic pe [/] pentru solicitări...",
"resetThisConversation": "Reset This Conversation"
}
3 changes: 2 additions & 1 deletion public/locales/ru/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@
"cloneChat": "Клонировать чат",
"cloned": "Клонировано",
"enterToSubmit": "Нажмите Enter для отправки",
"submitPlaceholder": "Напишите сообщение или нажмите [/] для подсказок..."
"submitPlaceholder": "Напишите сообщение или нажмите [/] для подсказок...",
"resetThisConversation": "Reset This Conversation"
}
3 changes: 2 additions & 1 deletion public/locales/sv/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@
"cloneChat": "Klona chatt",
"cloned": "Klonad",
"enterToSubmit": "Tryck på Enter för att skicka",
"submitPlaceholder": "Skriv ett meddelande eller klicka på [/] för uppmaning..."
"submitPlaceholder": "Skriv ett meddelande eller klicka på [/] för uppmaning...",
"resetThisConversation": "Reset This Conversation"
}
3 changes: 2 additions & 1 deletion public/locales/zh-CN/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@
"cloneChat": "创建聊天副本",
"cloned": "已创建副本",
"enterToSubmit": "按回车键提交",
"submitPlaceholder": "输入消息或点击 [/] 以使用提示词…"
"submitPlaceholder": "输入消息或点击 [/] 以使用提示词…",
"resetThisConversation": "重置当前会话"
}
3 changes: 2 additions & 1 deletion public/locales/zh-HK/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@
"cloneChat": "建立傾偈副本",
"cloned": "建立成功",
"enterToSubmit": "撳 Enter 鍵送出",
"submitPlaceholder": "輸入訊息或撳 [/] 以使用提示詞…"
"submitPlaceholder": "輸入訊息或撳 [/] 以使用提示詞…",
"resetThisConversation": "Reset This Conversation"
}
3 changes: 2 additions & 1 deletion public/locales/zh-TW/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@
"cloneChat": "建立聊天副本",
"cloned": "已建立副本",
"enterToSubmit": "按 Enter 鍵送出",
"submitPlaceholder": "輸入訊息或點選 [/] 以使用提示詞…"
"submitPlaceholder": "輸入訊息或點選 [/] 以使用提示詞…",
"resetThisConversation": "Reset This Conversation"
}
2 changes: 2 additions & 0 deletions src/components/Chat/ChatContent/ChatContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import useSubmit from '@hooks/useSubmit';
import DownloadChat from './DownloadChat';
import CloneChat from './CloneChat';
import ShareGPT from '@components/ShareGPT';
import ClearChat from './ClearChat';

const ChatContent = () => {
const inputRole = useStore((state) => state.inputRole);
Expand Down Expand Up @@ -110,6 +111,7 @@ const ChatContent = () => {
<DownloadChat saveRef={saveRef} />
<ShareGPT />
<CloneChat />
<ClearChat />
</div>
)}
</div>
Expand Down
33 changes: 33 additions & 0 deletions src/components/Chat/ChatContent/ClearChat.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import useStore from '@store/store';

import { ChatInterface } from '@type/chat';
import { _defaultSystemMessage } from '@constants/chat';

const ClearChat = React.memo(() => {
const { t } = useTranslation();

const setChats = useStore((state) => state.setChats);
const currentChatIndex = useStore((state) => state.currentChatIndex);

const clearChat = () => {
const updatedChats: ChatInterface[] = JSON.parse(
JSON.stringify(useStore.getState().chats)
);
updatedChats[currentChatIndex].messages = [{ role: 'system', content: useStore.getState().defaultSystemMessage }];
setChats(updatedChats);
};

return (
<button
className='btn btn-neutral flex gap-1'
aria-label={t('clearThisConversation') as string}
onClick={clearChat}
>
{t('resetThisConversation')}
</button>
);
});

export default ClearChat;