From 5ec4b8e5320cf194ff63149a1d8cb44145bfca4a Mon Sep 17 00:00:00 2001 From: Faisal Amir Date: Sat, 10 Feb 2024 00:51:16 +0700 Subject: [PATCH] feat: revamp ui dropdown list model option (#1977) * feat: add modal troubleshooting guideline * resolve inconsistent message hidden * feat: revamp ui dropdown list model option * display model id and copy button * add function copy id model from dropdownlist * add info concurrently send requests to one active local model --- uikit/src/select/styles.scss | 1 + web/containers/DropdownListSidebar/index.tsx | 170 ++++++++++++++++--- web/screens/LocalServer/index.tsx | 22 +++ 3 files changed, 167 insertions(+), 26 deletions(-) diff --git a/uikit/src/select/styles.scss b/uikit/src/select/styles.scss index 6f6cd5800b..90485723ab 100644 --- a/uikit/src/select/styles.scss +++ b/uikit/src/select/styles.scss @@ -21,6 +21,7 @@ &-item { @apply hover:bg-secondary relative my-1 block w-full cursor-pointer select-none items-center rounded-sm px-4 py-2 text-sm data-[disabled]:pointer-events-none data-[disabled]:opacity-50; + @apply focus:outline-none focus-visible:outline-0; } &-trigger-viewport { diff --git a/web/containers/DropdownListSidebar/index.tsx b/web/containers/DropdownListSidebar/index.tsx index 140a1aba15..2679d6869a 100644 --- a/web/containers/DropdownListSidebar/index.tsx +++ b/web/containers/DropdownListSidebar/index.tsx @@ -14,7 +14,14 @@ import { import { atom, useAtom, useAtomValue, useSetAtom } from 'jotai' -import { MonitorIcon } from 'lucide-react' +import { + MonitorIcon, + LayoutGridIcon, + FoldersIcon, + GlobeIcon, + CheckIcon, + CopyIcon, +} from 'lucide-react' import { twMerge } from 'tailwind-merge' @@ -22,6 +29,7 @@ import { MainViewState } from '@/constants/screens' import { useActiveModel } from '@/hooks/useActiveModel' +import { useClipboard } from '@/hooks/useClipboard' import { useMainViewState } from '@/hooks/useMainViewState' import useRecommendedModel from '@/hooks/useRecommendedModel' @@ -42,6 +50,8 @@ import { export const selectedModelAtom = atom(undefined) +const engineOptions = ['Local', 'Remote'] + // TODO: Move all of the unscoped logics outside of the component const DropdownListSidebar = ({ strictedThread = true, @@ -51,13 +61,24 @@ const DropdownListSidebar = ({ const activeThread = useAtomValue(activeThreadAtom) const [selectedModel, setSelectedModel] = useAtom(selectedModelAtom) const setThreadModelParams = useSetAtom(setThreadModelParamsAtom) - + const [isTabActive, setIsTabActive] = useState(0) const { stateModel } = useActiveModel() const [serverEnabled, setServerEnabled] = useAtom(serverEnabledAtom) const { setMainViewState } = useMainViewState() const [loader, setLoader] = useState(0) const { recommendedModel, downloadedModels } = useRecommendedModel() const { updateModelParameter } = useUpdateModelParameters() + const clipboard = useClipboard({ timeout: 1000 }) + const [copyId, setCopyId] = useState('') + + const localModel = downloadedModels.filter( + (model) => model.engine === InferenceEngine.nitro + ) + const remoteModel = downloadedModels.filter( + (model) => model.engine === InferenceEngine.openai + ) + + const modelOptions = isTabActive === 0 ? localModel : remoteModel useEffect(() => { if (!activeThread) return @@ -171,48 +192,145 @@ const DropdownListSidebar = ({ -
- - Local +
+
    + {engineOptions.map((name, i) => { + return ( +
  • setIsTabActive(i)} + > + {i === 0 ? ( + + ) : ( + + )} + + {name} + +
  • + ) + })} +
+
{downloadedModels.length === 0 ? (

{`Oops, you don't have a model yet.`}

) : ( - - {downloadedModels.map((x, i) => ( - -
- {x.name} -
- - {toGibibytes(x.metadata.size)} - - {x.engine == InferenceEngine.nitro && ( - + + <> + {modelOptions.map((x, i) => ( +
+ +
+ {x.engine === InferenceEngine.openai && ( + + + + )} +
+ + {x.name} + +
+ + {toGibibytes(x.metadata.size)} + + {x.engine == InferenceEngine.nitro && ( + + )} +
+
+
+
+
+ {x.id} + {clipboard.copied && copyId === x.id ? ( + + ) : ( + { + clipboard.copy(x.id) + setCopyId(x.id) + }} + /> )}
- - ))} + ))} +
)}
-
+
+
diff --git a/web/screens/LocalServer/index.tsx b/web/screens/LocalServer/index.tsx index 65b6c85637..88a9d86bae 100644 --- a/web/screens/LocalServer/index.tsx +++ b/web/screens/LocalServer/index.tsx @@ -373,6 +373,28 @@ const LocalServerScreen = () => { )} >
+
+ + + + +

+ You can concurrently send requests to one active local model and + multiple remote models. +

+
{loadModelError && (