From 3d6cd41befac326018d8cc49c419f9a3ae4a6019 Mon Sep 17 00:00:00 2001 From: joseplayero Date: Wed, 10 Jul 2024 22:41:24 +0100 Subject: [PATCH 1/4] clean up modal logic --- src/components/Common/IndexingProgress.tsx | 2 +- src/components/Common/Modal.tsx | 49 +++---------------- src/components/File/NewDirectory.tsx | 2 +- src/components/File/NewNote.tsx | 2 +- src/components/File/RenameDirectory.tsx | 2 +- src/components/File/RenameNote.tsx | 2 +- .../Flashcard/FlashcardMenuModal.tsx | 2 +- .../Flashcard/FlashcardReviewModal.tsx | 6 +-- src/components/MainPage.tsx | 1 + .../modals/NewLocalEmbeddingModel.tsx | 2 +- .../modals/NewRemoteEmbeddingModel.tsx | 2 +- .../LLMSettings/InitialSetupLLMSettings.tsx | 2 +- .../LLMSettings/modals/CloudLLMSetup.tsx | 10 ++-- .../LLMSettings/modals/NewOllamaModel.tsx | 2 +- .../LLMSettings/modals/RemoteLLMSetup.tsx | 6 +-- 15 files changed, 24 insertions(+), 68 deletions(-) diff --git a/src/components/Common/IndexingProgress.tsx b/src/components/Common/IndexingProgress.tsx index fe37a27a..de0062d3 100644 --- a/src/components/Common/IndexingProgress.tsx +++ b/src/components/Common/IndexingProgress.tsx @@ -35,7 +35,7 @@ const IndexingProgress: React.FC = ({ isOpen={true} onClose={() => console.log("Not allowing a close for now")} hideCloseButton={true} - widthType="indexingProgress" + width="850px" >
diff --git a/src/components/Common/Modal.tsx b/src/components/Common/Modal.tsx index ba06fd3f..ce806ac0 100644 --- a/src/components/Common/Modal.tsx +++ b/src/components/Common/Modal.tsx @@ -1,63 +1,26 @@ import React, { useRef, useEffect } from "react"; +type ValidDimension = "500px" | "750px" | "300px" | "full" | "850px"; + interface ModalProps { isOpen: boolean; onClose: () => void; children: React.ReactNode; hideCloseButton?: boolean; tailwindStylesOnBackground?: string; - widthType?: ModalWidthType; + width?: ValidDimension; } -/* - * Modal is used in many places for different functions. The dimensions that newNote window - * should display is different than what settings should be. This is a wrapper to select the width - * that should be displayed. - */ -type ModalWidthType = - | "newNote" - | "newDirectory" - | "renameNote" - | "renameDirectory" - | "flashcardMode" - | "flashcardReviewMode" - | "newEmbeddingModel" - | "localLLMSetting" - | "remoteLLMSetting" - | "indexingProgress"; - -type Dimension = "[500px]" | "[750px]" | "[300px]" | "full" | "[850px]"; - -const customDimensionsMap: Record = { - newNote: "[500px]", - newDirectory: "[500px]", - renameNote: "[500px]", - renameDirectory: "[500px]", - flashcardMode: "[750px]", - flashcardReviewMode: "[300px]", - newEmbeddingModel: "[500px]", - localLLMSetting: "[500px]", - remoteLLMSetting: "[500px]", - indexingProgress: "[850px]", -}; - -const getDimension = (name: ModalWidthType | undefined): Dimension => { - if (name === undefined) { - return "full"; - } - return customDimensionsMap[name] || "full"; -}; - const ReorModal: React.FC = ({ isOpen, onClose, children, hideCloseButton, tailwindStylesOnBackground, - widthType, + width, }) => { const modalRef = useRef(null); - const widthClass = getDimension(widthType as ModalWidthType); + // const widthClass = getDimension(widthType as ModalWidthType); const handleOffClick = (event: MouseEvent) => { if (modalRef.current && !modalRef.current.contains(event.target as Node)) { @@ -82,7 +45,7 @@ const ReorModal: React.FC = ({ >
{!hideCloseButton && ( diff --git a/src/components/File/NewDirectory.tsx b/src/components/File/NewDirectory.tsx index 934abf9e..136b230e 100644 --- a/src/components/File/NewDirectory.tsx +++ b/src/components/File/NewDirectory.tsx @@ -79,7 +79,7 @@ const NewDirectoryComponent: React.FC = ({ }; return ( - +

New Directory

= ({ }; return ( - +

New Note

= ({ }; return ( - +

Rename Directory diff --git a/src/components/File/RenameNote.tsx b/src/components/File/RenameNote.tsx index 5d287c63..7bbca005 100644 --- a/src/components/File/RenameNote.tsx +++ b/src/components/File/RenameNote.tsx @@ -98,7 +98,7 @@ const RenameNoteModal: React.FC = ({ }; return ( - +

Rename Note

= ({
diff --git a/src/components/Flashcard/FlashcardReviewModal.tsx b/src/components/Flashcard/FlashcardReviewModal.tsx index a67cce2f..4b03d54e 100644 --- a/src/components/Flashcard/FlashcardReviewModal.tsx +++ b/src/components/Flashcard/FlashcardReviewModal.tsx @@ -53,11 +53,7 @@ const FlashcardReviewModal: React.FC = ({ }, [selectedFlashcardFile]); return ( - +

Flashcard Review Mode diff --git a/src/components/MainPage.tsx b/src/components/MainPage.tsx index f2fc1b9f..67c36213 100644 --- a/src/components/MainPage.tsx +++ b/src/components/MainPage.tsx @@ -198,6 +198,7 @@ const FileEditorContainer: React.FC = () => { showSimilarFiles={showSimilarFiles} // This might need to be managed differently now chatFilters={chatFilters} setChatFilters={(chatFilters: ChatFilters) => { + console.log("CALLING ADD FILE TO CHAT"); posthog.capture("add_file_to_chat", { chatFilesLength: chatFilters.files.length, }); diff --git a/src/components/Settings/EmbeddingSettings/modals/NewLocalEmbeddingModel.tsx b/src/components/Settings/EmbeddingSettings/modals/NewLocalEmbeddingModel.tsx index 590f179f..3ef64149 100644 --- a/src/components/Settings/EmbeddingSettings/modals/NewLocalEmbeddingModel.tsx +++ b/src/components/Settings/EmbeddingSettings/modals/NewLocalEmbeddingModel.tsx @@ -56,7 +56,7 @@ const NewLocalEmbeddingModelModal: React.FC<

diff --git a/src/components/Settings/EmbeddingSettings/modals/NewRemoteEmbeddingModel.tsx b/src/components/Settings/EmbeddingSettings/modals/NewRemoteEmbeddingModel.tsx index 0b35b3ca..a2770f10 100644 --- a/src/components/Settings/EmbeddingSettings/modals/NewRemoteEmbeddingModel.tsx +++ b/src/components/Settings/EmbeddingSettings/modals/NewRemoteEmbeddingModel.tsx @@ -49,7 +49,7 @@ const NewRemoteEmbeddingModelModal: React.FC<

Set up remote model

diff --git a/src/components/Settings/LLMSettings/InitialSetupLLMSettings.tsx b/src/components/Settings/LLMSettings/InitialSetupLLMSettings.tsx index 8bb54910..2195c8d7 100644 --- a/src/components/Settings/LLMSettings/InitialSetupLLMSettings.tsx +++ b/src/components/Settings/LLMSettings/InitialSetupLLMSettings.tsx @@ -60,7 +60,7 @@ const InitialSetupLLMSettings: React.FC = ({ setIsSetupModalOpen(false); fetchAndUpdateModelConfigs(); }} - widthType="newNote" + width="500px" > = ({ }; return ( - +

{LLMDisplayName} Setup @@ -96,16 +96,16 @@ const CloudLLMSetupModal: React.FC = ({ const openAIDefaultModels: OpenAILLMConfig[] = [ { - contextLength: 16385, - modelName: "gpt-3.5-turbo", + contextLength: 128000, + modelName: "gpt-4o", engine: "openai", type: "openai", apiKey: "", apiURL: "", }, { - contextLength: 128000, - modelName: "gpt-4o", + contextLength: 16385, + modelName: "gpt-3.5-turbo", engine: "openai", type: "openai", apiKey: "", diff --git a/src/components/Settings/LLMSettings/modals/NewOllamaModel.tsx b/src/components/Settings/LLMSettings/modals/NewOllamaModel.tsx index 4fc015cd..f2498809 100644 --- a/src/components/Settings/LLMSettings/modals/NewOllamaModel.tsx +++ b/src/components/Settings/LLMSettings/modals/NewOllamaModel.tsx @@ -81,7 +81,7 @@ const NewOllamaModelModal: React.FC = ({ }, []); return ( - +

New Local LLM

diff --git a/src/components/Settings/LLMSettings/modals/RemoteLLMSetup.tsx b/src/components/Settings/LLMSettings/modals/RemoteLLMSetup.tsx index 9709c764..083b75fc 100644 --- a/src/components/Settings/LLMSettings/modals/RemoteLLMSetup.tsx +++ b/src/components/Settings/LLMSettings/modals/RemoteLLMSetup.tsx @@ -66,11 +66,7 @@ const RemoteLLMSetupModal: React.FC = ({ } }; return ( - +

Remote LLM Setup

From 54b552310171a8d1575a3b41ca9b2b6226b17c84 Mon Sep 17 00:00:00 2001 From: joseplayero Date: Wed, 10 Jul 2024 23:08:52 +0100 Subject: [PATCH 2/4] remove width from being defined by modal --- .../Chat/AddContextFiltersModal.tsx | 2 +- src/components/Common/IndexingProgress.tsx | 1 - src/components/Common/Modal.tsx | 8 +--- src/components/File/NewDirectory.tsx | 2 +- src/components/File/NewNote.tsx | 2 +- src/components/File/RenameDirectory.tsx | 2 +- src/components/File/RenameNote.tsx | 2 +- .../Flashcard/FlashcardCreateModal.tsx | 2 +- .../Flashcard/FlashcardMenuModal.tsx | 1 - .../Flashcard/FlashcardReviewModal.tsx | 4 +- .../modals/NewLocalEmbeddingModel.tsx | 6 +-- .../modals/NewRemoteEmbeddingModel.tsx | 6 +-- .../LLMSettings/InitialSetupLLMSettings.tsx | 1 - .../LLMSettings/modals/CloudLLMSetup.tsx | 2 +- .../LLMSettings/modals/NewOllamaModel.tsx | 2 +- .../LLMSettings/modals/RemoteLLMSetup.tsx | 2 +- src/components/Settings/Settings.tsx | 38 ++----------------- 17 files changed, 18 insertions(+), 65 deletions(-) diff --git a/src/components/Chat/AddContextFiltersModal.tsx b/src/components/Chat/AddContextFiltersModal.tsx index aa668230..ce829344 100644 --- a/src/components/Chat/AddContextFiltersModal.tsx +++ b/src/components/Chat/AddContextFiltersModal.tsx @@ -120,7 +120,7 @@ const AddContextFiltersModal: React.FC = ({ return ( -

+

Choose specific context files or customise the RAG search

diff --git a/src/components/Common/IndexingProgress.tsx b/src/components/Common/IndexingProgress.tsx index de0062d3..05ec42ea 100644 --- a/src/components/Common/IndexingProgress.tsx +++ b/src/components/Common/IndexingProgress.tsx @@ -35,7 +35,6 @@ const IndexingProgress: React.FC = ({ isOpen={true} onClose={() => console.log("Not allowing a close for now")} hideCloseButton={true} - width="850px" >
diff --git a/src/components/Common/Modal.tsx b/src/components/Common/Modal.tsx index ce806ac0..230e5d01 100644 --- a/src/components/Common/Modal.tsx +++ b/src/components/Common/Modal.tsx @@ -1,14 +1,11 @@ import React, { useRef, useEffect } from "react"; -type ValidDimension = "500px" | "750px" | "300px" | "full" | "850px"; - interface ModalProps { isOpen: boolean; onClose: () => void; children: React.ReactNode; hideCloseButton?: boolean; tailwindStylesOnBackground?: string; - width?: ValidDimension; } const ReorModal: React.FC = ({ @@ -17,7 +14,6 @@ const ReorModal: React.FC = ({ children, hideCloseButton, tailwindStylesOnBackground, - width, }) => { const modalRef = useRef(null); // const widthClass = getDimension(widthType as ModalWidthType); @@ -41,11 +37,11 @@ const ReorModal: React.FC = ({ return (
{!hideCloseButton && ( diff --git a/src/components/File/NewDirectory.tsx b/src/components/File/NewDirectory.tsx index 136b230e..90a9c1a5 100644 --- a/src/components/File/NewDirectory.tsx +++ b/src/components/File/NewDirectory.tsx @@ -79,7 +79,7 @@ const NewDirectoryComponent: React.FC = ({ }; return ( - +

New Directory

= ({ }; return ( - +

New Note

= ({ }; return ( - +

Rename Directory diff --git a/src/components/File/RenameNote.tsx b/src/components/File/RenameNote.tsx index 7bbca005..d89bbfa1 100644 --- a/src/components/File/RenameNote.tsx +++ b/src/components/File/RenameNote.tsx @@ -98,7 +98,7 @@ const RenameNoteModal: React.FC = ({ }; return ( - +

Rename Note

= ({ return ( -
+

Select a file to generate flashcards for: = ({
diff --git a/src/components/Flashcard/FlashcardReviewModal.tsx b/src/components/Flashcard/FlashcardReviewModal.tsx index 4b03d54e..0da5a793 100644 --- a/src/components/Flashcard/FlashcardReviewModal.tsx +++ b/src/components/Flashcard/FlashcardReviewModal.tsx @@ -53,8 +53,8 @@ const FlashcardReviewModal: React.FC = ({ }, [selectedFlashcardFile]); return ( - -
+ +

Flashcard Review Mode

diff --git a/src/components/Settings/EmbeddingSettings/modals/NewLocalEmbeddingModel.tsx b/src/components/Settings/EmbeddingSettings/modals/NewLocalEmbeddingModel.tsx index 3ef64149..e59a9fcc 100644 --- a/src/components/Settings/EmbeddingSettings/modals/NewLocalEmbeddingModel.tsx +++ b/src/components/Settings/EmbeddingSettings/modals/NewLocalEmbeddingModel.tsx @@ -53,11 +53,7 @@ const NewLocalEmbeddingModelModal: React.FC< }; return ( - +

Upload and attach local model diff --git a/src/components/Settings/EmbeddingSettings/modals/NewRemoteEmbeddingModel.tsx b/src/components/Settings/EmbeddingSettings/modals/NewRemoteEmbeddingModel.tsx index a2770f10..4b39b347 100644 --- a/src/components/Settings/EmbeddingSettings/modals/NewRemoteEmbeddingModel.tsx +++ b/src/components/Settings/EmbeddingSettings/modals/NewRemoteEmbeddingModel.tsx @@ -46,11 +46,7 @@ const NewRemoteEmbeddingModelModal: React.FC< }; return ( - +

Set up remote model

diff --git a/src/components/Settings/LLMSettings/InitialSetupLLMSettings.tsx b/src/components/Settings/LLMSettings/InitialSetupLLMSettings.tsx index 2195c8d7..db6f6462 100644 --- a/src/components/Settings/LLMSettings/InitialSetupLLMSettings.tsx +++ b/src/components/Settings/LLMSettings/InitialSetupLLMSettings.tsx @@ -60,7 +60,6 @@ const InitialSetupLLMSettings: React.FC = ({ setIsSetupModalOpen(false); fetchAndUpdateModelConfigs(); }} - width="500px" > = ({ }; return ( - +

{LLMDisplayName} Setup diff --git a/src/components/Settings/LLMSettings/modals/NewOllamaModel.tsx b/src/components/Settings/LLMSettings/modals/NewOllamaModel.tsx index f2498809..6b7e362f 100644 --- a/src/components/Settings/LLMSettings/modals/NewOllamaModel.tsx +++ b/src/components/Settings/LLMSettings/modals/NewOllamaModel.tsx @@ -81,7 +81,7 @@ const NewOllamaModelModal: React.FC = ({ }, []); return ( - +

New Local LLM

diff --git a/src/components/Settings/LLMSettings/modals/RemoteLLMSetup.tsx b/src/components/Settings/LLMSettings/modals/RemoteLLMSetup.tsx index 083b75fc..e5468b7c 100644 --- a/src/components/Settings/LLMSettings/modals/RemoteLLMSetup.tsx +++ b/src/components/Settings/LLMSettings/modals/RemoteLLMSetup.tsx @@ -66,7 +66,7 @@ const RemoteLLMSetupModal: React.FC = ({ } }; return ( - +

Remote LLM Setup

diff --git a/src/components/Settings/Settings.tsx b/src/components/Settings/Settings.tsx index bf6b4344..b2aa3e6f 100644 --- a/src/components/Settings/Settings.tsx +++ b/src/components/Settings/Settings.tsx @@ -48,18 +48,8 @@ const SettingsModal: React.FC = ({ handleSave(); }} > -

-
- {/*
setActiveTab(SettingsTab.GeneralSettings)} - > - General -
*/} +
+
= ({
{/* Right Content Area */} -
+
{/*

Settings

*/} {activeTab === SettingsTab.GeneralSettings && (
@@ -155,28 +145,6 @@ const SettingsModal: React.FC = ({
)} - - {/* {activeTab === SettingsTab.RAG && ( -
-

RAG

{" "} - -

- Number of notes to feed to the LLM during Q&A -

-
- -

- Change the Chunk Size -

-
-
- )} */} - - {activeTab === SettingsTab.GeneralSettings && ( -
- -
- )}
From 7ae9fb58f3fb960064d73eb1cb823eb135516112 Mon Sep 17 00:00:00 2001 From: joseplayero Date: Wed, 10 Jul 2024 23:12:31 +0100 Subject: [PATCH 3/4] fix flashcards width --- src/components/Flashcard/FlashcardsCore.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/Flashcard/FlashcardsCore.tsx b/src/components/Flashcard/FlashcardsCore.tsx index 7a17af8f..b9c5abc9 100644 --- a/src/components/Flashcard/FlashcardsCore.tsx +++ b/src/components/Flashcard/FlashcardsCore.tsx @@ -42,8 +42,8 @@ export const FlashcardCore = ({ flipDirection="vertical" > {flashcardQAPairs[currentSelectedFlashcard].isFlipped && ( // this boolean is required to ensure that we check the flipped boolean to prevent the answer from leaking