diff --git a/web/.prettierignore b/web/.prettierignore new file mode 100644 index 000000000..02d9145c1 --- /dev/null +++ b/web/.prettierignore @@ -0,0 +1,5 @@ +.next/ +node_modules/ +dist/ +*.hbs +*.mdx \ No newline at end of file diff --git a/web/.prettierrc b/web/.prettierrc new file mode 100644 index 000000000..933d88d62 --- /dev/null +++ b/web/.prettierrc @@ -0,0 +1,8 @@ +{ + "semi": false, + "singleQuote": true, + "quoteProps": "consistent", + "trailingComma": "es5", + "endOfLine": "lf", + "plugins": ["prettier-plugin-tailwindcss"] +} diff --git a/web/app/_components/ActiveModelTable/index.tsx b/web/app/_components/ActiveModelTable/index.tsx index 72951e33d..eae2ed565 100644 --- a/web/app/_components/ActiveModelTable/index.tsx +++ b/web/app/_components/ActiveModelTable/index.tsx @@ -1,19 +1,19 @@ -import { useAtomValue } from "jotai"; -import React from "react"; -import ModelTable from "../ModelTable"; -import { activeAssistantModelAtom } from "@/_helpers/atoms/Model.atom"; +import { useAtomValue } from 'jotai' +import React from 'react' +import ModelTable from '../ModelTable' +import { activeAssistantModelAtom } from '@/_helpers/atoms/Model.atom' const ActiveModelTable: React.FC = () => { - const activeModel = useAtomValue(activeAssistantModelAtom); + const activeModel = useAtomValue(activeAssistantModelAtom) - if (!activeModel) return null; + if (!activeModel) return null return (
-

Active Model(s)

+

Active Model(s)

- ); -}; + ) +} -export default ActiveModelTable; +export default ActiveModelTable diff --git a/web/app/_components/AvailableModelCard/index.tsx b/web/app/_components/AvailableModelCard/index.tsx index dc48cab95..8d69b2880 100644 --- a/web/app/_components/AvailableModelCard/index.tsx +++ b/web/app/_components/AvailableModelCard/index.tsx @@ -1,16 +1,16 @@ -import DownloadModelContent from "../DownloadModelContent"; -import ModelDownloadButton from "../ModelDownloadButton"; -import ModelDownloadingButton from "../ModelDownloadingButton"; -import { useAtomValue } from "jotai"; -import { modelDownloadStateAtom } from "@/_helpers/atoms/DownloadState.atom"; -import { AssistantModel } from "@/_models/AssistantModel"; +import DownloadModelContent from '../DownloadModelContent' +import ModelDownloadButton from '../ModelDownloadButton' +import ModelDownloadingButton from '../ModelDownloadingButton' +import { useAtomValue } from 'jotai' +import { modelDownloadStateAtom } from '@/_helpers/atoms/DownloadState.atom' +import { AssistantModel } from '@/_models/AssistantModel' type Props = { - model: AssistantModel; - isRecommend: boolean; - required?: string; - onDownloadClick?: (model: AssistantModel) => void; -}; + model: AssistantModel + isRecommend: boolean + required?: string + onDownloadClick?: (model: AssistantModel) => void +} const AvailableModelCard: React.FC = ({ model, @@ -18,36 +18,36 @@ const AvailableModelCard: React.FC = ({ required, onDownloadClick, }) => { - const downloadState = useAtomValue(modelDownloadStateAtom); + const downloadState = useAtomValue(modelDownloadStateAtom) - let isDownloading = false; - let total = 0; - let transferred = 0; + let isDownloading = false + let total = 0 + let transferred = 0 if (model._id && downloadState[model._id]) { isDownloading = downloadState[model._id].error == null && - downloadState[model._id].percent < 1; + downloadState[model._id].percent < 1 if (isDownloading) { - total = downloadState[model._id].size.total; - transferred = downloadState[model._id].size.transferred; + total = downloadState[model._id].size.total + transferred = downloadState[model._id].size.transferred } } const downloadButton = isDownloading ? ( -
+
) : ( -
+
onDownloadClick?.(model)} />
- ); + ) return ( -
-
+
+
= ({
{/* */}
- ); -}; + ) +} -export default AvailableModelCard; +export default AvailableModelCard diff --git a/web/app/_components/BasicPromptAccessories/index.tsx b/web/app/_components/BasicPromptAccessories/index.tsx index 11dbf8be6..bb68cdcc1 100644 --- a/web/app/_components/BasicPromptAccessories/index.tsx +++ b/web/app/_components/BasicPromptAccessories/index.tsx @@ -1,14 +1,14 @@ -"use client"; +'use client' -import { useSetAtom } from "jotai"; -import { InformationCircleIcon } from "@heroicons/react/24/outline"; -import SendButton from "../SendButton"; -import { showingAdvancedPromptAtom } from "@/_helpers/atoms/Modal.atom"; +import { useSetAtom } from 'jotai' +import { InformationCircleIcon } from '@heroicons/react/24/outline' +import SendButton from '../SendButton' +import { showingAdvancedPromptAtom } from '@/_helpers/atoms/Modal.atom' const BasicPromptAccessories: React.FC = () => { - const setShowingAdvancedPrompt = useSetAtom(showingAdvancedPromptAtom); + const setShowingAdvancedPrompt = useSetAtom(showingAdvancedPromptAtom) - const shouldShowAdvancedPrompt = false; + const shouldShowAdvancedPrompt = false return (
@@ -27,7 +27,7 @@ const BasicPromptAccessories: React.FC = () => {
- ); -}; + ) +} -export default BasicPromptAccessories; +export default BasicPromptAccessories diff --git a/web/app/_components/BasicPromptButton/index.tsx b/web/app/_components/BasicPromptButton/index.tsx index 898c38d10..58bc6abc4 100644 --- a/web/app/_components/BasicPromptButton/index.tsx +++ b/web/app/_components/BasicPromptButton/index.tsx @@ -1,20 +1,20 @@ -import React from "react"; -import { useSetAtom } from "jotai"; -import { ChevronLeftIcon } from "@heroicons/react/24/outline"; -import { showingAdvancedPromptAtom } from "@/_helpers/atoms/Modal.atom"; +import React from 'react' +import { useSetAtom } from 'jotai' +import { ChevronLeftIcon } from '@heroicons/react/24/outline' +import { showingAdvancedPromptAtom } from '@/_helpers/atoms/Modal.atom' const BasicPromptButton: React.FC = () => { - const setShowingAdvancedPrompt = useSetAtom(showingAdvancedPromptAtom); + const setShowingAdvancedPrompt = useSetAtom(showingAdvancedPromptAtom) return ( - ); -}; + ) +} -export default React.memo(BasicPromptButton); +export default React.memo(BasicPromptButton) diff --git a/web/app/_components/BasicPromptInput/index.tsx b/web/app/_components/BasicPromptInput/index.tsx index 38df07895..d6e2f2d83 100644 --- a/web/app/_components/BasicPromptInput/index.tsx +++ b/web/app/_components/BasicPromptInput/index.tsx @@ -1,71 +1,71 @@ -"use client"; +'use client' -import { currentPromptAtom } from "@/_helpers/JotaiWrapper"; -import { getActiveConvoIdAtom } from "@/_helpers/atoms/Conversation.atom"; -import { selectedModelAtom } from "@/_helpers/atoms/Model.atom"; -import useCreateConversation from "@/_hooks/useCreateConversation"; -import useInitModel from "@/_hooks/useInitModel"; -import useSendChatMessage from "@/_hooks/useSendChatMessage"; -import { useAtom, useAtomValue } from "jotai"; -import { ChangeEvent, useEffect, useRef } from "react"; +import { currentPromptAtom } from '@/_helpers/JotaiWrapper' +import { getActiveConvoIdAtom } from '@/_helpers/atoms/Conversation.atom' +import { selectedModelAtom } from '@/_helpers/atoms/Model.atom' +import useCreateConversation from '@/_hooks/useCreateConversation' +import useInitModel from '@/_hooks/useInitModel' +import useSendChatMessage from '@/_hooks/useSendChatMessage' +import { useAtom, useAtomValue } from 'jotai' +import { ChangeEvent, useEffect, useRef } from 'react' const BasicPromptInput: React.FC = () => { - const activeConversationId = useAtomValue(getActiveConvoIdAtom); - const selectedModel = useAtomValue(selectedModelAtom); - const [currentPrompt, setCurrentPrompt] = useAtom(currentPromptAtom); - const { sendChatMessage } = useSendChatMessage(); - const { requestCreateConvo } = useCreateConversation(); + const activeConversationId = useAtomValue(getActiveConvoIdAtom) + const selectedModel = useAtomValue(selectedModelAtom) + const [currentPrompt, setCurrentPrompt] = useAtom(currentPromptAtom) + const { sendChatMessage } = useSendChatMessage() + const { requestCreateConvo } = useCreateConversation() - const { initModel } = useInitModel(); + const { initModel } = useInitModel() - const textareaRef = useRef(null); + const textareaRef = useRef(null) const handleKeyDown = async ( event: React.KeyboardEvent ) => { - if (event.key === "Enter") { + if (event.key === 'Enter') { if (!event.shiftKey) { if (activeConversationId) { - event.preventDefault(); - sendChatMessage(); + event.preventDefault() + sendChatMessage() } else { if (!selectedModel) { - console.log("No model selected"); - return; + console.log('No model selected') + return } - await requestCreateConvo(selectedModel); - await initModel(selectedModel); - sendChatMessage(); + await requestCreateConvo(selectedModel) + await initModel(selectedModel) + sendChatMessage() } } } - }; + } useEffect(() => { - adjustTextareaHeight(); - }, [currentPrompt]); + adjustTextareaHeight() + }, [currentPrompt]) const handleMessageChange = (event: ChangeEvent) => { - setCurrentPrompt(event.target.value); - }; + setCurrentPrompt(event.target.value) + } // Auto adjust textarea height based on content - const MAX_ROWS = 30; + const MAX_ROWS = 30 const adjustTextareaHeight = () => { if (textareaRef.current) { - textareaRef.current.style.height = "auto"; // 1 row - const scrollHeight = textareaRef.current.scrollHeight; + textareaRef.current.style.height = 'auto' // 1 row + const scrollHeight = textareaRef.current.scrollHeight const maxScrollHeight = parseInt(window.getComputedStyle(textareaRef.current).lineHeight, 10) * - MAX_ROWS; + MAX_ROWS textareaRef.current.style.height = `${Math.min( scrollHeight, maxScrollHeight - )}px`; + )}px` } - }; + } return (
@@ -79,7 +79,7 @@ const BasicPromptInput: React.FC = () => { className="block w-full resize-none border-0 bg-transparent py-1.5 text-gray-900 placeholder:text-gray-400 focus:ring-0 sm:text-sm sm:leading-6" placeholder="Message ..." rows={1} - style={{ overflow: "auto" }} + style={{ overflow: 'auto' }} /> {/* Spacer element to match the height of the toolbar */}
- ); -}; + ) +} -export default BasicPromptInput; +export default BasicPromptInput diff --git a/web/app/_components/ChatBody/index.tsx b/web/app/_components/ChatBody/index.tsx index 5ff75c3dd..0a4d96bdd 100644 --- a/web/app/_components/ChatBody/index.tsx +++ b/web/app/_components/ChatBody/index.tsx @@ -1,44 +1,44 @@ -"use client"; +'use client' -import React, { useCallback, useRef, useState, useEffect } from "react"; -import ChatItem from "../ChatItem"; -import { ChatMessage } from "@/_models/ChatMessage"; -import useChatMessages from "@/_hooks/useChatMessages"; -import { useAtomValue } from "jotai"; -import { selectAtom } from "jotai/utils"; -import { getActiveConvoIdAtom } from "@/_helpers/atoms/Conversation.atom"; -import { chatMessages } from "@/_helpers/atoms/ChatMessage.atom"; +import React, { useCallback, useRef, useState, useEffect } from 'react' +import ChatItem from '../ChatItem' +import { ChatMessage } from '@/_models/ChatMessage' +import useChatMessages from '@/_hooks/useChatMessages' +import { useAtomValue } from 'jotai' +import { selectAtom } from 'jotai/utils' +import { getActiveConvoIdAtom } from '@/_helpers/atoms/Conversation.atom' +import { chatMessages } from '@/_helpers/atoms/ChatMessage.atom' const ChatBody: React.FC = () => { - const activeConversationId = useAtomValue(getActiveConvoIdAtom) ?? ""; + const activeConversationId = useAtomValue(getActiveConvoIdAtom) ?? '' const messageList = useAtomValue( selectAtom( chatMessages, - useCallback((v) => v[activeConversationId], [activeConversationId]), - ), - ); - const [content, setContent] = useState([]); + useCallback((v) => v[activeConversationId], [activeConversationId]) + ) + ) + const [content, setContent] = useState([]) - const [offset, setOffset] = useState(0); - const { loading, hasMore } = useChatMessages(offset); - const intersectObs = useRef(null); + const [offset, setOffset] = useState(0) + const { loading, hasMore } = useChatMessages(offset) + const intersectObs = useRef(null) const lastPostRef = useCallback( (message: ChatMessage) => { - if (loading) return; + if (loading) return - if (intersectObs.current) intersectObs.current.disconnect(); + if (intersectObs.current) intersectObs.current.disconnect() intersectObs.current = new IntersectionObserver((entries) => { if (entries[0].isIntersecting && hasMore) { - setOffset((prevOffset) => prevOffset + 5); + setOffset((prevOffset) => prevOffset + 5) } - }); + }) - if (message) intersectObs.current.observe(message); + if (message) intersectObs.current.observe(message) }, - [loading, hasMore], - ); + [loading, hasMore] + ) useEffect(() => { const list = messageList?.map((message, index) => { @@ -46,18 +46,18 @@ const ChatBody: React.FC = () => { return ( // @ts-ignore - ); + ) } - return ; - }); - setContent(list); - }, [messageList, lastPostRef]); + return + }) + setContent(list) + }, [messageList, lastPostRef]) return ( -
+
{content}
- ); -}; + ) +} -export default ChatBody; +export default ChatBody diff --git a/web/app/_components/ChatBody/renderChatMessage.tsx b/web/app/_components/ChatBody/renderChatMessage.tsx index ed5a264d2..c423d5a76 100644 --- a/web/app/_components/ChatBody/renderChatMessage.tsx +++ b/web/app/_components/ChatBody/renderChatMessage.tsx @@ -1,7 +1,7 @@ -import SimpleControlNetMessage from "../SimpleControlNetMessage"; -import SimpleImageMessage from "../SimpleImageMessage"; -import SimpleTextMessage from "../SimpleTextMessage"; -import { ChatMessage, MessageType } from "@/_models/ChatMessage"; +import SimpleControlNetMessage from '../SimpleControlNetMessage' +import SimpleImageMessage from '../SimpleImageMessage' +import SimpleTextMessage from '../SimpleTextMessage' +import { ChatMessage, MessageType } from '@/_models/ChatMessage' export default function renderChatMessage({ id, @@ -22,9 +22,9 @@ export default function renderChatMessage({ senderName={senderName} createdAt={createdAt} imageUrls={imageUrls ?? []} - text={text ?? ""} + text={text ?? ''} /> - ); + ) case MessageType.Image: return ( - ); + ) case MessageType.Text: return ( - ); + ) default: - return null; + return null } } diff --git a/web/app/_components/ChatItem/index.tsx b/web/app/_components/ChatItem/index.tsx index a8590cf01..00a0bbd52 100644 --- a/web/app/_components/ChatItem/index.tsx +++ b/web/app/_components/ChatItem/index.tsx @@ -1,20 +1,20 @@ /* eslint-disable react/display-name */ -import React, { forwardRef } from "react"; -import renderChatMessage from "../ChatBody/renderChatMessage"; -import { ChatMessage } from "@/_models/ChatMessage"; +import React, { forwardRef } from 'react' +import renderChatMessage from '../ChatBody/renderChatMessage' +import { ChatMessage } from '@/_models/ChatMessage' type Props = { - message: ChatMessage; -}; + message: ChatMessage +} -type Ref = HTMLDivElement; +type Ref = HTMLDivElement const ChatItem = forwardRef(({ message }, ref) => { - const item = renderChatMessage(message); + const item = renderChatMessage(message) - const content = ref ?
{item}
: item; + const content = ref ?
{item}
: item - return content; -}); + return content +}) -export default ChatItem; +export default ChatItem diff --git a/web/app/_components/CompactLogo/index.tsx b/web/app/_components/CompactLogo/index.tsx index 0035d004f..6eb8f0718 100644 --- a/web/app/_components/CompactLogo/index.tsx +++ b/web/app/_components/CompactLogo/index.tsx @@ -1,16 +1,16 @@ -import React from "react"; -import JanImage from "../JanImage"; -import { useSetAtom } from "jotai"; -import { setActiveConvoIdAtom } from "@/_helpers/atoms/Conversation.atom"; +import React from 'react' +import JanImage from '../JanImage' +import { useSetAtom } from 'jotai' +import { setActiveConvoIdAtom } from '@/_helpers/atoms/Conversation.atom' const CompactLogo: React.FC = () => { - const setActiveConvoId = useSetAtom(setActiveConvoIdAtom); + const setActiveConvoId = useSetAtom(setActiveConvoIdAtom) return ( - ); -}; + ) +} -export default React.memo(CompactLogo); +export default React.memo(CompactLogo) diff --git a/web/app/_components/ConfirmDeleteConversationModal/index.tsx b/web/app/_components/ConfirmDeleteConversationModal/index.tsx index 42160a1ce..b287c2170 100644 --- a/web/app/_components/ConfirmDeleteConversationModal/index.tsx +++ b/web/app/_components/ConfirmDeleteConversationModal/index.tsx @@ -1,18 +1,18 @@ -import { showConfirmDeleteConversationModalAtom } from "@/_helpers/atoms/Modal.atom"; -import useDeleteConversation from "@/_hooks/useDeleteConversation"; -import { Dialog, Transition } from "@headlessui/react"; -import { ExclamationTriangleIcon } from "@heroicons/react/24/outline"; -import { useAtom } from "jotai"; -import React, { Fragment, useRef } from "react"; +import { showConfirmDeleteConversationModalAtom } from '@/_helpers/atoms/Modal.atom' +import useDeleteConversation from '@/_hooks/useDeleteConversation' +import { Dialog, Transition } from '@headlessui/react' +import { ExclamationTriangleIcon } from '@heroicons/react/24/outline' +import { useAtom } from 'jotai' +import React, { Fragment, useRef } from 'react' const ConfirmDeleteConversationModal: React.FC = () => { - const [show, setShow] = useAtom(showConfirmDeleteConversationModalAtom); - const cancelButtonRef = useRef(null); - const { deleteConvo } = useDeleteConversation(); + const [show, setShow] = useAtom(showConfirmDeleteConversationModalAtom) + const cancelButtonRef = useRef(null) + const { deleteConvo } = useDeleteConversation() const onConfirmDelete = () => { - deleteConvo().then(() => setShow(false)); - }; + deleteConvo().then(() => setShow(false)) + } return ( @@ -92,7 +92,7 @@ const ConfirmDeleteConversationModal: React.FC = () => {
- ); -}; + ) +} -export default ConfirmDeleteConversationModal; +export default ConfirmDeleteConversationModal diff --git a/web/app/_components/ConfirmDeleteModelModal/index.tsx b/web/app/_components/ConfirmDeleteModelModal/index.tsx index 451eddb60..75bccbfb5 100644 --- a/web/app/_components/ConfirmDeleteModelModal/index.tsx +++ b/web/app/_components/ConfirmDeleteModelModal/index.tsx @@ -1,13 +1,13 @@ -import React, { Fragment } from "react"; -import { Dialog, Transition } from "@headlessui/react"; -import { QuestionMarkCircleIcon } from "@heroicons/react/24/outline"; -import { useAtom } from "jotai"; -import { showConfirmDeleteModalAtom } from "@/_helpers/atoms/Modal.atom"; +import React, { Fragment } from 'react' +import { Dialog, Transition } from '@headlessui/react' +import { QuestionMarkCircleIcon } from '@heroicons/react/24/outline' +import { useAtom } from 'jotai' +import { showConfirmDeleteModalAtom } from '@/_helpers/atoms/Modal.atom' const ConfirmDeleteModelModal: React.FC = () => { - const [show, setShow] = useAtom(showConfirmDeleteModalAtom); + const [show, setShow] = useAtom(showConfirmDeleteModalAtom) - const onConfirmDelete = () => {}; + const onConfirmDelete = () => {} return ( @@ -79,7 +79,7 @@ const ConfirmDeleteModelModal: React.FC = () => {
- ); -}; + ) +} -export default React.memo(ConfirmDeleteModelModal); +export default React.memo(ConfirmDeleteModelModal) diff --git a/web/app/_components/ConfirmSignOutModal/index.tsx b/web/app/_components/ConfirmSignOutModal/index.tsx index 2acc8acd9..973642ccb 100644 --- a/web/app/_components/ConfirmSignOutModal/index.tsx +++ b/web/app/_components/ConfirmSignOutModal/index.tsx @@ -1,17 +1,17 @@ -import React, { Fragment } from "react"; -import { Dialog, Transition } from "@headlessui/react"; -import { QuestionMarkCircleIcon } from "@heroicons/react/24/outline"; -import { useAtom } from "jotai"; -import useSignOut from "@/_hooks/useSignOut"; -import { showConfirmSignOutModalAtom } from "@/_helpers/atoms/Modal.atom"; +import React, { Fragment } from 'react' +import { Dialog, Transition } from '@headlessui/react' +import { QuestionMarkCircleIcon } from '@heroicons/react/24/outline' +import { useAtom } from 'jotai' +import useSignOut from '@/_hooks/useSignOut' +import { showConfirmSignOutModalAtom } from '@/_helpers/atoms/Modal.atom' const ConfirmSignOutModal: React.FC = () => { - const [show, setShow] = useAtom(showConfirmSignOutModalAtom); - const { signOut } = useSignOut(); + const [show, setShow] = useAtom(showConfirmSignOutModalAtom) + const { signOut } = useSignOut() const onLogOutClick = () => { - signOut().then(() => setShow(false)); - }; + signOut().then(() => setShow(false)) + } return ( @@ -83,7 +83,7 @@ const ConfirmSignOutModal: React.FC = () => {
- ); -}; + ) +} -export default React.memo(ConfirmSignOutModal); +export default React.memo(ConfirmSignOutModal) diff --git a/web/app/_components/ConversationalCard/index.tsx b/web/app/_components/ConversationalCard/index.tsx index 8f09d1caf..18d95dacd 100644 --- a/web/app/_components/ConversationalCard/index.tsx +++ b/web/app/_components/ConversationalCard/index.tsx @@ -1,43 +1,43 @@ -import React from "react"; -import Image from "next/image"; -import useCreateConversation from "@/_hooks/useCreateConversation"; -import { AssistantModel } from "@/_models/AssistantModel"; +import React from 'react' +import Image from 'next/image' +import useCreateConversation from '@/_hooks/useCreateConversation' +import { AssistantModel } from '@/_models/AssistantModel' type Props = { - model: AssistantModel; -}; + model: AssistantModel +} const ConversationalCard: React.FC = ({ model }) => { - const { requestCreateConvo } = useCreateConversation(); + const { requestCreateConvo } = useCreateConversation() - const { name, avatarUrl, shortDescription } = model; + const { name, avatarUrl, shortDescription } = model return ( - ); -}; + ) +} -export default React.memo(ConversationalCard); +export default React.memo(ConversationalCard) diff --git a/web/app/_components/ConversationalList/index.tsx b/web/app/_components/ConversationalList/index.tsx index 2275acf26..7d43a1616 100644 --- a/web/app/_components/ConversationalList/index.tsx +++ b/web/app/_components/ConversationalList/index.tsx @@ -1,25 +1,25 @@ -import { AssistantModel } from "@/_models/AssistantModel"; -import ConversationalCard from "../ConversationalCard"; -import { ChatBubbleBottomCenterTextIcon } from "@heroicons/react/24/outline"; +import { AssistantModel } from '@/_models/AssistantModel' +import ConversationalCard from '../ConversationalCard' +import { ChatBubbleBottomCenterTextIcon } from '@heroicons/react/24/outline' type Props = { - models: AssistantModel[]; -}; + models: AssistantModel[] +} const ConversationalList: React.FC = ({ models }) => ( <> -
+
Conversational
-
+
{models.map((item) => ( ))}
-); +) -export default ConversationalList; +export default ConversationalList diff --git a/web/app/_components/DiscordContainer/index.tsx b/web/app/_components/DiscordContainer/index.tsx index 1bf062956..0837963a3 100644 --- a/web/app/_components/DiscordContainer/index.tsx +++ b/web/app/_components/DiscordContainer/index.tsx @@ -1,18 +1,18 @@ -import React from "react"; -import Link from "next/link"; -import Image from "next/image"; +import React from 'react' +import Link from 'next/link' +import Image from 'next/image' const DiscordContainer = () => ( -
+
- + Discord
-); +) -export default React.memo(DiscordContainer); +export default React.memo(DiscordContainer) diff --git a/web/app/_components/DownloadModelContent/index.tsx b/web/app/_components/DownloadModelContent/index.tsx index d970727ad..18702dec5 100644 --- a/web/app/_components/DownloadModelContent/index.tsx +++ b/web/app/_components/DownloadModelContent/index.tsx @@ -1,13 +1,13 @@ -import DownloadModelTitle from "../DownloadModelTitle"; +import DownloadModelTitle from '../DownloadModelTitle' type Props = { - author: string; - description: string; - isRecommend: boolean; - name: string; - type: string; - required?: string; -}; + author: string + description: string + isRecommend: boolean + name: string + type: string + required?: string +} const DownloadModelContent: React.FC = ({ author, @@ -18,23 +18,23 @@ const DownloadModelContent: React.FC = ({ type, }) => { return ( -
+
-

+

{name}

-
- +
+ {author}
{required && ( -
+
- Required{" "} + Required{' '} - + {required}
@@ -43,16 +43,16 @@ const DownloadModelContent: React.FC = ({

{description}

-
- +
+ Recommend
- ); -}; + ) +} -export default DownloadModelContent; +export default DownloadModelContent diff --git a/web/app/_components/DownloadModelTitle/index.tsx b/web/app/_components/DownloadModelTitle/index.tsx index da7f9bb38..a3efceec2 100644 --- a/web/app/_components/DownloadModelTitle/index.tsx +++ b/web/app/_components/DownloadModelTitle/index.tsx @@ -1,13 +1,13 @@ type Props = { - title: string; -}; + title: string +} export const DownloadModelTitle: React.FC = ({ title }) => ( -
- +
+ {title}
-); +) -export default DownloadModelTitle; +export default DownloadModelTitle diff --git a/web/app/_components/DownloadedModelCard/index.tsx b/web/app/_components/DownloadedModelCard/index.tsx index 9e766612b..21cb5a5e9 100644 --- a/web/app/_components/DownloadedModelCard/index.tsx +++ b/web/app/_components/DownloadedModelCard/index.tsx @@ -1,13 +1,13 @@ -import { AssistantModel } from "@/_models/AssistantModel"; -import DownloadModelContent from "../DownloadModelContent"; +import { AssistantModel } from '@/_models/AssistantModel' +import DownloadModelContent from '../DownloadModelContent' type Props = { - model: AssistantModel; - isRecommend: boolean; - required?: string; - transferred?: number; - onDeleteClick?: (model: AssistantModel) => void; -}; + model: AssistantModel + isRecommend: boolean + required?: string + transferred?: number + onDeleteClick?: (model: AssistantModel) => void +} const DownloadedModelCard: React.FC = ({ model, @@ -15,8 +15,8 @@ const DownloadedModelCard: React.FC = ({ required, onDeleteClick, }) => ( -
-
+
+
= ({
-); +) -export default DownloadedModelCard; +export default DownloadedModelCard diff --git a/web/app/_components/DownloadedModelTable/index.tsx b/web/app/_components/DownloadedModelTable/index.tsx index 66b646df0..781cf7805 100644 --- a/web/app/_components/DownloadedModelTable/index.tsx +++ b/web/app/_components/DownloadedModelTable/index.tsx @@ -1,22 +1,22 @@ -import React from "react"; -import SearchBar from "../SearchBar"; -import ModelTable from "../ModelTable"; -import { useGetDownloadedModels } from "@/_hooks/useGetDownloadedModels"; +import React from 'react' +import SearchBar from '../SearchBar' +import ModelTable from '../ModelTable' +import { useGetDownloadedModels } from '@/_hooks/useGetDownloadedModels' const DownloadedModelTable: React.FC = () => { - const { downloadedModels } = useGetDownloadedModels(); + const { downloadedModels } = useGetDownloadedModels() - if (!downloadedModels || downloadedModels.length === 0) return null; + if (!downloadedModels || downloadedModels.length === 0) return null return (
-

Downloaded Models

-
+

Downloaded Models

+
- ); -}; + ) +} -export default DownloadedModelTable; +export default DownloadedModelTable diff --git a/web/app/_components/DownloadingModelTable/index.tsx b/web/app/_components/DownloadingModelTable/index.tsx index 37c13baed..654740215 100644 --- a/web/app/_components/DownloadingModelTable/index.tsx +++ b/web/app/_components/DownloadingModelTable/index.tsx @@ -1,29 +1,29 @@ -import React, { Fragment } from "react"; -import { modelDownloadStateAtom } from "@/_helpers/atoms/DownloadState.atom"; -import { useAtomValue } from "jotai"; -import ModelDownloadingTable from "../ModelDownloadingTable"; -import { DownloadState } from "@/_models/DownloadState"; +import React, { Fragment } from 'react' +import { modelDownloadStateAtom } from '@/_helpers/atoms/DownloadState.atom' +import { useAtomValue } from 'jotai' +import ModelDownloadingTable from '../ModelDownloadingTable' +import { DownloadState } from '@/_models/DownloadState' const DownloadingModelTable: React.FC = () => { - const modelDownloadState = useAtomValue(modelDownloadStateAtom); + const modelDownloadState = useAtomValue(modelDownloadStateAtom) - const isAnyModelDownloading = Object.values(modelDownloadState).length > 0; + const isAnyModelDownloading = Object.values(modelDownloadState).length > 0 - if (!isAnyModelDownloading) return null; + if (!isAnyModelDownloading) return null - const downloadStates: DownloadState[] = []; + const downloadStates: DownloadState[] = [] for (const [, value] of Object.entries(modelDownloadState)) { - downloadStates.push(value); + downloadStates.push(value) } return (
-

+

Downloading Models

- ); -}; + ) +} -export default DownloadingModelTable; +export default DownloadingModelTable diff --git a/web/app/_components/DropdownList/index.tsx b/web/app/_components/DropdownList/index.tsx index b2db63c9e..94b15a18f 100644 --- a/web/app/_components/DropdownList/index.tsx +++ b/web/app/_components/DropdownList/index.tsx @@ -1,64 +1,64 @@ -import { Fragment, useState } from "react"; -import { Menu, Transition } from "@headlessui/react"; -import Image from "next/image"; - -function classNames(...classes: any) { - return classes.filter(Boolean).join(" "); -} - -type Props = { - title: string; - data: string[]; -}; - -export const DropdownsList: React.FC = ({ data, title }) => { - const [checked, setChecked] = useState(data[0]); - - return ( - -
-

{title}

- - {checked} - - -
- - - - - - -
- ); -}; +import { Fragment, useState } from 'react' +import { Menu, Transition } from '@headlessui/react' +import Image from 'next/image' + +function classNames(...classes: any) { + return classes.filter(Boolean).join(' ') +} + +type Props = { + title: string + data: string[] +} + +export const DropdownsList: React.FC = ({ data, title }) => { + const [checked, setChecked] = useState(data[0]) + + return ( + +
+

{title}

+ + {checked} + + +
+ + + + + + +
+ ) +} diff --git a/web/app/_components/EmptyChatContainer/index.tsx b/web/app/_components/EmptyChatContainer/index.tsx index caeff5655..01fc87a75 100644 --- a/web/app/_components/EmptyChatContainer/index.tsx +++ b/web/app/_components/EmptyChatContainer/index.tsx @@ -1,14 +1,14 @@ -import React from "react"; -import SelectModels from "../ModelSelector"; -import InputToolbar from "../InputToolbar"; +import React from 'react' +import SelectModels from '../ModelSelector' +import InputToolbar from '../InputToolbar' const EmptyChatContainer: React.FC = () => ( -
+
-); +) -export default EmptyChatContainer; +export default EmptyChatContainer diff --git a/web/app/_components/ExpandableHeader/index.tsx b/web/app/_components/ExpandableHeader/index.tsx index fdbdaa97a..11d4851c2 100644 --- a/web/app/_components/ExpandableHeader/index.tsx +++ b/web/app/_components/ExpandableHeader/index.tsx @@ -1,14 +1,14 @@ -import { ChevronDownIcon, ChevronUpIcon } from "@heroicons/react/24/outline"; +import { ChevronDownIcon, ChevronUpIcon } from '@heroicons/react/24/outline' type Props = { - title: string; - expanded: boolean; - onClick: () => void; -}; + title: string + expanded: boolean + onClick: () => void +} const ExpandableHeader: React.FC = ({ title, expanded, onClick }) => ( -); +) -export default ExpandableHeader; +export default ExpandableHeader diff --git a/web/app/_components/ExploreModelContainer/index.tsx b/web/app/_components/ExploreModelContainer/index.tsx index 3102b2b49..d8ceb50ff 100644 --- a/web/app/_components/ExploreModelContainer/index.tsx +++ b/web/app/_components/ExploreModelContainer/index.tsx @@ -1,20 +1,20 @@ -import HeaderTitle from "../HeaderTitle"; -import SearchBar, { SearchType } from "../SearchBar"; -import ExploreModelList from "../ExploreModelList"; -import ExploreModelFilter from "../ExploreModelFilter"; +import HeaderTitle from '../HeaderTitle' +import SearchBar, { SearchType } from '../SearchBar' +import ExploreModelList from '../ExploreModelList' +import ExploreModelFilter from '../ExploreModelFilter' const ExploreModelContainer: React.FC = () => ( -
+
{/* */} -
+
-); +) -export default ExploreModelContainer; +export default ExploreModelContainer diff --git a/web/app/_components/ExploreModelFilter/index.tsx b/web/app/_components/ExploreModelFilter/index.tsx index a3c173130..d22a9cdf9 100644 --- a/web/app/_components/ExploreModelFilter/index.tsx +++ b/web/app/_components/ExploreModelFilter/index.tsx @@ -1,29 +1,29 @@ -import React from "react"; -import SearchBar from "../SearchBar"; -import SimpleCheckbox from "../SimpleCheckbox"; -import SimpleTag from "../SimpleTag"; -import { TagType } from "../SimpleTag/TagType"; +import React from 'react' +import SearchBar from '../SearchBar' +import SimpleCheckbox from '../SimpleCheckbox' +import SimpleTag from '../SimpleTag' +import { TagType } from '../SimpleTag/TagType' const tags = [ - "Roleplay", - "Llama", - "Story", - "Casual", - "Professional", - "CodeLlama", - "Coding", -]; -const checkboxs = ["GGUF", "TensorRT", "Meow", "JigglyPuff"]; + 'Roleplay', + 'Llama', + 'Story', + 'Casual', + 'Professional', + 'CodeLlama', + 'Coding', +] +const checkboxs = ['GGUF', 'TensorRT', 'Meow', 'JigglyPuff'] const ExploreModelFilter: React.FC = () => { - const enabled = false; - if (!enabled) return null; + const enabled = false + if (!enabled) return null return (
-

Tags

+

Tags

-
+
{tags.map((item) => ( ))} @@ -35,7 +35,7 @@ const ExploreModelFilter: React.FC = () => { ))}
- ); -}; + ) +} -export default ExploreModelFilter; +export default ExploreModelFilter diff --git a/web/app/_components/ExploreModelItem/index.tsx b/web/app/_components/ExploreModelItem/index.tsx index 1c65374c5..fe856aef2 100644 --- a/web/app/_components/ExploreModelItem/index.tsx +++ b/web/app/_components/ExploreModelItem/index.tsx @@ -1,11 +1,11 @@ /* eslint-disable react/display-name */ -"use client"; +'use client' -import ExploreModelItemHeader from "../ExploreModelItemHeader"; -import ModelVersionList from "../ModelVersionList"; -import { Fragment, forwardRef, useEffect, useState } from "react"; -import SimpleTag from "../SimpleTag"; +import ExploreModelItemHeader from '../ExploreModelItemHeader' +import ModelVersionList from '../ModelVersionList' +import { Fragment, forwardRef, useEffect, useState } from 'react' +import SimpleTag from '../SimpleTag' import { MiscellanousTag, NumOfBit, @@ -13,37 +13,37 @@ import { RamRequired, UsecaseTag, VersionTag, -} from "@/_components/SimpleTag/TagType"; -import { displayDate } from "@/_utils/datetime"; -import { Product } from "@/_models/Product"; -import useGetMostSuitableModelVersion from "@/_hooks/useGetMostSuitableModelVersion"; -import { toGigabytes } from "@/_utils/converter"; +} from '@/_components/SimpleTag/TagType' +import { displayDate } from '@/_utils/datetime' +import { Product } from '@/_models/Product' +import useGetMostSuitableModelVersion from '@/_hooks/useGetMostSuitableModelVersion' +import { toGigabytes } from '@/_utils/converter' type Props = { - model: Product; -}; + model: Product +} const ExploreModelItem = forwardRef(({ model }, ref) => { - const [show, setShow] = useState(false); + const [show, setShow] = useState(false) - const { availableVersions } = model; + const { availableVersions } = model const { suitableModel, getMostSuitableModelVersion } = - useGetMostSuitableModelVersion(); + useGetMostSuitableModelVersion() useEffect(() => { - getMostSuitableModelVersion(availableVersions); - }, [availableVersions]); + getMostSuitableModelVersion(availableVersions) + }, [availableVersions]) if (!suitableModel) { - return null; + return null } - const { quantMethod, bits, maxRamRequired, usecase } = suitableModel; + const { quantMethod, bits, maxRamRequired, usecase } = suitableModel return (
(({ model }, ref) => { />
-
+
Release Date @@ -81,7 +81,7 @@ const ExploreModelItem = forwardRef(({ model }, ref) => {
-
+
Author
@@ -107,13 +107,13 @@ const ExploreModelItem = forwardRef(({ model }, ref) => {
-
+
About {model.longDescription}
-
+
Tags
{model.tags.map((tag) => ( @@ -133,19 +133,19 @@ const ExploreModelItem = forwardRef(({ model }, ref) => { )} )}
- ); -}); + ) +}) -export default ExploreModelItem; +export default ExploreModelItem diff --git a/web/app/_components/ExploreModelItemHeader/index.tsx b/web/app/_components/ExploreModelItemHeader/index.tsx index 23caa8dd5..a2b3c953a 100644 --- a/web/app/_components/ExploreModelItemHeader/index.tsx +++ b/web/app/_components/ExploreModelItemHeader/index.tsx @@ -1,72 +1,72 @@ -import SimpleTag from "../SimpleTag"; -import PrimaryButton from "../PrimaryButton"; -import { formatDownloadPercentage, toGigabytes } from "@/_utils/converter"; -import SecondaryButton from "../SecondaryButton"; -import { Product } from "@/_models/Product"; -import { useCallback, useEffect, useMemo } from "react"; -import { ModelVersion } from "@/_models/ModelVersion"; -import useGetPerformanceTag from "@/_hooks/useGetPerformanceTag"; -import useDownloadModel from "@/_hooks/useDownloadModel"; -import { useGetDownloadedModels } from "@/_hooks/useGetDownloadedModels"; -import { modelDownloadStateAtom } from "@/_helpers/atoms/DownloadState.atom"; -import { atom, useAtomValue, useSetAtom } from "jotai"; +import SimpleTag from '../SimpleTag' +import PrimaryButton from '../PrimaryButton' +import { formatDownloadPercentage, toGigabytes } from '@/_utils/converter' +import SecondaryButton from '../SecondaryButton' +import { Product } from '@/_models/Product' +import { useCallback, useEffect, useMemo } from 'react' +import { ModelVersion } from '@/_models/ModelVersion' +import useGetPerformanceTag from '@/_hooks/useGetPerformanceTag' +import useDownloadModel from '@/_hooks/useDownloadModel' +import { useGetDownloadedModels } from '@/_hooks/useGetDownloadedModels' +import { modelDownloadStateAtom } from '@/_helpers/atoms/DownloadState.atom' +import { atom, useAtomValue, useSetAtom } from 'jotai' import { MainViewState, setMainViewStateAtom, -} from "@/_helpers/atoms/MainView.atom"; +} from '@/_helpers/atoms/MainView.atom' type Props = { - suitableModel: ModelVersion; - exploreModel: Product; -}; + suitableModel: ModelVersion + exploreModel: Product +} const ExploreModelItemHeader: React.FC = ({ suitableModel, exploreModel, }) => { - const { downloadModel } = useDownloadModel(); - const { downloadedModels } = useGetDownloadedModels(); + const { downloadModel } = useDownloadModel() + const { downloadedModels } = useGetDownloadedModels() const { performanceTag, title, getPerformanceForModel } = - useGetPerformanceTag(); + useGetPerformanceTag() const downloadAtom = useMemo( () => atom((get) => get(modelDownloadStateAtom)[suitableModel._id]), [suitableModel._id] - ); - const downloadState = useAtomValue(downloadAtom); - const setMainViewState = useSetAtom(setMainViewStateAtom); + ) + const downloadState = useAtomValue(downloadAtom) + const setMainViewState = useSetAtom(setMainViewStateAtom) useEffect(() => { - getPerformanceForModel(suitableModel); - }, [suitableModel]); + getPerformanceForModel(suitableModel) + }, [suitableModel]) const onDownloadClick = useCallback(() => { - downloadModel(exploreModel, suitableModel); - }, [exploreModel, suitableModel]); + downloadModel(exploreModel, suitableModel) + }, [exploreModel, suitableModel]) const isDownloaded = - downloadedModels.find((model) => model._id === suitableModel._id) != null; + downloadedModels.find((model) => model._id === suitableModel._id) != null let downloadButton = ( onDownloadClick()} /> - ); + ) if (isDownloaded) { downloadButton = ( { - setMainViewState(MainViewState.MyModel); + setMainViewState(MainViewState.MyModel) }} className="bg-green-500 hover:bg-green-400" /> - ); + ) } if (downloadState != null) { @@ -78,11 +78,11 @@ const ExploreModelItemHeader: React.FC = ({ downloadState.percent )})`} /> - ); + ) } return ( -
+
{exploreModel.name} {performanceTag && ( @@ -91,7 +91,7 @@ const ExploreModelItemHeader: React.FC = ({
{downloadButton}
- ); -}; + ) +} -export default ExploreModelItemHeader; +export default ExploreModelItemHeader diff --git a/web/app/_components/ExploreModelList/index.tsx b/web/app/_components/ExploreModelList/index.tsx index b76826c90..7c9ec8f9d 100644 --- a/web/app/_components/ExploreModelList/index.tsx +++ b/web/app/_components/ExploreModelList/index.tsx @@ -1,18 +1,18 @@ -import React, { useEffect } from "react"; -import ExploreModelItem from "../ExploreModelItem"; -import { getConfiguredModels } from "@/_hooks/useGetDownloadedModels"; -import useGetConfiguredModels from "@/_hooks/useGetConfiguredModels"; -import { Waveform } from "@uiball/loaders"; +import React, { useEffect } from 'react' +import ExploreModelItem from '../ExploreModelItem' +import { getConfiguredModels } from '@/_hooks/useGetDownloadedModels' +import useGetConfiguredModels from '@/_hooks/useGetConfiguredModels' +import { Waveform } from '@uiball/loaders' const ExploreModelList: React.FC = () => { - const { loading, models } = useGetConfiguredModels(); + const { loading, models } = useGetConfiguredModels() useEffect(() => { - getConfiguredModels(); - }, []); + getConfiguredModels() + }, []) return ( -
+
{loading && (
@@ -22,7 +22,7 @@ const ExploreModelList: React.FC = () => { ))}
- ); -}; + ) +} -export default ExploreModelList; +export default ExploreModelList diff --git a/web/app/_components/Footer/index.tsx b/web/app/_components/Footer/index.tsx index fd14e4fc9..e424752cd 100644 --- a/web/app/_components/Footer/index.tsx +++ b/web/app/_components/Footer/index.tsx @@ -1,29 +1,23 @@ -import Image from "next/image"; -import Link from "next/link"; +import Image from 'next/image' +import Link from 'next/link' // DEPRECATED export default function Footer() { return ( -
+
- + Jan
-
- +
+ Privacy - + Support
- ); + ) } diff --git a/web/app/_components/HamburgerButton/index.tsx b/web/app/_components/HamburgerButton/index.tsx index d3e775631..ba41679c6 100644 --- a/web/app/_components/HamburgerButton/index.tsx +++ b/web/app/_components/HamburgerButton/index.tsx @@ -1,22 +1,22 @@ -"use client"; +'use client' -import { showingMobilePaneAtom } from "@/_helpers/atoms/Modal.atom"; -import { Bars3Icon } from "@heroicons/react/24/outline"; -import { useSetAtom } from "jotai"; -import React from "react"; +import { showingMobilePaneAtom } from '@/_helpers/atoms/Modal.atom' +import { Bars3Icon } from '@heroicons/react/24/outline' +import { useSetAtom } from 'jotai' +import React from 'react' const HamburgerButton: React.FC = () => { - const setShowingMobilePane = useSetAtom(showingMobilePaneAtom); + const setShowingMobilePane = useSetAtom(showingMobilePaneAtom) return ( - ); -}; + ) +} -export default React.memo(HamburgerButton); +export default React.memo(HamburgerButton) diff --git a/web/app/_components/Header/index.tsx b/web/app/_components/Header/index.tsx index d62114085..3c9a90910 100644 --- a/web/app/_components/Header/index.tsx +++ b/web/app/_components/Header/index.tsx @@ -1,19 +1,19 @@ -import React from "react"; -import UserProfileDropDown from "../UserProfileDropDown"; -import LoginButton from "../LoginButton"; -import HamburgerButton from "../HamburgerButton"; - -const Header: React.FC = () => { - return ( -
- -
- - -
- ); -}; - -export default Header; +import React from 'react' +import UserProfileDropDown from '../UserProfileDropDown' +import LoginButton from '../LoginButton' +import HamburgerButton from '../HamburgerButton' + +const Header: React.FC = () => { + return ( +
+ +
+ + +
+ ) +} + +export default Header diff --git a/web/app/_components/HeaderBackButton/index.tsx b/web/app/_components/HeaderBackButton/index.tsx index fbcefc737..e2f920c4e 100644 --- a/web/app/_components/HeaderBackButton/index.tsx +++ b/web/app/_components/HeaderBackButton/index.tsx @@ -1,5 +1,5 @@ -import React from "react"; -import { ArrowLeftIcon } from "@heroicons/react/24/outline"; +import React from 'react' +import { ArrowLeftIcon } from '@heroicons/react/24/outline' const HeaderBackButton: React.FC = () => { return ( @@ -7,7 +7,7 @@ const HeaderBackButton: React.FC = () => { Back - ); -}; + ) +} -export default React.memo(HeaderBackButton); +export default React.memo(HeaderBackButton) diff --git a/web/app/_components/HeaderTitle/index.tsx b/web/app/_components/HeaderTitle/index.tsx index 8605ee9d6..460769b9f 100644 --- a/web/app/_components/HeaderTitle/index.tsx +++ b/web/app/_components/HeaderTitle/index.tsx @@ -1,16 +1,16 @@ -import React from "react"; +import React from 'react' type Props = { - title: string; - className?: string; -}; + title: string + className?: string +} const HeaderTitle: React.FC = ({ title, className }) => (

{title}

-); +) -export default React.memo(HeaderTitle); +export default React.memo(HeaderTitle) diff --git a/web/app/_components/HistoryItem/index.tsx b/web/app/_components/HistoryItem/index.tsx index 3b85cec2a..6592ffbb0 100644 --- a/web/app/_components/HistoryItem/index.tsx +++ b/web/app/_components/HistoryItem/index.tsx @@ -1,30 +1,30 @@ -import React from "react"; -import { useAtomValue, useSetAtom } from "jotai"; -import Image from "next/image"; -import { Conversation } from "@/_models/Conversation"; -import { ModelManagementService } from "@janhq/core"; -import { executeSerial } from "../../../../electron/core/plugin-manager/execution/extension-manager"; +import React from 'react' +import { useAtomValue, useSetAtom } from 'jotai' +import Image from 'next/image' +import { Conversation } from '@/_models/Conversation' +import { ModelManagementService } from '@janhq/core' +import { executeSerial } from '../../../../electron/core/plugin-manager/execution/extension-manager' import { conversationStatesAtom, getActiveConvoIdAtom, setActiveConvoIdAtom, updateConversationErrorAtom, updateConversationWaitingForResponseAtom, -} from "@/_helpers/atoms/Conversation.atom"; +} from '@/_helpers/atoms/Conversation.atom' import { setMainViewStateAtom, MainViewState, -} from "@/_helpers/atoms/MainView.atom"; -import useInitModel from "@/_hooks/useInitModel"; -import { displayDate } from "@/_utils/datetime"; +} from '@/_helpers/atoms/MainView.atom' +import useInitModel from '@/_hooks/useInitModel' +import { displayDate } from '@/_utils/datetime' type Props = { - conversation: Conversation; - avatarUrl?: string; - name: string; - summary?: string; - updatedAt?: string; -}; + conversation: Conversation + avatarUrl?: string + name: string + summary?: string + updatedAt?: string +} const HistoryItem: React.FC = ({ conversation, @@ -33,82 +33,80 @@ const HistoryItem: React.FC = ({ summary, updatedAt, }) => { - const setMainViewState = useSetAtom(setMainViewStateAtom); - const conversationStates = useAtomValue(conversationStatesAtom); - const activeConvoId = useAtomValue(getActiveConvoIdAtom); - const setActiveConvoId = useSetAtom(setActiveConvoIdAtom); - const updateConvWaiting = useSetAtom( - updateConversationWaitingForResponseAtom - ); - const updateConvError = useSetAtom(updateConversationErrorAtom); - const isSelected = activeConvoId === conversation._id; + const setMainViewState = useSetAtom(setMainViewStateAtom) + const conversationStates = useAtomValue(conversationStatesAtom) + const activeConvoId = useAtomValue(getActiveConvoIdAtom) + const setActiveConvoId = useSetAtom(setActiveConvoIdAtom) + const updateConvWaiting = useSetAtom(updateConversationWaitingForResponseAtom) + const updateConvError = useSetAtom(updateConversationErrorAtom) + const isSelected = activeConvoId === conversation._id - const { initModel } = useInitModel(); + const { initModel } = useInitModel() const onClick = async () => { const model = await executeSerial( ModelManagementService.GetModelById, conversation.modelId - ); + ) - if (conversation._id) updateConvWaiting(conversation._id, true); + if (conversation._id) updateConvWaiting(conversation._id, true) initModel(model).then((res: any) => { - if (conversation._id) updateConvWaiting(conversation._id, false); + if (conversation._id) updateConvWaiting(conversation._id, false) if (res?.error && conversation._id) { - updateConvError(conversation._id, res.error); + updateConvError(conversation._id, res.error) } - }); + }) if (activeConvoId !== conversation._id) { - setMainViewState(MainViewState.Conversation); - setActiveConvoId(conversation._id); + setMainViewState(MainViewState.Conversation) + setActiveConvoId(conversation._id) } - }; - - const backgroundColor = isSelected - ? "bg-gray-100 dark:bg-gray-700" - : "bg-white dark:bg-gray-500"; - - let rightImageUrl: string | undefined; - if (conversationStates[conversation._id ?? ""]?.waitingForResponse === true) { - rightImageUrl = "icons/loading.svg"; } - const description = conversation?.lastMessage ?? "No new message"; + const backgroundColor = isSelected + ? 'bg-gray-100 dark:bg-gray-700' + : 'bg-white dark:bg-gray-500' + + let rightImageUrl: string | undefined + if (conversationStates[conversation._id ?? '']?.waitingForResponse === true) { + rightImageUrl = 'icons/loading.svg' + } + + const description = conversation?.lastMessage ?? 'No new message' return (
  • -
    +
    -
    +
    {/* title */}
    - + {summary ?? name} - + {updatedAt && displayDate(new Date(updatedAt).getTime())}
    {/* description */} - {description} + {description}
  • - ); -}; + ) +} -export default HistoryItem; +export default HistoryItem diff --git a/web/app/_components/HistoryList/index.tsx b/web/app/_components/HistoryList/index.tsx index 584579ab6..c598d970a 100644 --- a/web/app/_components/HistoryList/index.tsx +++ b/web/app/_components/HistoryList/index.tsx @@ -1,57 +1,57 @@ -import HistoryItem from "../HistoryItem"; -import { useEffect, useState } from "react"; -import ExpandableHeader from "../ExpandableHeader"; -import { useAtomValue } from "jotai"; -import { searchAtom } from "@/_helpers/JotaiWrapper"; -import useGetUserConversations from "@/_hooks/useGetUserConversations"; -import SidebarEmptyHistory from "../SidebarEmptyHistory"; -import { userConversationsAtom } from "@/_helpers/atoms/Conversation.atom"; - -const HistoryList: React.FC = () => { - const conversations = useAtomValue(userConversationsAtom); - const searchText = useAtomValue(searchAtom); - const [expand, setExpand] = useState(true); - const { getUserConversations } = useGetUserConversations(); - - useEffect(() => { - getUserConversations(); - }, []); - - return ( -
    - setExpand(!expand)} - /> -
      - {conversations.length > 0 ? ( - conversations - .filter( - (e) => - searchText.trim() === "" || - e.name?.toLowerCase().includes(searchText.toLowerCase().trim()) - ) - .map((convo) => ( - - )) - ) : ( - - )} -
    -
    - ); -}; - -export default HistoryList; +import HistoryItem from '../HistoryItem' +import { useEffect, useState } from 'react' +import ExpandableHeader from '../ExpandableHeader' +import { useAtomValue } from 'jotai' +import { searchAtom } from '@/_helpers/JotaiWrapper' +import useGetUserConversations from '@/_hooks/useGetUserConversations' +import SidebarEmptyHistory from '../SidebarEmptyHistory' +import { userConversationsAtom } from '@/_helpers/atoms/Conversation.atom' + +const HistoryList: React.FC = () => { + const conversations = useAtomValue(userConversationsAtom) + const searchText = useAtomValue(searchAtom) + const [expand, setExpand] = useState(true) + const { getUserConversations } = useGetUserConversations() + + useEffect(() => { + getUserConversations() + }, []) + + return ( +
    + setExpand(!expand)} + /> +
      + {conversations.length > 0 ? ( + conversations + .filter( + (e) => + searchText.trim() === '' || + e.name?.toLowerCase().includes(searchText.toLowerCase().trim()) + ) + .map((convo) => ( + + )) + ) : ( + + )} +
    +
    + ) +} + +export default HistoryList diff --git a/web/app/_components/InputToolbar/index.tsx b/web/app/_components/InputToolbar/index.tsx index f5d1f1b0c..9d8a2b6e6 100644 --- a/web/app/_components/InputToolbar/index.tsx +++ b/web/app/_components/InputToolbar/index.tsx @@ -1,24 +1,24 @@ -"use client"; +'use client' -import BasicPromptInput from "../BasicPromptInput"; -import BasicPromptAccessories from "../BasicPromptAccessories"; -import { useAtomValue } from "jotai"; -import { showingAdvancedPromptAtom } from "@/_helpers/atoms/Modal.atom"; -import SecondaryButton from "../SecondaryButton"; -import { Fragment } from "react"; -import { PlusIcon } from "@heroicons/react/24/outline"; -import useCreateConversation from "@/_hooks/useCreateConversation"; -import { activeAssistantModelAtom } from "@/_helpers/atoms/Model.atom"; -import { currentConvoStateAtom } from "@/_helpers/atoms/Conversation.atom"; +import BasicPromptInput from '../BasicPromptInput' +import BasicPromptAccessories from '../BasicPromptAccessories' +import { useAtomValue } from 'jotai' +import { showingAdvancedPromptAtom } from '@/_helpers/atoms/Modal.atom' +import SecondaryButton from '../SecondaryButton' +import { Fragment } from 'react' +import { PlusIcon } from '@heroicons/react/24/outline' +import useCreateConversation from '@/_hooks/useCreateConversation' +import { activeAssistantModelAtom } from '@/_helpers/atoms/Model.atom' +import { currentConvoStateAtom } from '@/_helpers/atoms/Conversation.atom' const InputToolbar: React.FC = () => { - const showingAdvancedPrompt = useAtomValue(showingAdvancedPromptAtom); - const activeModel = useAtomValue(activeAssistantModelAtom); - const { requestCreateConvo } = useCreateConversation(); - const currentConvoState = useAtomValue(currentConvoStateAtom); + const showingAdvancedPrompt = useAtomValue(showingAdvancedPromptAtom) + const activeModel = useAtomValue(activeAssistantModelAtom) + const { requestCreateConvo } = useCreateConversation() + const currentConvoState = useAtomValue(currentConvoStateAtom) if (showingAdvancedPrompt) { - return
    ; + return
    } // TODO: implement regenerate @@ -26,20 +26,20 @@ const InputToolbar: React.FC = () => { const onNewConversationClick = () => { if (activeModel) { - requestCreateConvo(activeModel); + requestCreateConvo(activeModel) } - }; + } return ( {currentConvoState?.error && (
    - + {currentConvoState?.error?.toString()}
    )} -
    +
    {/* */} { />
    {/* My text input */} -
    -
    +
    +
    - ); -}; + ) +} -export default InputToolbar; +export default InputToolbar diff --git a/web/app/_components/JanImage/index.tsx b/web/app/_components/JanImage/index.tsx index 9ce7f1c15..a3b11cff4 100644 --- a/web/app/_components/JanImage/index.tsx +++ b/web/app/_components/JanImage/index.tsx @@ -1,21 +1,21 @@ -import React from "react"; +import React from 'react' type Props = { - imageUrl: string; - className?: string; - alt?: string; - width?: number; - height?: number; -}; + imageUrl: string + className?: string + alt?: string + width?: number + height?: number +} const JanImage: React.FC = ({ imageUrl, - className = "", - alt = "", + className = '', + alt = '', width, height, }) => { - const [attempt, setAttempt] = React.useState(0); + const [attempt, setAttempt] = React.useState(0) return ( = ({ key={attempt} onError={() => setAttempt(attempt + 1)} /> - ); -}; + ) +} -export default JanImage; +export default JanImage diff --git a/web/app/_components/JanLogo/index.tsx b/web/app/_components/JanLogo/index.tsx index 898d320a3..043ec4128 100644 --- a/web/app/_components/JanLogo/index.tsx +++ b/web/app/_components/JanLogo/index.tsx @@ -1,19 +1,19 @@ -import { setActiveConvoIdAtom } from "@/_helpers/atoms/Conversation.atom"; -import { useSetAtom } from "jotai"; -import Image from "next/image"; -import React from "react"; +import { setActiveConvoIdAtom } from '@/_helpers/atoms/Conversation.atom' +import { useSetAtom } from 'jotai' +import Image from 'next/image' +import React from 'react' const JanLogo: React.FC = () => { - const setActiveConvoId = useSetAtom(setActiveConvoIdAtom); + const setActiveConvoId = useSetAtom(setActiveConvoIdAtom) return ( - ); -}; + ) +} -export default React.memo(JanLogo); +export default React.memo(JanLogo) diff --git a/web/app/_components/LeftContainer/index.tsx b/web/app/_components/LeftContainer/index.tsx index a3b78679b..8a64c8c8c 100644 --- a/web/app/_components/LeftContainer/index.tsx +++ b/web/app/_components/LeftContainer/index.tsx @@ -1,9 +1,9 @@ -import React, { Fragment } from "react"; -import SidebarFooter from "../SidebarFooter"; -import SidebarHeader from "../SidebarHeader"; -import SidebarMenu from "../SidebarMenu"; -import HistoryList from "../HistoryList"; -import NewChatButton from "../NewChatButton"; +import React, { Fragment } from 'react' +import SidebarFooter from '../SidebarFooter' +import SidebarHeader from '../SidebarHeader' +import SidebarMenu from '../SidebarMenu' +import HistoryList from '../HistoryList' +import NewChatButton from '../NewChatButton' const LeftContainer: React.FC = () => ( @@ -13,6 +13,6 @@ const LeftContainer: React.FC = () => ( -); +) -export default React.memo(LeftContainer); +export default React.memo(LeftContainer) diff --git a/web/app/_components/LeftSidebar/index.tsx b/web/app/_components/LeftSidebar/index.tsx index 04bc47420..067615c53 100644 --- a/web/app/_components/LeftSidebar/index.tsx +++ b/web/app/_components/LeftSidebar/index.tsx @@ -1,20 +1,20 @@ -import React from "react"; -import SearchBar from "../SearchBar"; -// import ShortcutList from "../ShortcutList"; -import HistoryList from "../HistoryList"; -import DiscordContainer from "../DiscordContainer"; -import JanLogo from "../JanLogo"; - -const LeftSidebar: React.FC = () => ( -
    - -
    - - {/* */} - -
    - -
    -); - -export default LeftSidebar; +import React from 'react' +import SearchBar from '../SearchBar' +// import ShortcutList from "../ShortcutList"; +import HistoryList from '../HistoryList' +import DiscordContainer from '../DiscordContainer' +import JanLogo from '../JanLogo' + +const LeftSidebar: React.FC = () => ( +
    + +
    + + {/* */} + +
    + +
    +) + +export default LeftSidebar diff --git a/web/app/_components/LoadingIndicator.tsx b/web/app/_components/LoadingIndicator.tsx index 021f0e42d..0fcf75cb2 100644 --- a/web/app/_components/LoadingIndicator.tsx +++ b/web/app/_components/LoadingIndicator.tsx @@ -1,5 +1,4 @@ const LoadingIndicator = () => { - return (
    @@ -8,7 +7,7 @@ const LoadingIndicator = () => {
    - ); -}; + ) +} -export default LoadingIndicator; +export default LoadingIndicator diff --git a/web/app/_components/LoginButton/index.tsx b/web/app/_components/LoginButton/index.tsx index 5f4725cbd..2865d45b9 100644 --- a/web/app/_components/LoginButton/index.tsx +++ b/web/app/_components/LoginButton/index.tsx @@ -1,4 +1,4 @@ -"use client"; +'use client' const LoginButton: React.FC = () => { // const { signInWithKeyCloak } = useSignIn(); @@ -18,7 +18,7 @@ const LoginButton: React.FC = () => { // //
    // ); - return
    ; -}; + return
    +} -export default LoginButton; +export default LoginButton diff --git a/web/app/_components/MainChat/index.tsx b/web/app/_components/MainChat/index.tsx index 4f820dd1d..b506756f6 100644 --- a/web/app/_components/MainChat/index.tsx +++ b/web/app/_components/MainChat/index.tsx @@ -1,13 +1,13 @@ -import ChatBody from "../ChatBody"; -import InputToolbar from "../InputToolbar"; -import MainChatHeader from "../MainChatHeader"; +import ChatBody from '../ChatBody' +import InputToolbar from '../InputToolbar' +import MainChatHeader from '../MainChatHeader' const MainChat: React.FC = () => ( -
    +
    -); +) -export default MainChat; +export default MainChat diff --git a/web/app/_components/MainChatHeader/index.tsx b/web/app/_components/MainChatHeader/index.tsx index 253f04e22..942fc33eb 100644 --- a/web/app/_components/MainChatHeader/index.tsx +++ b/web/app/_components/MainChatHeader/index.tsx @@ -1,11 +1,11 @@ -import ModelMenu from "../ModelMenu"; -import UserToolbar from "../UserToolbar"; +import ModelMenu from '../ModelMenu' +import UserToolbar from '../UserToolbar' const MainChatHeader: React.FC = () => ( -
    +
    -); +) -export default MainChatHeader; +export default MainChatHeader diff --git a/web/app/_components/MainContainer/index.tsx b/web/app/_components/MainContainer/index.tsx index bdc2a36ee..9220dd47c 100644 --- a/web/app/_components/MainContainer/index.tsx +++ b/web/app/_components/MainContainer/index.tsx @@ -1,11 +1,11 @@ -"use client"; +'use client' -import React from "react"; -import LeftContainer from "../LeftContainer"; -import RightContainer from "../RightContainer"; -import { Variants, motion } from "framer-motion"; -import { useAtomValue } from "jotai"; -import { leftSideBarExpandStateAtom } from "@/_helpers/atoms/LeftSideBarExpand.atom"; +import React from 'react' +import LeftContainer from '../LeftContainer' +import RightContainer from '../RightContainer' +import { Variants, motion } from 'framer-motion' +import { useAtomValue } from 'jotai' +import { leftSideBarExpandStateAtom } from '@/_helpers/atoms/LeftSideBarExpand.atom' const leftSideBarVariants: Variants = { show: { @@ -15,31 +15,31 @@ const leftSideBarVariants: Variants = { transition: { duration: 0.1 }, }, hide: { - x: "-100%", + x: '-100%', width: 0, opacity: 0, transition: { duration: 0.1 }, }, -}; +} const MainContainer: React.FC = () => { - const leftSideBarExpand = useAtomValue(leftSideBarExpandStateAtom); + const leftSideBarExpand = useAtomValue(leftSideBarExpandStateAtom) return (
    -
    +
    - ); -}; + ) +} -export default MainContainer; +export default MainContainer diff --git a/web/app/_components/MainView/index.tsx b/web/app/_components/MainView/index.tsx index 621253eea..ceec7d164 100644 --- a/web/app/_components/MainView/index.tsx +++ b/web/app/_components/MainView/index.tsx @@ -1,35 +1,35 @@ -"use client"; +'use client' -import { useAtomValue } from "jotai"; -import Welcome from "../WelcomeContainer"; -import { Preferences } from "../Preferences"; -import MyModelContainer from "../MyModelContainer"; -import ExploreModelContainer from "../ExploreModelContainer"; +import { useAtomValue } from 'jotai' +import Welcome from '../WelcomeContainer' +import { Preferences } from '../Preferences' +import MyModelContainer from '../MyModelContainer' +import ExploreModelContainer from '../ExploreModelContainer' import { MainViewState, getMainViewStateAtom, -} from "@/_helpers/atoms/MainView.atom"; -import EmptyChatContainer from "../EmptyChatContainer"; -import MainChat from "../MainChat"; +} from '@/_helpers/atoms/MainView.atom' +import EmptyChatContainer from '../EmptyChatContainer' +import MainChat from '../MainChat' const MainView: React.FC = () => { - const viewState = useAtomValue(getMainViewStateAtom); + const viewState = useAtomValue(getMainViewStateAtom) switch (viewState) { case MainViewState.ConversationEmptyModel: - return ; + return case MainViewState.ExploreModel: - return ; + return case MainViewState.Setting: - return ; + return case MainViewState.ResourceMonitor: case MainViewState.MyModel: - return ; + return case MainViewState.Welcome: - return ; + return default: - return ; + return } -}; +} -export default MainView; +export default MainView diff --git a/web/app/_components/MenuHeader/index.tsx b/web/app/_components/MenuHeader/index.tsx index 851af41c1..0dc51ef97 100644 --- a/web/app/_components/MenuHeader/index.tsx +++ b/web/app/_components/MenuHeader/index.tsx @@ -1,53 +1,53 @@ -import Link from "next/link"; -import { Popover, Transition } from "@headlessui/react"; -import { Fragment } from "react"; -// import useGetCurrentUser from "@/_hooks/useGetCurrentUser"; -import { useSetAtom } from "jotai"; -import { showConfirmSignOutModalAtom } from "@/_helpers/atoms/Modal.atom"; - -export const MenuHeader: React.FC = () => { - const setShowConfirmSignOutModal = useSetAtom(showConfirmSignOutModalAtom); - // const { user } = useGetCurrentUser(); - - return
    ; - - // return ( - // - // - //
    - //

    - // {user.displayName} - //

    - // - // {user.email} - // - //
    - //
    - // - //
    - //
    - // - // Privacy - // - //
    - // - // Support - // - //
    - // - // - // ); -}; +import Link from 'next/link' +import { Popover, Transition } from '@headlessui/react' +import { Fragment } from 'react' +// import useGetCurrentUser from "@/_hooks/useGetCurrentUser"; +import { useSetAtom } from 'jotai' +import { showConfirmSignOutModalAtom } from '@/_helpers/atoms/Modal.atom' + +export const MenuHeader: React.FC = () => { + const setShowConfirmSignOutModal = useSetAtom(showConfirmSignOutModalAtom) + // const { user } = useGetCurrentUser(); + + return
    + + // return ( + // + // + //
    + //

    + // {user.displayName} + //

    + // + // {user.email} + // + //
    + //
    + // + //
    + //
    + // + // Privacy + // + //
    + // + // Support + // + //
    + // + // + // ); +} diff --git a/web/app/_components/MobileMenuPane/index.tsx b/web/app/_components/MobileMenuPane/index.tsx index 27dff1a52..d8b73196c 100644 --- a/web/app/_components/MobileMenuPane/index.tsx +++ b/web/app/_components/MobileMenuPane/index.tsx @@ -1,13 +1,13 @@ -import React, { useRef } from "react"; -import { Dialog } from "@headlessui/react"; -import { XMarkIcon } from "@heroicons/react/24/outline"; -import Image from "next/image"; -import { useAtom } from "jotai"; -import { showingMobilePaneAtom } from "@/_helpers/atoms/Modal.atom"; +import React, { useRef } from 'react' +import { Dialog } from '@headlessui/react' +import { XMarkIcon } from '@heroicons/react/24/outline' +import Image from 'next/image' +import { useAtom } from 'jotai' +import { showingMobilePaneAtom } from '@/_helpers/atoms/Modal.atom' const MobileMenuPane: React.FC = () => { - const [show, setShow] = useAtom(showingMobilePaneAtom); - let loginRef = useRef(null); + const [show, setShow] = useAtom(showingMobilePaneAtom) + let loginRef = useRef(null) return ( {
    - ); -}; + ) +} -export default MobileMenuPane; +export default MobileMenuPane diff --git a/web/app/_components/ModelActionButton/index.tsx b/web/app/_components/ModelActionButton/index.tsx index 2f3035441..afa7deaea 100644 --- a/web/app/_components/ModelActionButton/index.tsx +++ b/web/app/_components/ModelActionButton/index.tsx @@ -1,46 +1,50 @@ -import React from "react"; -import PrimaryButton from "../PrimaryButton"; +import React from 'react' +import PrimaryButton from '../PrimaryButton' export enum ModelActionType { - Start = "Start", - Stop = "Stop", + Start = 'Start', + Stop = 'Stop', } type ModelActionStyle = { - title: string; - backgroundColor: string; - textColor: string; -}; + title: string + backgroundColor: string + textColor: string +} const modelActionMapper: Record = { [ModelActionType.Start]: { - title: "Start", - backgroundColor: "bg-blue-500 hover:bg-blue-600", - textColor: "text-white", + title: 'Start', + backgroundColor: 'bg-blue-500 hover:bg-blue-600', + textColor: 'text-white', }, [ModelActionType.Stop]: { - title: "Stop", - backgroundColor: "bg-red-500 hover:bg-red-600", - textColor: "text-white", + title: 'Stop', + backgroundColor: 'bg-red-500 hover:bg-red-600', + textColor: 'text-white', }, -}; +} type Props = { - type: ModelActionType; - onActionClick: (type: ModelActionType) => void; -}; + type: ModelActionType + onActionClick: (type: ModelActionType) => void +} const ModelActionButton: React.FC = ({ type, onActionClick }) => { - const styles = modelActionMapper[type]; + const styles = modelActionMapper[type] const onClick = () => { - onActionClick(type); - }; + onActionClick(type) + } return ( - + - ); -}; + ) +} -export default ModelActionButton; +export default ModelActionButton diff --git a/web/app/_components/ModelActionMenu/index.tsx b/web/app/_components/ModelActionMenu/index.tsx index cc8e4ad20..58c97585a 100644 --- a/web/app/_components/ModelActionMenu/index.tsx +++ b/web/app/_components/ModelActionMenu/index.tsx @@ -1,10 +1,10 @@ -import { Menu, Transition } from "@headlessui/react"; -import { EllipsisVerticalIcon } from "@heroicons/react/20/solid"; -import { Fragment } from "react"; +import { Menu, Transition } from '@headlessui/react' +import { EllipsisVerticalIcon } from '@heroicons/react/20/solid' +import { Fragment } from 'react' type Props = { - onDeleteClick: () => void; -}; + onDeleteClick: () => void +} const ModelActionMenu: React.FC = ({ onDeleteClick }) => ( @@ -26,7 +26,7 @@ const ModelActionMenu: React.FC = ({ onDeleteClick }) => ( {({ active }) => ( -); +) -export default ModelActionMenu; +export default ModelActionMenu diff --git a/web/app/_components/ModelDownloadButton/index.tsx b/web/app/_components/ModelDownloadButton/index.tsx index b8610dc41..144369eaa 100644 --- a/web/app/_components/ModelDownloadButton/index.tsx +++ b/web/app/_components/ModelDownloadButton/index.tsx @@ -1,21 +1,21 @@ -import { ArrowDownTrayIcon } from "@heroicons/react/24/outline"; +import { ArrowDownTrayIcon } from '@heroicons/react/24/outline' type Props = { - callback: () => void; -}; + callback: () => void +} const ModelDownloadButton: React.FC = ({ callback }) => { return ( - ); -}; + ) +} -export default ModelDownloadButton; +export default ModelDownloadButton diff --git a/web/app/_components/ModelDownloadingButton/index.tsx b/web/app/_components/ModelDownloadingButton/index.tsx index 30bb3f877..cebb2d661 100644 --- a/web/app/_components/ModelDownloadingButton/index.tsx +++ b/web/app/_components/ModelDownloadingButton/index.tsx @@ -1,23 +1,23 @@ -import { toGigabytes } from "@/_utils/converter"; +import { toGigabytes } from '@/_utils/converter' type Props = { - total: number; - value: number; -}; + total: number + value: number +} const ModelDownloadingButton: React.FC = ({ total, value }) => { return (
    - -
    +
    {toGigabytes(value)} / {toGigabytes(total)}
    - ); -}; + ) +} -export default ModelDownloadingButton; +export default ModelDownloadingButton diff --git a/web/app/_components/ModelDownloadingRow/index.tsx b/web/app/_components/ModelDownloadingRow/index.tsx index 0130cd0b1..d507d0615 100644 --- a/web/app/_components/ModelDownloadingRow/index.tsx +++ b/web/app/_components/ModelDownloadingRow/index.tsx @@ -1,18 +1,18 @@ -import React from "react"; -import { DownloadState } from "@/_models/DownloadState"; +import React from 'react' +import { DownloadState } from '@/_models/DownloadState' import { formatDownloadPercentage, formatDownloadSpeed, toGigabytes, -} from "@/_utils/converter"; +} from '@/_utils/converter' type Props = { - downloadState: DownloadState; -}; + downloadState: DownloadState +} const ModelDownloadingRow: React.FC = ({ downloadState }) => ( @@ -31,6 +31,6 @@ const ModelDownloadingRow: React.FC = ({ downloadState }) => ( {formatDownloadSpeed(downloadState.speed)} -); +) -export default ModelDownloadingRow; +export default ModelDownloadingRow diff --git a/web/app/_components/ModelDownloadingTable/index.tsx b/web/app/_components/ModelDownloadingTable/index.tsx index 75a20443e..bc5e35e12 100644 --- a/web/app/_components/ModelDownloadingTable/index.tsx +++ b/web/app/_components/ModelDownloadingTable/index.tsx @@ -1,23 +1,23 @@ -import React from "react"; -import ModelTableHeader from "../ModelTableHeader"; -import { DownloadState } from "@/_models/DownloadState"; -import ModelDownloadingRow from "../ModelDownloadingRow"; +import React from 'react' +import ModelTableHeader from '../ModelTableHeader' +import { DownloadState } from '@/_models/DownloadState' +import ModelDownloadingRow from '../ModelDownloadingRow' type Props = { - downloadStates: DownloadState[]; -}; + downloadStates: DownloadState[] +} -const tableHeaders = ["MODEL", "TRANSFERRED", "SIZE", "PERCENTAGE", "SPEED"]; +const tableHeaders = ['MODEL', 'TRANSFERRED', 'SIZE', 'PERCENTAGE', 'SPEED'] const ModelDownloadingTable: React.FC = ({ downloadStates }) => ( -
    +
    - + {tableHeaders.map((item) => ( ))} - @@ -29,6 +29,6 @@ const ModelDownloadingTable: React.FC = ({ downloadStates }) => (
    + Edit
    -); +) -export default React.memo(ModelDownloadingTable); +export default React.memo(ModelDownloadingTable) diff --git a/web/app/_components/ModelInfo/index.tsx b/web/app/_components/ModelInfo/index.tsx index ceb867204..fae37949c 100644 --- a/web/app/_components/ModelInfo/index.tsx +++ b/web/app/_components/ModelInfo/index.tsx @@ -1,42 +1,42 @@ -import Image from "next/image"; -import ModelInfoItem from "../ModelInfoItem"; -import React from "react"; - -type Props = { - modelName: string; - inferenceTime: string; - hardware: string; - pricing: string; -}; - -const ModelInfo: React.FC = ({ - modelName, - inferenceTime, - hardware, - pricing, -}) => ( -
    -

    - {modelName} is available via Jan API -

    -
    - - -
    -
    -
    -
    -

    {pricing}

    - - Average Cost / Call - -
    - -
    -
    -); - -export default React.memo(ModelInfo); +import Image from 'next/image' +import ModelInfoItem from '../ModelInfoItem' +import React from 'react' + +type Props = { + modelName: string + inferenceTime: string + hardware: string + pricing: string +} + +const ModelInfo: React.FC = ({ + modelName, + inferenceTime, + hardware, + pricing, +}) => ( +
    +

    + {modelName} is available via Jan API +

    +
    + + +
    +
    +
    +
    +

    {pricing}

    + + Average Cost / Call + +
    + +
    +
    +) + +export default React.memo(ModelInfo) diff --git a/web/app/_components/ModelInfoItem/index.tsx b/web/app/_components/ModelInfoItem/index.tsx index 406893631..95c5acf27 100644 --- a/web/app/_components/ModelInfoItem/index.tsx +++ b/web/app/_components/ModelInfoItem/index.tsx @@ -1,15 +1,15 @@ -import React from "react"; - -type Props = { - name: string; - description: string; -}; - -const ModelInfoItem: React.FC = ({ description, name }) => ( -
    - {name} - {description} -
    -); - -export default React.memo(ModelInfoItem); +import React from 'react' + +type Props = { + name: string + description: string +} + +const ModelInfoItem: React.FC = ({ description, name }) => ( +
    + {name} + {description} +
    +) + +export default React.memo(ModelInfoItem) diff --git a/web/app/_components/ModelMenu/index.tsx b/web/app/_components/ModelMenu/index.tsx index 23170a5c9..4ab591f84 100644 --- a/web/app/_components/ModelMenu/index.tsx +++ b/web/app/_components/ModelMenu/index.tsx @@ -1,21 +1,21 @@ -"use client"; - -import { useSetAtom } from "jotai"; -import { TrashIcon } from "@heroicons/react/24/outline"; -import { showConfirmDeleteConversationModalAtom } from "@/_helpers/atoms/Modal.atom"; - -const ModelMenu: React.FC = () => { - const setShowConfirmDeleteConversationModal = useSetAtom( - showConfirmDeleteConversationModalAtom - ); - - return ( -
    - -
    - ); -}; - -export default ModelMenu; +'use client' + +import { useSetAtom } from 'jotai' +import { TrashIcon } from '@heroicons/react/24/outline' +import { showConfirmDeleteConversationModalAtom } from '@/_helpers/atoms/Modal.atom' + +const ModelMenu: React.FC = () => { + const setShowConfirmDeleteConversationModal = useSetAtom( + showConfirmDeleteConversationModalAtom + ) + + return ( +
    + +
    + ) +} + +export default ModelMenu diff --git a/web/app/_components/ModelRow/index.tsx b/web/app/_components/ModelRow/index.tsx index cafd68fd7..6d9e01496 100644 --- a/web/app/_components/ModelRow/index.tsx +++ b/web/app/_components/ModelRow/index.tsx @@ -1,50 +1,50 @@ -import React, { useCallback } from "react"; -import { ModelStatus, ModelStatusComponent } from "../ModelStatusComponent"; -import ModelActionMenu from "../ModelActionMenu"; -import { useAtomValue } from "jotai"; -import ModelActionButton, { ModelActionType } from "../ModelActionButton"; -import useStartStopModel from "@/_hooks/useStartStopModel"; -import useDeleteModel from "@/_hooks/useDeleteModel"; -import { AssistantModel } from "@/_models/AssistantModel"; -import { activeAssistantModelAtom } from "@/_helpers/atoms/Model.atom"; -import { toGigabytes } from "@/_utils/converter"; +import React, { useCallback } from 'react' +import { ModelStatus, ModelStatusComponent } from '../ModelStatusComponent' +import ModelActionMenu from '../ModelActionMenu' +import { useAtomValue } from 'jotai' +import ModelActionButton, { ModelActionType } from '../ModelActionButton' +import useStartStopModel from '@/_hooks/useStartStopModel' +import useDeleteModel from '@/_hooks/useDeleteModel' +import { AssistantModel } from '@/_models/AssistantModel' +import { activeAssistantModelAtom } from '@/_helpers/atoms/Model.atom' +import { toGigabytes } from '@/_utils/converter' type Props = { - model: AssistantModel; -}; + model: AssistantModel +} const ModelRow: React.FC = ({ model }) => { - const { startModel, stopModel } = useStartStopModel(); - const activeModel = useAtomValue(activeAssistantModelAtom); - const { deleteModel } = useDeleteModel(); + const { startModel, stopModel } = useStartStopModel() + const activeModel = useAtomValue(activeAssistantModelAtom) + const { deleteModel } = useDeleteModel() - let status = ModelStatus.Installed; + let status = ModelStatus.Installed if (activeModel && activeModel._id === model._id) { - status = ModelStatus.Active; + status = ModelStatus.Active } - let actionButtonType = ModelActionType.Start; + let actionButtonType = ModelActionType.Start if (activeModel && activeModel._id === model._id) { - actionButtonType = ModelActionType.Stop; + actionButtonType = ModelActionType.Stop } const onModelActionClick = (action: ModelActionType) => { if (action === ModelActionType.Start) { - startModel(model._id); + startModel(model._id) } else { - stopModel(model._id); + stopModel(model._id) } - }; + } const onDeleteClick = useCallback(() => { - deleteModel(model); - }, [model]); + deleteModel(model) + }, [model]) return ( - + {model.name} - {model.version} + {model.version}
    @@ -61,11 +61,11 @@ const ModelRow: React.FC = ({ model }) => { type={actionButtonType} onActionClick={onModelActionClick} /> - + - ); -}; + ) +} -export default ModelRow; +export default ModelRow diff --git a/web/app/_components/ModelSearchBar/index.tsx b/web/app/_components/ModelSearchBar/index.tsx index ffa1e3f85..04ff6f726 100644 --- a/web/app/_components/ModelSearchBar/index.tsx +++ b/web/app/_components/ModelSearchBar/index.tsx @@ -1,31 +1,31 @@ -"use client"; +'use client' -import { searchingModelText } from "@/_helpers/JotaiWrapper"; -import { MagnifyingGlassIcon } from "@heroicons/react/24/outline"; -import { useSetAtom } from "jotai"; -import { useEffect, useState } from "react"; +import { searchingModelText } from '@/_helpers/JotaiWrapper' +import { MagnifyingGlassIcon } from '@heroicons/react/24/outline' +import { useSetAtom } from 'jotai' +import { useEffect, useState } from 'react' const ModelSearchBar: React.FC = () => { - const setSearchtext = useSetAtom(searchingModelText); - const [text, setText] = useState(""); + const setSearchtext = useSetAtom(searchingModelText) + const [text, setText] = useState('') useEffect(() => { - setSearchtext(text); - }, [text, setSearchtext]); + setSearchtext(text) + }, [text, setSearchtext]) return ( -
    -
    +
    +
    setText(text.currentTarget.value)} /> -
    - ); -}; + ) +} -export default ModelSearchBar; +export default ModelSearchBar diff --git a/web/app/_components/ModelSelector/index.tsx b/web/app/_components/ModelSelector/index.tsx index cbb564e27..bc6032783 100644 --- a/web/app/_components/ModelSelector/index.tsx +++ b/web/app/_components/ModelSelector/index.tsx @@ -1,31 +1,31 @@ -import { Fragment, useEffect } from "react"; -import { Listbox, Transition } from "@headlessui/react"; -import { CheckIcon, ChevronUpDownIcon } from "@heroicons/react/20/solid"; -import { useAtom, useAtomValue } from "jotai"; -import { selectedModelAtom } from "@/_helpers/atoms/Model.atom"; -import { downloadedModelAtom } from "@/_helpers/atoms/DownloadedModel.atom"; -import { AssistantModel } from "@/_models/AssistantModel"; +import { Fragment, useEffect } from 'react' +import { Listbox, Transition } from '@headlessui/react' +import { CheckIcon, ChevronUpDownIcon } from '@heroicons/react/20/solid' +import { useAtom, useAtomValue } from 'jotai' +import { selectedModelAtom } from '@/_helpers/atoms/Model.atom' +import { downloadedModelAtom } from '@/_helpers/atoms/DownloadedModel.atom' +import { AssistantModel } from '@/_models/AssistantModel' function classNames(...classes: any) { - return classes.filter(Boolean).join(" "); + return classes.filter(Boolean).join(' ') } const SelectModels: React.FC = () => { - const downloadedModels = useAtomValue(downloadedModelAtom); - const [selectedModel, setSelectedModel] = useAtom(selectedModelAtom); + const downloadedModels = useAtomValue(downloadedModelAtom) + const [selectedModel, setSelectedModel] = useAtom(selectedModelAtom) useEffect(() => { if (downloadedModels && downloadedModels.length > 0) { - onModelSelected(downloadedModels[0]); + onModelSelected(downloadedModels[0]) } - }, [downloadedModels]); + }, [downloadedModels]) const onModelSelected = (model: AssistantModel) => { - setSelectedModel(model); - }; + setSelectedModel(model) + } if (!selectedModel) { - return
    You have not downloaded any model!
    ; + return
    You have not downloaded any model!
    } return ( @@ -68,8 +68,8 @@ const SelectModels: React.FC = () => { key={model._id} className={({ active }) => classNames( - active ? "bg-blue-600 text-white" : "text-gray-900", - "relative cursor-default select-none py-2 pl-3 pr-9", + active ? 'bg-blue-600 text-white' : 'text-gray-900', + 'relative cursor-default select-none py-2 pl-3 pr-9' ) } value={model} @@ -84,8 +84,8 @@ const SelectModels: React.FC = () => { /> {model.name} @@ -95,8 +95,8 @@ const SelectModels: React.FC = () => { {selected ? (
    )} - ); -}; + ) +} -export default SelectModels; +export default SelectModels diff --git a/web/app/_components/ModelStatusComponent/index.tsx b/web/app/_components/ModelStatusComponent/index.tsx index b6cae0457..08d4bb59f 100644 --- a/web/app/_components/ModelStatusComponent/index.tsx +++ b/web/app/_components/ModelStatusComponent/index.tsx @@ -1,10 +1,10 @@ -import React from "react"; +import React from 'react' export type ModelStatusType = { - title: string; - textColor: string; - backgroundColor: string; -}; + title: string + textColor: string + backgroundColor: string +} export enum ModelStatus { Installed, @@ -14,33 +14,33 @@ export enum ModelStatus { export const ModelStatusMapper: Record = { [ModelStatus.Installed]: { - title: "Installed", - textColor: "text-black", - backgroundColor: "bg-gray-100", + title: 'Installed', + textColor: 'text-black', + backgroundColor: 'bg-gray-100', }, [ModelStatus.Active]: { - title: "Active", - textColor: "text-black", - backgroundColor: "bg-green-100", + title: 'Active', + textColor: 'text-black', + backgroundColor: 'bg-green-100', }, [ModelStatus.RunningInNitro]: { - title: "Running in Nitro", - textColor: "text-black", - backgroundColor: "bg-green-100", + title: 'Running in Nitro', + textColor: 'text-black', + backgroundColor: 'bg-green-100', }, -}; +} type Props = { - status: ModelStatus; -}; + status: ModelStatus +} export const ModelStatusComponent: React.FC = ({ status }) => { - const statusType = ModelStatusMapper[status]; + const statusType = ModelStatusMapper[status] return (
    {statusType.title}
    - ); -}; + ) +} diff --git a/web/app/_components/ModelTable/index.tsx b/web/app/_components/ModelTable/index.tsx index 771c60058..41bf49799 100644 --- a/web/app/_components/ModelTable/index.tsx +++ b/web/app/_components/ModelTable/index.tsx @@ -1,23 +1,23 @@ -import React from "react"; -import ModelRow from "../ModelRow"; -import ModelTableHeader from "../ModelTableHeader"; -import { AssistantModel } from "@/_models/AssistantModel"; +import React from 'react' +import ModelRow from '../ModelRow' +import ModelTableHeader from '../ModelTableHeader' +import { AssistantModel } from '@/_models/AssistantModel' type Props = { - models: AssistantModel[]; -}; + models: AssistantModel[] +} -const tableHeaders = ["MODEL", "FORMAT", "SIZE", "STATUS", "ACTIONS"]; +const tableHeaders = ['MODEL', 'FORMAT', 'SIZE', 'STATUS', 'ACTIONS'] const ModelTable: React.FC = ({ models }) => ( -
    +
    - + {tableHeaders.map((item) => ( ))} - @@ -29,6 +29,6 @@ const ModelTable: React.FC = ({ models }) => (
    + Edit
    -); +) -export default React.memo(ModelTable); +export default React.memo(ModelTable) diff --git a/web/app/_components/ModelTableHeader/index.tsx b/web/app/_components/ModelTableHeader/index.tsx index b335888ee..0ac18d3dc 100644 --- a/web/app/_components/ModelTableHeader/index.tsx +++ b/web/app/_components/ModelTableHeader/index.tsx @@ -1,16 +1,16 @@ -import React from "react"; +import React from 'react' type Props = { - title: string; -}; + title: string +} const ModelTableHeader: React.FC = ({ title }) => ( {title} -); +) -export default React.memo(ModelTableHeader); +export default React.memo(ModelTableHeader) diff --git a/web/app/_components/ModelVersionItem/index.tsx b/web/app/_components/ModelVersionItem/index.tsx index d68c538dd..d0eb4c7ad 100644 --- a/web/app/_components/ModelVersionItem/index.tsx +++ b/web/app/_components/ModelVersionItem/index.tsx @@ -1,70 +1,70 @@ -import React, { useMemo } from "react"; -import { formatDownloadPercentage, toGigabytes } from "@/_utils/converter"; -import Image from "next/image"; -import { Product } from "@/_models/Product"; -import useDownloadModel from "@/_hooks/useDownloadModel"; -import { modelDownloadStateAtom } from "@/_helpers/atoms/DownloadState.atom"; -import { atom, useAtomValue } from "jotai"; -import { ModelVersion } from "@/_models/ModelVersion"; -import { useGetDownloadedModels } from "@/_hooks/useGetDownloadedModels"; -import SimpleTag from "../SimpleTag"; -import { RamRequired, UsecaseTag } from "../SimpleTag/TagType"; +import React, { useMemo } from 'react' +import { formatDownloadPercentage, toGigabytes } from '@/_utils/converter' +import Image from 'next/image' +import { Product } from '@/_models/Product' +import useDownloadModel from '@/_hooks/useDownloadModel' +import { modelDownloadStateAtom } from '@/_helpers/atoms/DownloadState.atom' +import { atom, useAtomValue } from 'jotai' +import { ModelVersion } from '@/_models/ModelVersion' +import { useGetDownloadedModels } from '@/_hooks/useGetDownloadedModels' +import SimpleTag from '../SimpleTag' +import { RamRequired, UsecaseTag } from '../SimpleTag/TagType' type Props = { - model: Product; - modelVersion: ModelVersion; - isRecommended: boolean; -}; + model: Product + modelVersion: ModelVersion + isRecommended: boolean +} const ModelVersionItem: React.FC = ({ model, modelVersion, isRecommended, }) => { - const { downloadModel } = useDownloadModel(); - const { downloadedModels } = useGetDownloadedModels(); + const { downloadModel } = useDownloadModel() + const { downloadedModels } = useGetDownloadedModels() const isDownloaded = - downloadedModels.find((model) => model._id === modelVersion._id) != null; + downloadedModels.find((model) => model._id === modelVersion._id) != null const downloadAtom = useMemo( - () => atom((get) => get(modelDownloadStateAtom)[modelVersion._id ?? ""]), + () => atom((get) => get(modelDownloadStateAtom)[modelVersion._id ?? '']), [modelVersion._id] - ); - const downloadState = useAtomValue(downloadAtom); + ) + const downloadState = useAtomValue(downloadAtom) const onDownloadClick = () => { - downloadModel(model, modelVersion); - }; + downloadModel(model, modelVersion) + } let downloadButton = ( - ); + ) if (downloadState) { downloadButton = (
    {formatDownloadPercentage(downloadState.percent)}
    - ); + ) } else if (isDownloaded) { - downloadButton =
    Downloaded
    ; + downloadButton =
    Downloaded
    } - const { maxRamRequired, usecase } = modelVersion; + const { maxRamRequired, usecase } = modelVersion return ( -
    +
    - - + + {modelVersion.name}
    -
    +
    = ({ clickable={false} />
    -
    +
    {toGigabytes(modelVersion.size)}
    {downloadButton}
    - ); -}; + ) +} -export default ModelVersionItem; +export default ModelVersionItem diff --git a/web/app/_components/ModelVersionList/index.tsx b/web/app/_components/ModelVersionList/index.tsx index 79fba8642..5ddf280fc 100644 --- a/web/app/_components/ModelVersionList/index.tsx +++ b/web/app/_components/ModelVersionList/index.tsx @@ -1,13 +1,13 @@ -import React from "react"; -import ModelVersionItem from "../ModelVersionItem"; -import { Product } from "@/_models/Product"; -import { ModelVersion } from "@/_models/ModelVersion"; +import React from 'react' +import ModelVersionItem from '../ModelVersionItem' +import { Product } from '@/_models/Product' +import { ModelVersion } from '@/_models/ModelVersion' type Props = { - model: Product; - versions: ModelVersion[]; - recommendedVersion: string; -}; + model: Product + versions: ModelVersion[] + recommendedVersion: string +} const ModelVersionList: React.FC = ({ model, @@ -15,11 +15,11 @@ const ModelVersionList: React.FC = ({ recommendedVersion, }) => { return ( -
    +
    Available Versions
    -
    +
    {versions.map((item) => ( = ({ ))}
    - ); -}; + ) +} -export default ModelVersionList; +export default ModelVersionList diff --git a/web/app/_components/MonitorBar/index.tsx b/web/app/_components/MonitorBar/index.tsx index 3ded033f6..6d6b48503 100644 --- a/web/app/_components/MonitorBar/index.tsx +++ b/web/app/_components/MonitorBar/index.tsx @@ -1,24 +1,24 @@ -import ProgressBar from "../ProgressBar"; -import SystemItem from "../SystemItem"; -import { useAtomValue } from "jotai"; -import { appDownloadProgress } from "@/_helpers/JotaiWrapper"; -import useGetAppVersion from "@/_hooks/useGetAppVersion"; -import useGetSystemResources from "@/_hooks/useGetSystemResources"; -import { modelDownloadStateAtom } from "@/_helpers/atoms/DownloadState.atom"; -import { DownloadState } from "@/_models/DownloadState"; -import { formatDownloadPercentage } from "@/_utils/converter"; -import { activeAssistantModelAtom } from "@/_helpers/atoms/Model.atom"; +import ProgressBar from '../ProgressBar' +import SystemItem from '../SystemItem' +import { useAtomValue } from 'jotai' +import { appDownloadProgress } from '@/_helpers/JotaiWrapper' +import useGetAppVersion from '@/_hooks/useGetAppVersion' +import useGetSystemResources from '@/_hooks/useGetSystemResources' +import { modelDownloadStateAtom } from '@/_helpers/atoms/DownloadState.atom' +import { DownloadState } from '@/_models/DownloadState' +import { formatDownloadPercentage } from '@/_utils/converter' +import { activeAssistantModelAtom } from '@/_helpers/atoms/Model.atom' const MonitorBar: React.FC = () => { - const progress = useAtomValue(appDownloadProgress); - const activeModel = useAtomValue(activeAssistantModelAtom); - const { version } = useGetAppVersion(); - const { ram, cpu } = useGetSystemResources(); - const modelDownloadStates = useAtomValue(modelDownloadStateAtom); + const progress = useAtomValue(appDownloadProgress) + const activeModel = useAtomValue(activeAssistantModelAtom) + const { version } = useGetAppVersion() + const { ram, cpu } = useGetSystemResources() + const modelDownloadStates = useAtomValue(modelDownloadStateAtom) - const downloadStates: DownloadState[] = []; + const downloadStates: DownloadState[] = [] for (const [, value] of Object.entries(modelDownloadStates)) { - downloadStates.push(value); + downloadStates.push(value) } return ( @@ -26,7 +26,7 @@ const MonitorBar: React.FC = () => { {progress && progress >= 0 ? ( ) : null} -
    +
    {downloadStates.length > 0 && ( { {activeModel && ( - + )} - v{version} + v{version}
    - ); -}; + ) +} -export default MonitorBar; +export default MonitorBar diff --git a/web/app/_components/MyModelContainer/index.tsx b/web/app/_components/MyModelContainer/index.tsx index 36cde130b..1b6be685b 100644 --- a/web/app/_components/MyModelContainer/index.tsx +++ b/web/app/_components/MyModelContainer/index.tsx @@ -1,17 +1,17 @@ -import HeaderTitle from "../HeaderTitle"; -import DownloadedModelTable from "../DownloadedModelTable"; -import ActiveModelTable from "../ActiveModelTable"; -import DownloadingModelTable from "../DownloadingModelTable"; - -const MyModelContainer: React.FC = () => ( -
    - -
    - - - -
    -
    -); - -export default MyModelContainer; +import HeaderTitle from '../HeaderTitle' +import DownloadedModelTable from '../DownloadedModelTable' +import ActiveModelTable from '../ActiveModelTable' +import DownloadingModelTable from '../DownloadingModelTable' + +const MyModelContainer: React.FC = () => ( +
    + +
    + + + +
    +
    +) + +export default MyModelContainer diff --git a/web/app/_components/NewChatButton/index.tsx b/web/app/_components/NewChatButton/index.tsx index 2ac6ad184..b7a885516 100644 --- a/web/app/_components/NewChatButton/index.tsx +++ b/web/app/_components/NewChatButton/index.tsx @@ -1,45 +1,45 @@ -"use client"; +'use client' -import React from "react"; -import SecondaryButton from "../SecondaryButton"; -import { useAtomValue, useSetAtom } from "jotai"; +import React from 'react' +import SecondaryButton from '../SecondaryButton' +import { useAtomValue, useSetAtom } from 'jotai' import { MainViewState, setMainViewStateAtom, -} from "@/_helpers/atoms/MainView.atom"; -import useCreateConversation from "@/_hooks/useCreateConversation"; -import useInitModel from "@/_hooks/useInitModel"; -import { PlusIcon } from "@heroicons/react/24/outline"; -import { activeAssistantModelAtom } from "@/_helpers/atoms/Model.atom"; -import { AssistantModel } from "@/_models/AssistantModel"; +} from '@/_helpers/atoms/MainView.atom' +import useCreateConversation from '@/_hooks/useCreateConversation' +import useInitModel from '@/_hooks/useInitModel' +import { PlusIcon } from '@heroicons/react/24/outline' +import { activeAssistantModelAtom } from '@/_helpers/atoms/Model.atom' +import { AssistantModel } from '@/_models/AssistantModel' const NewChatButton: React.FC = () => { - const activeModel = useAtomValue(activeAssistantModelAtom); - const setMainView = useSetAtom(setMainViewStateAtom); - const { requestCreateConvo } = useCreateConversation(); - const { initModel } = useInitModel(); + const activeModel = useAtomValue(activeAssistantModelAtom) + const setMainView = useSetAtom(setMainViewStateAtom) + const { requestCreateConvo } = useCreateConversation() + const { initModel } = useInitModel() const onClick = () => { if (!activeModel) { - setMainView(MainViewState.ConversationEmptyModel); + setMainView(MainViewState.ConversationEmptyModel) } else { - createConversationAndInitModel(activeModel); + createConversationAndInitModel(activeModel) } - }; + } const createConversationAndInitModel = async (model: AssistantModel) => { - await requestCreateConvo(model); - await initModel(model); - }; + await requestCreateConvo(model) + await initModel(model) + } return ( } /> - ); -}; + ) +} -export default React.memo(NewChatButton); +export default React.memo(NewChatButton) diff --git a/web/app/_components/Preferences.tsx b/web/app/_components/Preferences.tsx index a48d9543e..021f6d2f8 100644 --- a/web/app/_components/Preferences.tsx +++ b/web/app/_components/Preferences.tsx @@ -1,25 +1,32 @@ -"use client"; -import { useEffect, useRef, useState } from "react"; -import { plugins, extensionPoints } from "@/../../electron/core/plugin-manager/execution/index"; -import { ChartPieIcon, CommandLineIcon, PlayIcon } from "@heroicons/react/24/outline"; +'use client' +import { useEffect, useRef, useState } from 'react' +import { + plugins, + extensionPoints, +} from '@/../../electron/core/plugin-manager/execution/index' +import { + ChartPieIcon, + CommandLineIcon, + PlayIcon, +} from '@heroicons/react/24/outline' -import { MagnifyingGlassIcon } from "@heroicons/react/20/solid"; -import classNames from "classnames"; -import { PluginService, preferences } from "@janhq/core"; -import { execute } from "../../../electron/core/plugin-manager/execution/extension-manager"; -import LoadingIndicator from "./LoadingIndicator"; +import { MagnifyingGlassIcon } from '@heroicons/react/20/solid' +import classNames from 'classnames' +import { PluginService, preferences } from '@janhq/core' +import { execute } from '../../../electron/core/plugin-manager/execution/extension-manager' +import LoadingIndicator from './LoadingIndicator' export const Preferences = () => { - const [search, setSearch] = useState(""); - const [activePlugins, setActivePlugins] = useState([]); - const [preferenceItems, setPreferenceItems] = useState([]); - const [preferenceValues, setPreferenceValues] = useState([]); - const [isTestAvailable, setIsTestAvailable] = useState(false); - const [fileName, setFileName] = useState(""); - const [pluginCatalog, setPluginCatalog] = useState([]); - const [isLoading, setIsLoading] = useState(false); - const experimentRef = useRef(null); - const preferenceRef = useRef(null); + const [search, setSearch] = useState('') + const [activePlugins, setActivePlugins] = useState([]) + const [preferenceItems, setPreferenceItems] = useState([]) + const [preferenceValues, setPreferenceValues] = useState([]) + const [isTestAvailable, setIsTestAvailable] = useState(false) + const [fileName, setFileName] = useState('') + const [pluginCatalog, setPluginCatalog] = useState([]) + const [isLoading, setIsLoading] = useState(false) + const experimentRef = useRef(null) + const preferenceRef = useRef(null) /** * Loads the plugin catalog module from a CDN and sets it as the plugin catalog state. @@ -28,10 +35,10 @@ export const Preferences = () => { useEffect(() => { // @ts-ignore import(/* webpackIgnore: true */ PLUGIN_CATALOGS).then((module) => { - console.log(module); - setPluginCatalog(module.default); - }); - }, []); + console.log(module) + setPluginCatalog(module.default) + }) + }, []) /** * Fetches the active plugins and their preferences from the `plugins` and `preferences` modules. @@ -42,36 +49,42 @@ export const Preferences = () => { */ useEffect(() => { const getActivePlugins = async () => { - const plgs = await plugins.getActive(); - setActivePlugins(plgs); + const plgs = await plugins.getActive() + setActivePlugins(plgs) - if (extensionPoints.get("experimentComponent")) { - const components = await Promise.all(extensionPoints.execute("experimentComponent")); + if (extensionPoints.get('experimentComponent')) { + const components = await Promise.all( + extensionPoints.execute('experimentComponent') + ) if (components.length > 0) { - setIsTestAvailable(true); + setIsTestAvailable(true) } components.forEach((e) => { if (experimentRef.current) { // @ts-ignore - experimentRef.current.appendChild(e); + experimentRef.current.appendChild(e) } - }); + }) } - if (extensionPoints.get("PluginPreferences")) { - const data = await Promise.all(extensionPoints.execute("PluginPreferences")); - setPreferenceItems(Array.isArray(data) ? data : []); + if (extensionPoints.get('PluginPreferences')) { + const data = await Promise.all( + extensionPoints.execute('PluginPreferences') + ) + setPreferenceItems(Array.isArray(data) ? data : []) Promise.all( (Array.isArray(data) ? data : []).map((e) => - preferences.get(e.pluginName, e.preferenceKey).then((k) => ({ key: e.preferenceKey, value: k })) + preferences + .get(e.pluginName, e.preferenceKey) + .then((k) => ({ key: e.preferenceKey, value: k })) ) ).then((data) => { - setPreferenceValues(data); - }); + setPreferenceValues(data) + }) } - }; - getActivePlugins(); - }, []); + } + getActivePlugins() + }, []) /** * Installs a plugin by calling the `plugins.install` function with the plugin file path. @@ -79,15 +92,15 @@ export const Preferences = () => { * @param e - The event object. */ const install = async (e: any) => { - e.preventDefault(); + e.preventDefault() //@ts-ignore - const pluginFile = new FormData(e.target).get("plugin-file").path; + const pluginFile = new FormData(e.target).get('plugin-file').path // Send the filename of the to be installed plugin // to the main process for installation - const installed = await plugins.install([pluginFile]); - if (installed) window.coreAPI?.relaunch(); - }; + const installed = await plugins.install([pluginFile]) + if (installed) window.coreAPI?.relaunch() + } /** * Uninstalls a plugin by calling the `plugins.uninstall` function with the plugin name. @@ -97,9 +110,9 @@ export const Preferences = () => { const uninstall = async (name: string) => { // Send the filename of the to be uninstalled plugin // to the main process for removal - const res = await plugins.uninstall([name]); - if (res) window.coreAPI?.relaunch(); - }; + const res = await plugins.uninstall([name]) + if (res) window.coreAPI?.relaunch() + } /** * Updates a plugin by calling the `window.pluggableElectronIpc.update` function with the plugin name. @@ -108,12 +121,12 @@ export const Preferences = () => { * @param plugin - The name of the plugin to update. */ const update = async (plugin: string) => { - if (typeof window !== "undefined") { + if (typeof window !== 'undefined') { // @ts-ignore - await window.pluggableElectronIpc.update([plugin], true); - window.coreAPI?.relaunch(); + await window.pluggableElectronIpc.update([plugin], true) + window.coreAPI?.relaunch() } - }; + } /** * Downloads a remote plugin tarball and installs it using the `plugins.install` function. @@ -121,22 +134,22 @@ export const Preferences = () => { * @param pluginName - The name of the remote plugin to download and install. */ const downloadTarball = async (pluginName: string) => { - setIsLoading(true); - const pluginPath = await window.coreAPI?.installRemotePlugin(pluginName); - const installed = await plugins.install([pluginPath]); - setIsLoading(false); - if (installed) window.coreAPI.relaunch(); - }; + setIsLoading(true) + const pluginPath = await window.coreAPI?.installRemotePlugin(pluginName) + const installed = await plugins.install([pluginPath]) + setIsLoading(false) + if (installed) window.coreAPI.relaunch() + } /** * Notifies plugins of a preference update by executing the `PluginService.OnPreferencesUpdate` event. * If a timeout is already set, it is cleared before setting a new timeout to execute the event. */ - let timeout: any | undefined = undefined; + let timeout: any | undefined = undefined function notifyPreferenceUpdate() { if (timeout) { - clearTimeout(timeout); + clearTimeout(timeout) } - timeout = setTimeout(() => execute(PluginService.OnPreferencesUpdate), 100); + timeout = setTimeout(() => execute(PluginService.OnPreferencesUpdate), 100) } /** @@ -145,21 +158,21 @@ export const Preferences = () => { * @param event - The change event object. */ const handleFileChange = (event: React.ChangeEvent) => { - const file = event.target.files?.[0]; + const file = event.target.files?.[0] if (file) { - setFileName(file.name); + setFileName(file.name) } else { - setFileName(""); + setFileName('') } - }; + } return ( -
    -
    +
    +
    {/* Separator */} -