From d88974e1fa0376bcb6df350ee093b56e974cdd95 Mon Sep 17 00:00:00 2001 From: samlhuillier Date: Mon, 11 Dec 2023 23:24:05 +0530 Subject: [PATCH] initial work on custom select component --- src/components/Generic/Select.tsx | 47 ++++++++++++++++++ .../Settings/InitialSettingsPage.tsx | 3 -- src/components/Settings/LLMSettings.tsx | 48 ++++++++++++++----- src/components/Settings/Settings.tsx | 14 +++--- 4 files changed, 90 insertions(+), 22 deletions(-) create mode 100644 src/components/Generic/Select.tsx diff --git a/src/components/Generic/Select.tsx b/src/components/Generic/Select.tsx new file mode 100644 index 00000000..bcfc31c1 --- /dev/null +++ b/src/components/Generic/Select.tsx @@ -0,0 +1,47 @@ +import React, { useState } from "react"; + +type CustomSelectProps = { + options: string[]; + value: string; + onChange: (value: string) => void; +}; + +const CustomSelect: React.FC = ({ + options, + value, + onChange, +}) => { + const [isOpen, setIsOpen] = useState(false); + + const toggleDropdown = () => setIsOpen(!isOpen); + const handleOptionClick = (value: string) => { + onChange(value); + setIsOpen(false); + }; + + return ( +
+
+ {value} +
+ {isOpen && ( +
+ {options.map((option, index) => ( +
handleOptionClick(option)} + > + {option} +
+ ))} +
+ )} +
+ ); +}; + +export default CustomSelect; diff --git a/src/components/Settings/InitialSettingsPage.tsx b/src/components/Settings/InitialSettingsPage.tsx index 5fa9f966..613f2054 100644 --- a/src/components/Settings/InitialSettingsPage.tsx +++ b/src/components/Settings/InitialSettingsPage.tsx @@ -102,9 +102,6 @@ const DirectoryPicker: React.FC = ({ onDirectorySelected }) => { disabled placeholder="LLM Model Name" /> -

- *Models are currently pre-set (custom models are coming soon). -

Open AI Key

{ const [modelConfigs, setModelConfigs] = useState< @@ -51,16 +52,48 @@ const AIModelManager: React.FC = () => { }); }; - const handleDefaultModelChange = ( - e: React.ChangeEvent - ) => { - const selectedModel = e.target.value; + const handleDefaultModelChange = (selectedModel: string) => { + // const selectedModel = e.target.value; setDefaultModel(selectedModel); window.electronStore.setDefaultAIModel(selectedModel); }; + const modelNames = Object.keys(modelConfigs); return (
+

LLM

+ {/* */} + + + {/* */} + + {/* */} {/*

Configure LLM

*/} { {/* Default Model Dropdown */} {/*

Default AI Model

*/} -
); }; diff --git a/src/components/Settings/Settings.tsx b/src/components/Settings/Settings.tsx index 4b2739e0..41529b92 100644 --- a/src/components/Settings/Settings.tsx +++ b/src/components/Settings/Settings.tsx @@ -40,14 +40,17 @@ const SettingsModal: React.FC = ({ isOpen, onClose }) => { disabled placeholder="Embedding Model" /> -

LLM

+ {/*

LLM

+ /> */} +
+ +

Open AI Key

= ({ isOpen, onClose }) => { onKeyDown={handleKeyPress} placeholder="Open AI API Key" /> -
- -
+ -

- *Models are currently pre-set. Custom models are coming very soon :) -

);