From 1d4aeba034f11556f2af40adf60e678cfdb40b5a Mon Sep 17 00:00:00 2001 From: mamadoudicko Date: Wed, 6 Sep 2023 14:35:29 +0200 Subject: [PATCH 1/3] feat: remove 'ux-upload' feature flag --- .../components/ActionsBar/components/ChatInput/index.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/frontend/app/chat/[chatId]/components/ActionsBar/components/ChatInput/index.tsx b/frontend/app/chat/[chatId]/components/ActionsBar/components/ChatInput/index.tsx index e951b1777807..85be74d88afd 100644 --- a/frontend/app/chat/[chatId]/components/ActionsBar/components/ChatInput/index.tsx +++ b/frontend/app/chat/[chatId]/components/ActionsBar/components/ChatInput/index.tsx @@ -1,5 +1,4 @@ "use client"; -import { useFeature } from "@growthbook/growthbook-react"; import { useTranslation } from "react-i18next"; import { MdAddCircle, MdSend } from "react-icons/md"; @@ -25,7 +24,6 @@ export const ChatInput = ({ const { setMessage, submitQuestion, chatId, generatingAnswer, message } = useChatInput(); const { t } = useTranslation(["chat"]); - const shouldDisplayUploadButton = useFeature("ux-upload").on; const { currentBrainId } = useBrainContext(); return ( @@ -37,7 +35,7 @@ export const ChatInput = ({ }} className="sticky flex items-star bottom-0 bg-white dark:bg-black w-full flex justify-center gap-2 z-20" > - {!shouldDisplayUploadCard && shouldDisplayUploadButton && ( + {!shouldDisplayUploadCard && (
diff --git a/frontend/app/chat/[chatId]/components/ActionsBar/hooks/useKnowledgeUploader.ts b/frontend/app/chat/[chatId]/components/ActionsBar/hooks/useKnowledgeUploader.ts index 34894d1bc6f8..54b85eeb0384 100644 --- a/frontend/app/chat/[chatId]/components/ActionsBar/hooks/useKnowledgeUploader.ts +++ b/frontend/app/chat/[chatId]/components/ActionsBar/hooks/useKnowledgeUploader.ts @@ -48,7 +48,6 @@ export const useKnowledgeUploader = () => { variant: "danger", text: t("crawlFailed", { message: JSON.stringify(error), - ns: "upload", }), }); } @@ -80,7 +79,7 @@ export const useKnowledgeUploader = () => { } else { publish({ variant: "danger", - text: t("error", { message: e, ns: "upload" }), + text: t("error", { message: e }), }); } } @@ -106,11 +105,22 @@ export const useKnowledgeUploader = () => { return; } try { - await Promise.all([ - ...files.map((file) => uploadFileHandler(file, currentBrainId)), - ...urls.map((url) => crawlWebsiteHandler(url, currentBrainId)), - ]); - } catch (e: unknown) { + const uploadPromises = files.map((file) => + uploadFileHandler(file, currentBrainId) + ); + const crawlPromises = urls.map((url) => + crawlWebsiteHandler(url, currentBrainId) + ); + + await Promise.all([...uploadPromises, ...crawlPromises]); + + setContents([]); + + publish({ + variant: "success", + text: t("knowledgeUploaded"), + }); + } catch (e) { publish({ variant: "danger", text: JSON.stringify(e), diff --git a/frontend/public/locales/en/upload.json b/frontend/public/locales/en/upload.json index 9581246e7c26..4aa331eff944 100644 --- a/frontend/public/locales/en/upload.json +++ b/frontend/public/locales/en/upload.json @@ -15,5 +15,6 @@ "ohNo": "Oh no!", "selectBrainFirst": "You need to select a brain first. 🧠💡🥲", "missingNecessaryRole": "You don't have the necessary role to upload content to the selected brain. 🧠💡🥲", - "invalidFileType": "Invalid file type" + "invalidFileType": "Invalid file type", + "knowledgeUploaded": "Knowledge uploaded" } \ No newline at end of file diff --git a/frontend/public/locales/es/upload.json b/frontend/public/locales/es/upload.json index 91c9bb1cd87f..0e131fdf5376 100644 --- a/frontend/public/locales/es/upload.json +++ b/frontend/public/locales/es/upload.json @@ -15,5 +15,6 @@ "success": "Archivo subido correctamente", "title": "Subir conocimiento", "webSite": "Ingrese la URL del sitio web", - "invalidFileType": "Tipo de archivo no permitido" + "invalidFileType": "Tipo de archivo no permitido", + "knowledgeUploaded": "Conocimiento subido" } \ No newline at end of file diff --git a/frontend/public/locales/fr/upload.json b/frontend/public/locales/fr/upload.json index 41427f513703..46cfbdb60b40 100644 --- a/frontend/public/locales/fr/upload.json +++ b/frontend/public/locales/fr/upload.json @@ -15,5 +15,6 @@ "ohNo": "Oh non !", "selectBrainFirst": "Vous devez d'abord sélectionner un cerveau. 🧠💡🥲", "missingNecessaryRole": "Vous n'avez pas le rôle nécessaire pour télécharger du contenu dans le cerveau sélectionné. 🧠💡🥲", - "invalidFileType": "Type de fichier invalide" + "invalidFileType": "Type de fichier invalide", + "knowledgeUploaded": "Connaissance téléchargée" } \ No newline at end of file diff --git a/frontend/public/locales/pt-br/upload.json b/frontend/public/locales/pt-br/upload.json index 7f7e1741f883..1262e6ba67dd 100644 --- a/frontend/public/locales/pt-br/upload.json +++ b/frontend/public/locales/pt-br/upload.json @@ -15,5 +15,6 @@ "ohNo": "Oh, não!", "selectBrainFirst": "Você precisa selecionar um cérebro primeiro. 🧠💡🥲", "missingNecessaryRole": "Você não possui a função necessária para enviar conteúdo para o cérebro selecionado. 🧠💡🥲", - "invalidFileType": "Tipo de arquivo inválido" + "invalidFileType": "Tipo de arquivo inválido", + "knowledgeUploaded": "Conhecimento enviado" } \ No newline at end of file diff --git a/frontend/public/locales/ru/upload.json b/frontend/public/locales/ru/upload.json index 666899740910..e18501026846 100644 --- a/frontend/public/locales/ru/upload.json +++ b/frontend/public/locales/ru/upload.json @@ -15,5 +15,6 @@ "ohNo": "О нет!", "selectBrainFirst": "Сначала вам нужно выбрать мозг. 🧠💡🥲", "missingNecessaryRole": "У вас нет необходимой роли для загрузки контента в выбранный мозг. 🧠💡🥲", - "invalidFileType": "Неверный тип файла" + "invalidFileType": "Неверный тип файла", + "knowledgeUploaded": "Знания загружены" } diff --git a/frontend/public/locales/zh-cn/upload.json b/frontend/public/locales/zh-cn/upload.json index 3ece7aee350e..143a3c5da3d1 100644 --- a/frontend/public/locales/zh-cn/upload.json +++ b/frontend/public/locales/zh-cn/upload.json @@ -15,5 +15,6 @@ "ohNo": "不好了!", "selectBrainFirst": "你需要先选择一个大脑。 🧠💡🥲", "missingNecessaryRole": "您没有所选大脑的上传权限。 🧠💡🥲", - "invalidFileType": "文件类型不受支持" + "invalidFileType": "文件类型不受支持", + "knowledgeUploaded": "知识已上传" } \ No newline at end of file From 43505a02efae3e84b9a40a3d5d5b616b5d5a2fbe Mon Sep 17 00:00:00 2001 From: mamadoudicko Date: Wed, 6 Sep 2023 14:58:25 +0200 Subject: [PATCH 3/3] feat: hide feed card during feed process --- .../ActionsBar/components/ChatInput/index.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/app/chat/[chatId]/components/ActionsBar/components/ChatInput/index.tsx b/frontend/app/chat/[chatId]/components/ActionsBar/components/ChatInput/index.tsx index 85be74d88afd..c7ac005b8f6e 100644 --- a/frontend/app/chat/[chatId]/components/ActionsBar/components/ChatInput/index.tsx +++ b/frontend/app/chat/[chatId]/components/ActionsBar/components/ChatInput/index.tsx @@ -1,3 +1,4 @@ +/* eslint-disable max-lines */ "use client"; import { useTranslation } from "react-i18next"; import { MdAddCircle, MdSend } from "react-icons/md"; @@ -14,12 +15,14 @@ type ChatInputProps = { shouldDisplayUploadCard: boolean; feedBrain: () => void; setShouldDisplayUploadCard: (shouldDisplayUploadCard: boolean) => void; + hasContentToFeedBrain: boolean; }; export const ChatInput = ({ shouldDisplayUploadCard, feedBrain, setShouldDisplayUploadCard, + hasContentToFeedBrain, }: ChatInputProps): JSX.Element => { const { setMessage, submitQuestion, chatId, generatingAnswer, message } = useChatInput(); @@ -65,9 +68,12 @@ export const ChatInput = ({ {shouldDisplayUploadCard ? (