From 58966355c342f513a455c9de2420a3328ebe6d3c Mon Sep 17 00:00:00 2001 From: n4ze3m Date: Wed, 7 Feb 2024 00:11:07 +0530 Subject: [PATCH] Update dependencies and fix styling issues --- package.json | 4 +- src/background.ts | 7 +- src/components/Common/Playground/Message.tsx | 70 ++-- src/components/Option/Layout.tsx | 113 +++++++ .../Option/Playground/Playground.tsx | 89 +++++ .../Option/Playground/PlaygroundChat.tsx | 33 ++ .../Option/Playground/PlaygroundForm.tsx | 181 +++++++++++ .../Option/Playground/PlaygroundMessage.tsx | 98 ++++++ .../Option/Playground/PlaygroundNewChat.tsx | 25 ++ .../Option/Playground/PlaygroundSettings.tsx | 42 +++ src/components/Option/Sidebar.tsx | 47 +++ src/components/Sidepanel/Chat/form.tsx | 2 +- src/css/tailwind.css | 2 +- src/hooks/useMessageOption.tsx | 306 ++++++++++++++++++ src/libs/class-name.tsx | 3 + src/libs/db.ts | 111 +++++++ src/options.tsx | 2 + src/routes/index.tsx | 16 +- src/routes/option-index.tsx | 8 +- src/store/option.tsx | 62 ++++ yarn.lock | 5 + 21 files changed, 1175 insertions(+), 51 deletions(-) create mode 100644 src/components/Option/Layout.tsx create mode 100644 src/components/Option/Playground/Playground.tsx create mode 100644 src/components/Option/Playground/PlaygroundChat.tsx create mode 100644 src/components/Option/Playground/PlaygroundForm.tsx create mode 100644 src/components/Option/Playground/PlaygroundMessage.tsx create mode 100644 src/components/Option/Playground/PlaygroundNewChat.tsx create mode 100644 src/components/Option/Playground/PlaygroundSettings.tsx create mode 100644 src/components/Option/Sidebar.tsx create mode 100644 src/hooks/useMessageOption.tsx create mode 100644 src/libs/class-name.tsx create mode 100644 src/libs/db.ts create mode 100644 src/store/option.tsx diff --git a/package.json b/package.json index 06feb95..926fa77 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "axios": "^1.6.7", "html-to-text": "^9.0.5", "langchain": "^0.1.9", + "lucide-react": "^0.323.0", "plasmo": "0.84.1", "property-information": "^6.4.1", "react": "18.2.0", @@ -78,7 +79,8 @@ "scripting", "declarativeNetRequest", "declarativeNetRequestFeedback", - "action" + "action", + "unlimitedStorage" ] } } diff --git a/src/background.ts b/src/background.ts index e67032f..172269e 100644 --- a/src/background.ts +++ b/src/background.ts @@ -13,9 +13,4 @@ chrome.runtime.onMessage.addListener(async (message) => { chrome.action.onClicked.addListener((tab) => { chrome.tabs.create({url: chrome.runtime.getURL("options.html")}); -}); - -// listen to commadns -chrome.commands.onCommand.addListener((command) => { - console.log('Command', command) -}) \ No newline at end of file +}); \ No newline at end of file diff --git a/src/components/Common/Playground/Message.tsx b/src/components/Common/Playground/Message.tsx index d946b45..a469ae6 100644 --- a/src/components/Common/Playground/Message.tsx +++ b/src/components/Common/Playground/Message.tsx @@ -55,43 +55,45 @@ export const PlaygroundMessage = (props: Props) => { {/* source if aviable */} - + {props.images && ( +
+ {props.images + .filter((image) => image.length > 0) + .map((image, index) => ( +
+ Uploaded +
+ ))} +
+ )} - {props.isBot && ( -
- {!props.hideCopy && ( - - )} -
- )} + {props.isBot && ( +
+ {!props.hideCopy && ( + + )} +
+ )} + - {props.images && ( -
- {props.images - .filter((image) => image.length > 0) - .map((image, index) => ( -
- Uploaded -
- ))} -
- )} ) } diff --git a/src/components/Option/Layout.tsx b/src/components/Option/Layout.tsx new file mode 100644 index 0000000..99b9422 --- /dev/null +++ b/src/components/Option/Layout.tsx @@ -0,0 +1,113 @@ +import React, { Fragment, useState } from "react" +import { Dialog, Menu, Transition } from "@headlessui/react" +import { + Bars3BottomLeftIcon, + XMarkIcon, + TagIcon, + CircleStackIcon, + CogIcon, + ChatBubbleLeftIcon, + Bars3Icon, + Bars4Icon, + ArrowPathIcon +} from "@heroicons/react/24/outline" +import logoImage from "data-base64:~assets/icon.png" + +import { Link, useParams, useLocation, useNavigate } from "react-router-dom" +import { Sidebar } from "./Sidebar" +import { Drawer, Layout, Select } from "antd" +import { useQuery } from "@tanstack/react-query" +import { fetchModels } from "~services/ollama" +import { useMessageOption } from "~hooks/useMessageOption" +import { PanelLeftIcon, Settings2 } from "lucide-react" + +const navigation = [ + { name: "Embed", href: "/bot/:id", icon: TagIcon }, + { + name: "Preview", + href: "/bot/:id/preview", + icon: ChatBubbleLeftIcon + }, + { + name: "Data Sources", + href: "/bot/:id/data-sources", + icon: CircleStackIcon + }, + { + name: "Settings", + href: "/bot/:id/settings", + icon: CogIcon + } +] + +//@ts-ignore - +function classNames(...classes) { + return classes.filter(Boolean).join(" ") +} + +export default function OptionLayout({ + children +}: { + children: React.ReactNode +}) { + const [sidebarOpen, setSidebarOpen] = useState(false) + const params = useParams<{ id: string }>() + const location = useLocation() + + const { + data: models, + isLoading: isModelsLoading, + refetch: refetchModels, + isFetching: isModelsFetching + } = useQuery({ + queryKey: ["fetchModel"], + queryFn: fetchModels + }) + + const { selectedModel, setSelectedModel } = useMessageOption() + + return ( + +
+
+
+ +
+
+ + +