From 0351beeaae3ec0c1cb09dcd62a27faa27a3c9b93 Mon Sep 17 00:00:00 2001 From: n4ze3m Date: Sun, 3 Mar 2024 19:55:43 +0530 Subject: [PATCH] Delete unused files and update API calls --- .../Layouts/SettingsOptionLayout.tsx | 90 ++++++++ src/components/Option/Layout.tsx | 185 ++++++++------- src/components/Option/Models/index.tsx | 6 +- .../Option/Playground/Playground.tsx | 8 +- .../Option/Playground/PlaygroundChat.tsx | 2 +- src/components/Option/Prompt/index.tsx | 4 +- src/components/Option/Settings/ollama.tsx | 211 ++++++++++-------- src/components/Option/Settings/other.tsx | 16 +- src/components/Option/Settings/prompt.tsx | 13 +- src/components/Sidepanel/Chat/empty.tsx | 2 +- src/components/Sidepanel/Settings/body.tsx | 2 +- src/options.html | 8 + src/routes/index.tsx | 12 +- ...on-model.tsx => option-settings-model.tsx} | 5 +- ...-prompt.tsx => option-settings-prompt.tsx} | 5 +- src/routes/option-settings.tsx | 13 ++ src/routes/options-settings-ollama.tsx | 13 ++ src/services/ollama.ts | 5 +- 18 files changed, 389 insertions(+), 211 deletions(-) create mode 100644 src/components/Layouts/SettingsOptionLayout.tsx create mode 100644 src/options.html rename src/routes/{option-model.tsx => option-settings-model.tsx} (58%) rename src/routes/{option-prompt.tsx => option-settings-prompt.tsx} (58%) create mode 100644 src/routes/option-settings.tsx create mode 100644 src/routes/options-settings-ollama.tsx diff --git a/src/components/Layouts/SettingsOptionLayout.tsx b/src/components/Layouts/SettingsOptionLayout.tsx new file mode 100644 index 0000000..10fde58 --- /dev/null +++ b/src/components/Layouts/SettingsOptionLayout.tsx @@ -0,0 +1,90 @@ +import { + Book, + BrainCircuit, + CircuitBoardIcon, + Orbit +} from "lucide-react" +import { Link, useLocation } from "react-router-dom" + +function classNames(...classes: string[]) { + return classes.filter(Boolean).join(" ") +} + +const LinkComponent = (item: { + href: string + name: string + icon: any + current: string +}) => { + return ( +
  • + +
  • + ) +} + +export const SettingsLayout = ({ children }: { children: React.ReactNode }) => { + const location = useLocation() + return ( + <> +
    + + +
    +
    + {children} +
    +
    +
    + + ) +} diff --git a/src/components/Option/Layout.tsx b/src/components/Option/Layout.tsx index 1fb6b7c..e998864 100644 --- a/src/components/Option/Layout.tsx +++ b/src/components/Option/Layout.tsx @@ -2,16 +2,14 @@ import React, { useState } from "react" import { useLocation, NavLink } from "react-router-dom" import { Sidebar } from "./Sidebar" -import { Drawer, Layout, Modal, Select, Tooltip } from "antd" +import { Drawer, Select, Tooltip } from "antd" import { useQuery } from "@tanstack/react-query" import { getAllModels } from "~services/ollama" import { useMessageOption } from "~hooks/useMessageOption" -import { Settings } from "./Settings" import { - Book, - BrainCircuit, ChevronLeft, CogIcon, + GithubIcon, PanelLeftIcon, SquarePen } from "lucide-react" @@ -22,7 +20,6 @@ export default function OptionLayout({ children: React.ReactNode }) { const [sidebarOpen, setSidebarOpen] = useState(false) - const [open, setOpen] = useState(false) const { data: models, @@ -38,89 +35,99 @@ export default function OptionLayout({ const { selectedModel, setSelectedModel, clearChat } = useMessageOption() return ( - -
    -
    - {pathname !== "/" && ( -
    - - - +
    +
    +
    +
    +
    + {pathname !== "/" && ( +
    + + + +
    + )} +
    + +
    +
    + +
    + + {"/"} + +
    + - option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0 || - option.value.toLowerCase().indexOf(input.toLowerCase()) >= 0 - } - showSearch - placeholder="Select a model" - className="w-64 " - options={models?.map((model) => ({ - label: model.name, - value: model.model - }))} - /> -
    -
    -
    - - - - - - {/* - - - - */} - - - - - - +
    {children}
    - {children} - - - setOpen(false)} - footer={null} - onCancel={() => setOpen(false)}> - setOpen(false)} /> - - +
    ) } diff --git a/src/components/Option/Models/index.tsx b/src/components/Option/Models/index.tsx index a7c6116..d898e66 100644 --- a/src/components/Option/Models/index.tsx +++ b/src/components/Option/Models/index.tsx @@ -22,7 +22,7 @@ export const ModelsBody = () => { const { data, status } = useQuery({ queryKey: ["fetchAllModels"], - queryFn: getAllModels + queryFn: () => getAllModels({ returnEmpty: true }) }) const { mutate: deleteOllamaModel } = useMutation({ @@ -67,8 +67,8 @@ export const ModelsBody = () => { }) return ( -
    -
    +
    +
    {/* Add new model button */}
    diff --git a/src/components/Option/Playground/Playground.tsx b/src/components/Option/Playground/Playground.tsx index fd59544..58a5446 100644 --- a/src/components/Option/Playground/Playground.tsx +++ b/src/components/Option/Playground/Playground.tsx @@ -70,17 +70,15 @@ export const Playground = () => { ref={drop} className={`${ dropState === "dragging" ? "bg-gray-100 dark:bg-gray-800 z-10" : "" - } min-h-screen`}> - + } bg-white dark:bg-[#171717]`}> +
    - +
    diff --git a/src/components/Option/Playground/PlaygroundChat.tsx b/src/components/Option/Playground/PlaygroundChat.tsx index ac0f5b0..1d7948a 100644 --- a/src/components/Option/Playground/PlaygroundChat.tsx +++ b/src/components/Option/Playground/PlaygroundChat.tsx @@ -18,7 +18,7 @@ export const PlaygroundChat = () => {
    )} - {messages.length > 0 &&
    } + {/* {messages.length > 0 &&
    } */} {messages.map((message, index) => ( { }) return ( -
    -
    +
    +
    diff --git a/src/components/Option/Settings/ollama.tsx b/src/components/Option/Settings/ollama.tsx index da5939c..08a73ca 100644 --- a/src/components/Option/Settings/ollama.tsx +++ b/src/components/Option/Settings/ollama.tsx @@ -11,6 +11,7 @@ import { saveForRag, setOllamaURL as saveOllamaURL } from "~services/ollama" +import { SettingPrompt } from "./prompt" export const SettingsOllama = () => { const [ollamaURL, setOllamaURL] = useState("") @@ -20,7 +21,7 @@ export const SettingsOllama = () => { const [ollamaURL, allModels, chunkOverlap, chunkSize, defaultEM] = await Promise.all([ getOllamaURL(), - getAllModels(), + getAllModels({returnEmpty: true}), defaultEmbeddingChunkOverlap(), defaultEmbeddingChunkSize(), defaultEmbeddingModelForRag() @@ -46,98 +47,130 @@ export const SettingsOllama = () => { }) return ( -
    +
    {status === "pending" && } {status === "success" && ( - <> +
    - - { - setOllamaURL(e.target.value) - }} - placeholder="Your Ollama URL" - className="w-full p-2 border border-gray-300 rounded-md dark:bg-[#262626] dark:text-gray-100" - /> -
    -
    - { - saveOllamaURL(ollamaURL) - }} - className="mt-2" - /> -
    - -
    { - saveRAG({ - model: data.defaultEM, - chunkSize: data.chunkSize, - overlap: data.chunkOverlap - }) - }} - initialValues={{ - chunkSize: ollamaInfo?.chunkSize, - chunkOverlap: ollamaInfo?.chunkOverlap, - defaultEM: ollamaInfo?.defaultEM - }}> - - { + setOllamaURL(e.target.value) + }} + placeholder="Your Ollama URL" + className="w-full p-2 border border-gray-300 rounded-md dark:bg-[#262626] dark:text-gray-100" + /> +
    +
    + { + saveOllamaURL(ollamaURL) + }} + className="mt-2" + /> +
    +
    + +
    +
    +

    + Configure RAG +

    +
    +
    + { + saveRAG({ + model: data.defaultEM, + chunkSize: data.chunkSize, + overlap: data.chunkOverlap + }) + }} + initialValues={{ + chunkSize: ollamaInfo?.chunkSize, + chunkOverlap: ollamaInfo?.chunkOverlap, + defaultEM: ollamaInfo?.defaultEM + }}> + +