From 84e03f44ad3f9f37b98486789f3bc5fe859318e4 Mon Sep 17 00:00:00 2001 From: mamadoudicko Date: Wed, 16 Aug 2023 10:43:59 +0200 Subject: [PATCH] feat: add brain missing message --- frontend/app/chat/[chatId]/hooks/useChat.ts | 11 ++++++++++- frontend/public/locales/en/chat.json | 3 ++- frontend/public/locales/es/chat.json | 3 ++- frontend/public/locales/fr/chat.json | 3 ++- frontend/public/locales/pt-br/chat.json | 3 ++- frontend/public/locales/ru/chat.json | 3 ++- 6 files changed, 20 insertions(+), 6 deletions(-) diff --git a/frontend/app/chat/[chatId]/hooks/useChat.ts b/frontend/app/chat/[chatId]/hooks/useChat.ts index 0ff669e5de8f..65c8255a1e71 100644 --- a/frontend/app/chat/[chatId]/hooks/useChat.ts +++ b/frontend/app/chat/[chatId]/hooks/useChat.ts @@ -45,6 +45,15 @@ export const useChat = () => { setChatId(currentChatId); } + if (currentBrain?.id === undefined) { + publish({ + variant: "danger", + text: t("missing_brain"), + }); + + return; + } + void track("QUESTION_ASKED"); const chatConfig = getChatConfigFromLocalStorage(currentChatId); @@ -53,7 +62,7 @@ export const useChat = () => { question, temperature: chatConfig?.temperature, max_tokens: chatConfig?.maxTokens, - brain_id: currentBrain?.id, + brain_id: currentBrain.id, }; await addStreamQuestion(currentChatId, chatQuestion); diff --git a/frontend/public/locales/en/chat.json b/frontend/public/locales/en/chat.json index 301c82a7191f..0414b2f8af15 100644 --- a/frontend/public/locales/en/chat.json +++ b/frontend/public/locales/en/chat.json @@ -31,5 +31,6 @@ "chat_title_intro": "Chat with your", "empty_brain_title_prefix": "Upload files in a", "empty_brain_title_suffix": "and chat with them", - "actions_bar_placeholder": "Ask a question to @brains or /files and choose your #prompt" + "actions_bar_placeholder": "Ask a question to @brains or /files and choose your #prompt", + "missing_brain": "Please select a brain to chat with" } \ No newline at end of file diff --git a/frontend/public/locales/es/chat.json b/frontend/public/locales/es/chat.json index a5755f222c58..ba0a27d3824b 100644 --- a/frontend/public/locales/es/chat.json +++ b/frontend/public/locales/es/chat.json @@ -32,5 +32,6 @@ "shortcut_select_file": "/: Seleccionar un archivo para hablar", "subtitle": "Habla con un modelo de lenguaje acerca de tus datos subidos", "thinking": "Pensando...", - "title": "Conversa con {{brain}}" + "title": "Conversa con {{brain}}", + "missing_brain": "No hay cerebro seleccionado" } \ No newline at end of file diff --git a/frontend/public/locales/fr/chat.json b/frontend/public/locales/fr/chat.json index 4391b53d6191..c56c7a8dbd0b 100644 --- a/frontend/public/locales/fr/chat.json +++ b/frontend/public/locales/fr/chat.json @@ -32,5 +32,6 @@ "shortcut_select_file": "/: Sélectionner un fichier pour discuter", "subtitle": "Parlez à un modèle linguistique de vos données téléchargées", "thinking": "Réflexion...", - "title": "Discuter avec {{brain}}" + "title": "Discuter avec {{brain}}", + "missing_brain": "Veuillez selectionner un cerveau pour discuter" } \ No newline at end of file diff --git a/frontend/public/locales/pt-br/chat.json b/frontend/public/locales/pt-br/chat.json index 3970e47c8b60..afcb1a00dd15 100644 --- a/frontend/public/locales/pt-br/chat.json +++ b/frontend/public/locales/pt-br/chat.json @@ -32,5 +32,6 @@ "shortcut_select_file": "/: Selecione um arquivo para conversar", "subtitle": "Converse com um modelo de linguagem sobre seus dados enviados", "thinking": "Pensando...", - "title": "Converse com {{brain}}" + "title": "Converse com {{brain}}", + "missing_brain": "Cérebro não encontrado" } \ No newline at end of file diff --git a/frontend/public/locales/ru/chat.json b/frontend/public/locales/ru/chat.json index 277a9cd0083c..0b00ab3356f9 100644 --- a/frontend/public/locales/ru/chat.json +++ b/frontend/public/locales/ru/chat.json @@ -32,5 +32,6 @@ "shortcut_select_file": "/: Выберите файл для общения", "subtitle": "Общайтесь с языковой моделью о ваших загруженных данных", "thinking": "Думаю...", - "title": "Чат с {{brain}}" + "title": "Чат с {{brain}}", + "missing_brain": "Мозг не найден" } \ No newline at end of file