From fd1ea8f2928ec3b817e185465325d0d4723b026b Mon Sep 17 00:00:00 2001 From: Zewed Date: Wed, 18 Sep 2024 14:18:52 +0200 Subject: [PATCH] delete assistants --- .../AssistantModal/AssistantModal.module.scss | 29 ---- .../AssistantModal/AssistantModal.tsx | 151 ------------------ .../InputsStep/InputsStep.module.scss | 0 .../AssistantModal/InputsStep/InputsStep.tsx | 27 ---- .../OutputsStep/OutputsStep.module.scss | 16 -- .../OutputsStep/OutputsStep.tsx | 83 ---------- frontend/app/assistants/page.module.scss | 20 --- frontend/app/assistants/page.tsx | 109 ------------- frontend/lib/api/assistants/assistants.ts | 38 ----- 9 files changed, 473 deletions(-) delete mode 100644 frontend/app/assistants/AssistantModal/AssistantModal.module.scss delete mode 100644 frontend/app/assistants/AssistantModal/AssistantModal.tsx delete mode 100644 frontend/app/assistants/AssistantModal/InputsStep/InputsStep.module.scss delete mode 100644 frontend/app/assistants/AssistantModal/InputsStep/InputsStep.tsx delete mode 100644 frontend/app/assistants/AssistantModal/OutputsStep/OutputsStep.module.scss delete mode 100644 frontend/app/assistants/AssistantModal/OutputsStep/OutputsStep.tsx delete mode 100644 frontend/app/assistants/page.module.scss delete mode 100644 frontend/app/assistants/page.tsx diff --git a/frontend/app/assistants/AssistantModal/AssistantModal.module.scss b/frontend/app/assistants/AssistantModal/AssistantModal.module.scss deleted file mode 100644 index 5a06ee35fedd..000000000000 --- a/frontend/app/assistants/AssistantModal/AssistantModal.module.scss +++ /dev/null @@ -1,29 +0,0 @@ -@use "styles/Spacings.module.scss"; - -.modal_content_container { - padding: Spacings.$spacing05; - display: flex; - flex-direction: column; - height: 100%; - justify-content: space-between; - - .modal_content_wrapper { - display: flex; - flex-direction: column; - gap: Spacings.$spacing05; - - .message_wrapper { - display: flex; - flex-direction: column; - } - - .title { - font-weight: 600; - } - } - - .button { - display: flex; - align-self: flex-end; - } -} \ No newline at end of file diff --git a/frontend/app/assistants/AssistantModal/AssistantModal.tsx b/frontend/app/assistants/AssistantModal/AssistantModal.tsx deleted file mode 100644 index fe8988babaa8..000000000000 --- a/frontend/app/assistants/AssistantModal/AssistantModal.tsx +++ /dev/null @@ -1,151 +0,0 @@ -import { useState } from "react"; - -import { Assistant } from "@/lib/api/assistants/types"; -import { useAssistants } from "@/lib/api/assistants/useAssistants"; -import { Stepper } from "@/lib/components/AddBrainModal/components/Stepper/Stepper"; -import { StepValue } from "@/lib/components/AddBrainModal/types/types"; -import { MessageInfoBox } from "@/lib/components/ui/MessageInfoBox/MessageInfoBox"; -import { Modal } from "@/lib/components/ui/Modal/Modal"; -import { QuivrButton } from "@/lib/components/ui/QuivrButton/QuivrButton"; -import { Step } from "@/lib/types/Modal"; - -import styles from "./AssistantModal.module.scss"; -import { InputsStep } from "./InputsStep/InputsStep"; -import { OutputsStep } from "./OutputsStep/OutputsStep"; - -interface AssistantModalProps { - isOpen: boolean; - setIsOpen: (value: boolean) => void; - assistant: Assistant; -} - -export const AssistantModal = ({ - isOpen, - setIsOpen, - assistant, -}: AssistantModalProps): JSX.Element => { - const steps: Step[] = [ - { - label: "Inputs", - value: "FIRST_STEP", - }, - { - label: "Outputs", - value: "SECOND_STEP", - }, - ]; - const [currentStep, setCurrentStep] = useState("FIRST_STEP"); - const [emailOutput, setEmailOutput] = useState(true); - const [brainOutput, setBrainOutput] = useState(""); - const [files, setFiles] = useState<{ key: string; file: File | null }[]>( - assistant.inputs.files.map((fileInput) => ({ - key: fileInput.key, - file: null, - })) - ); - const { processAssistant } = useAssistants(); - - const handleFileChange = (file: File, inputKey: string) => { - setFiles((prevFiles) => - prevFiles.map((fileObj) => - fileObj.key === inputKey ? { ...fileObj, file } : fileObj - ) - ); - }; - - const handleSetIsOpen = (value: boolean) => { - if (!value) { - setCurrentStep("FIRST_STEP"); - } - setIsOpen(value); - }; - - const handleProcessAssistant = async () => { - handleSetIsOpen(false); - await processAssistant( - { - name: assistant.name, - inputs: { - files: files.map((file) => ({ - key: file.key, - value: (file.file as File).name, - })), - urls: [], - texts: [], - }, - outputs: { - email: { - activated: emailOutput, - }, - brain: { - activated: brainOutput !== "", - value: brainOutput, - }, - }, - }, - files.map((file) => file.file as File) - ); - }; - - return ( - } - > -
-
- - {currentStep === "FIRST_STEP" ? ( - -
- Expected Input - {assistant.input_description} -
-
- ) : ( - -
- Output - {assistant.output_description} -
-
- )} - {currentStep === "FIRST_STEP" ? ( - - ) : ( - - )} -
-
- {currentStep === "FIRST_STEP" ? ( - setCurrentStep("SECOND_STEP")} - disabled={!!files.find((file) => !file.file)} - /> - ) : ( - handleProcessAssistant()} - disabled={!emailOutput && brainOutput === ""} - /> - )} -
-
-
- ); -}; diff --git a/frontend/app/assistants/AssistantModal/InputsStep/InputsStep.module.scss b/frontend/app/assistants/AssistantModal/InputsStep/InputsStep.module.scss deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/frontend/app/assistants/AssistantModal/InputsStep/InputsStep.tsx b/frontend/app/assistants/AssistantModal/InputsStep/InputsStep.tsx deleted file mode 100644 index 7d348530e19d..000000000000 --- a/frontend/app/assistants/AssistantModal/InputsStep/InputsStep.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { capitalCase } from "change-case"; - -import { AssistantInputs } from "@/lib/api/assistants/types"; -import { FileInput } from "@/lib/components/ui/FileInput/FileInput"; - -interface InputsStepProps { - inputs: AssistantInputs; - onFileChange: (file: File, inputKey: string) => void; -} - -export const InputsStep = ({ - inputs, - onFileChange, -}: InputsStepProps): JSX.Element => { - return ( -
- {inputs.files.map((fileInput) => ( - onFileChange(file, fileInput.key)} - /> - ))} -
- ); -}; diff --git a/frontend/app/assistants/AssistantModal/OutputsStep/OutputsStep.module.scss b/frontend/app/assistants/AssistantModal/OutputsStep/OutputsStep.module.scss deleted file mode 100644 index b2fedc2fc510..000000000000 --- a/frontend/app/assistants/AssistantModal/OutputsStep/OutputsStep.module.scss +++ /dev/null @@ -1,16 +0,0 @@ -@use "styles/Spacings.module.scss"; - -.outputs_wrapper { - display: flex; - flex-direction: column; - gap: Spacings.$spacing03; - - .message_wrapper { - width: 100%; - } - - .brain_selector { - padding-block: Spacings.$spacing02; - max-width: 250px; - } -} \ No newline at end of file diff --git a/frontend/app/assistants/AssistantModal/OutputsStep/OutputsStep.tsx b/frontend/app/assistants/AssistantModal/OutputsStep/OutputsStep.tsx deleted file mode 100644 index 3903b1d59851..000000000000 --- a/frontend/app/assistants/AssistantModal/OutputsStep/OutputsStep.tsx +++ /dev/null @@ -1,83 +0,0 @@ -import { useMemo, useState } from "react"; - -import { formatMinimalBrainsToSelectComponentInput } from "@/app/chat/[chatId]/components/ActionsBar/components/KnowledgeToFeed/utils/formatMinimalBrainsToSelectComponentInput"; -import { Checkbox } from "@/lib/components/ui/Checkbox/Checkbox"; -import { MessageInfoBox } from "@/lib/components/ui/MessageInfoBox/MessageInfoBox"; -import { SingleSelector } from "@/lib/components/ui/SingleSelector/SingleSelector"; -import { requiredRolesForUpload } from "@/lib/config/upload"; -import { useBrainContext } from "@/lib/context/BrainProvider/hooks/useBrainContext"; - -import styles from "./OutputsStep.module.scss"; - -interface OutputsStepProps { - setEmailOutput: (value: boolean) => void; - setBrainOutput: (value: string) => void; -} - -export const OutputsStep = ({ - setEmailOutput, - setBrainOutput, -}: OutputsStepProps): JSX.Element => { - const [existingBrainChecked, setExistingBrainChecked] = - useState(false); - const [selectedBrainId, setSelectedBrainId] = useState(""); - const { allBrains } = useBrainContext(); - - const brainsWithUploadRights = formatMinimalBrainsToSelectComponentInput( - useMemo( - () => - allBrains.filter( - (brain) => - requiredRolesForUpload.includes(brain.role) && !!brain.max_files - ), - [allBrains] - ) - ); - - return ( -
- - It can take a few minutes to process. - - - { - if (existingBrainChecked) { - setBrainOutput(""); - setSelectedBrainId(""); - } - setExistingBrainChecked(!existingBrainChecked); - }} - /> - {existingBrainChecked && ( -
- { - setBrainOutput(brain); - setSelectedBrainId(brain); - }} - selectedOption={ - selectedBrainId - ? { - value: selectedBrainId, - label: allBrains.find( - (brain) => brain.id === selectedBrainId - )?.name as string, - } - : undefined - } - placeholder="Select a brain" - iconName="brain" - /> -
- )} -
- ); -}; diff --git a/frontend/app/assistants/page.module.scss b/frontend/app/assistants/page.module.scss deleted file mode 100644 index 0d475ea641b2..000000000000 --- a/frontend/app/assistants/page.module.scss +++ /dev/null @@ -1,20 +0,0 @@ -@use "styles/Spacings.module.scss"; - -.content_wrapper { - padding: Spacings.$spacing06; - display: flex; - flex-direction: column; - gap: Spacings.$spacing05; - - .assistants_grid { - display: flex; - gap: Spacings.$spacing03; - flex-wrap: wrap; - } - - .message_wrapper { - display: flex; - flex-direction: column; - gap: Spacings.$spacing02; - } -} \ No newline at end of file diff --git a/frontend/app/assistants/page.tsx b/frontend/app/assistants/page.tsx deleted file mode 100644 index fb24129b0b53..000000000000 --- a/frontend/app/assistants/page.tsx +++ /dev/null @@ -1,109 +0,0 @@ -"use client"; -import { redirect, usePathname } from "next/navigation"; -import { useEffect, useState } from "react"; - -import { Assistant } from "@/lib/api/assistants/types"; -import { useAssistants } from "@/lib/api/assistants/useAssistants"; -import { PageHeader } from "@/lib/components/PageHeader/PageHeader"; -import { BrainCard } from "@/lib/components/ui/BrainCard/BrainCard"; -import { MessageInfoBox } from "@/lib/components/ui/MessageInfoBox/MessageInfoBox"; -import { useSupabase } from "@/lib/context/SupabaseProvider"; -import { redirectToLogin } from "@/lib/router/redirectToLogin"; - -import { AssistantModal } from "./AssistantModal/AssistantModal"; -import styles from "./page.module.scss"; - -const Assistants = (): JSX.Element => { - const pathname = usePathname(); - const { session } = useSupabase(); - const [assistants, setAssistants] = useState([]); - const [assistantModalOpened, setAssistantModalOpened] = - useState(false); - const [currentAssistant, setCurrentAssistant] = useState( - null - ); - - const { getAssistants } = useAssistants(); - - useEffect(() => { - // REMOVE FOR NOW ACCESS TO QUIVR ASSISTANTS - redirect("/search"); - if (session === null) { - redirectToLogin(); - } - - void (async () => { - try { - const res = await getAssistants(); - if (res) { - setAssistants(res); - } - } catch (error) { - console.error(error); - } - })(); - }, [pathname, session]); - - return ( - <> -
- -
- -
- - A Quivr Assistant is an AI agent that apply specific processes - to an input in order to generate a usable output. - - - For now, you can try the summary assistant, that summarizes a - document and send the result by email or upload it in one of - your brains. - - But don't worry! Other assistants are cooking! -
-
- -
- - Feature still in Beta. Please provide feedbacks - on the chat below! - -
-
-
- {assistants.map((assistant) => { - return ( - { - setAssistantModalOpened(true); - setCurrentAssistant(assistant); - }} - key={assistant.name} - cardKey={assistant.name} - /> - ); - })} -
-
-
- {currentAssistant && ( - - )} - - ); -}; - -export default Assistants; diff --git a/frontend/lib/api/assistants/assistants.ts b/frontend/lib/api/assistants/assistants.ts index 7db2c0dfe267..e69de29bb2d1 100644 --- a/frontend/lib/api/assistants/assistants.ts +++ b/frontend/lib/api/assistants/assistants.ts @@ -1,38 +0,0 @@ -import { AxiosInstance } from "axios"; - -import { Assistant, ProcessAssistantRequest } from "./types"; - -export const getAssistants = async ( - axiosInstance: AxiosInstance -): Promise => { - return (await axiosInstance.get("/assistants")).data; -}; - -export const processAssistant = async ( - axiosInstance: AxiosInstance, - input: ProcessAssistantRequest, - files: File[] -): Promise => { - const formData = new FormData(); - - formData.append( - "input", - JSON.stringify({ - name: input.name, - inputs: { - files: input.inputs.files, - urls: input.inputs.urls, - texts: input.inputs.texts, - }, - outputs: input.outputs, - }) - ); - - files.forEach((file) => { - formData.append("files", file); - }); - - return ( - await axiosInstance.post("/assistant/process", formData) - ).data; -};