diff --git a/src/listAPIs.tsx b/src/listAPIs.tsx index 152aadd..14fb6f2 100644 --- a/src/listAPIs.tsx +++ b/src/listAPIs.tsx @@ -1,14 +1,16 @@ import { ChatStore, TemplateAPI } from "@/types/chatstore"; import { Tr } from "@/translate"; -import { Card, CardHeader, CardTitle, CardFooter } from "@/components/ui/card"; import { - Carousel, - CarouselContent, - CarouselItem, - CarouselNext, - CarouselPrevious, -} from "@/components/ui/carousel"; + NavigationMenu, + NavigationMenuContent, + NavigationMenuIndicator, + NavigationMenuItem, + NavigationMenuLink, + NavigationMenuList, + NavigationMenuTrigger, + NavigationMenuViewport, +} from "@/components/ui/navigation-menu"; import { Button } from "./components/ui/button"; import { cn } from "@/lib/utils"; @@ -31,79 +33,116 @@ export function ListAPIs({ keyField, }: Props) { return ( -
-

- {Tr(`Saved ${label} templates`)} -

- - + + {label} + + + + + //
+ //

+ // {Tr(`Saved ${label} templates`)} + //

+ // + // + // {tmps.map((t, index) => ( + // + //
+ // + // + // { + // // @ts-ignore + // chatStore[apiField] = t.endpoint; + // // @ts-ignore + // chatStore[keyField] = t.key; + // setChatStore({ ...chatStore }); + // }} + // > + // {t.name} + // + // + // + + // + // + //
+ //
+ // ))} + //
+ // + // + //
+ //
); } diff --git a/src/listToolsTemplates.tsx b/src/listToolsTemplates.tsx index 0be70d0..8007522 100644 --- a/src/listToolsTemplates.tsx +++ b/src/listToolsTemplates.tsx @@ -1,13 +1,16 @@ import { ChatStore, TemplateTools } from "@/types/chatstore"; import { Tr } from "@/translate"; -import { Card, CardContent } from "@/components/ui/card"; import { - Carousel, - CarouselContent, - CarouselItem, - CarouselNext, - CarouselPrevious, -} from "@/components/ui/carousel"; + NavigationMenu, + NavigationMenuContent, + NavigationMenuIndicator, + NavigationMenuItem, + NavigationMenuLink, + NavigationMenuList, + NavigationMenuTrigger, + NavigationMenuViewport, +} from "@/components/ui/navigation-menu"; +import { cn } from "@/lib/utils"; import { Button } from "./components/ui/button"; interface Props { @@ -23,8 +26,8 @@ export function ListToolsTempaltes({ setChatStore, }: Props) { return ( -
-

+ + {Tr(`Saved tools templates`)} -

- - + + + + + ); } diff --git a/src/pages/Chatbox.tsx b/src/pages/Chatbox.tsx index a69fb1a..480f3e5 100644 --- a/src/pages/Chatbox.tsx +++ b/src/pages/Chatbox.tsx @@ -51,13 +51,16 @@ import { KeyIcon, } from "lucide-react"; import { Switch } from "@/components/ui/switch"; -import { - Accordion, - AccordionContent, - AccordionItem, - AccordionTrigger, -} from "@/components/ui/accordion"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; +import { + NavigationMenu, + NavigationMenuContent, + NavigationMenuItem, + NavigationMenuLink, + NavigationMenuList, + NavigationMenuTrigger, + navigationMenuTriggerStyle, +} from "@/components/ui/navigation-menu"; export default function ChatBOX(props: { db: Promise>; @@ -453,36 +456,37 @@ export default function ChatBOX(props: { const userInputRef = createRef(); return ( -
- {true && ( - - )} - {showSearch && ( - - )} - + <> +
+ {true && ( + + )} + {showSearch && ( + + )} + {!chatStore.apiKey && ( @@ -501,293 +505,288 @@ export default function ChatBOX(props: { )} - - - Saved Presets - - {templateAPIs.length > 0 && ( - - )} - - {templateAPIsWhisper.length > 0 && ( - - )} - - {templateAPIsTTS.length > 0 && ( - - )} - - {templateAPIsImageGen.length > 0 && ( - - )} - - {toolsTemplates.length > 0 && ( - - )} - - - - - {chatStore.history.filter((msg) => !msg.example).length == 0 && ( -
-

- {Tr("Saved prompt templates")} - -

-
-
- + + {templateAPIs.length > 0 && ( + + )} + {templateAPIsWhisper.length > 0 && ( + + )} + {templateAPIsTTS.length > 0 && ( + + )} + {templateAPIsImageGen.length > 0 && ( + + )} + {toolsTemplates.length > 0 && ( + -
-
- )} - {chatStore.history.length === 0 && ( -

- {Tr("No chat history here")} -
⚙{Tr("Model")}: {chatStore.model} -
⬆{Tr("Click above to change the settings of this chat")} -
↖{Tr("Click the conor to create a new chat")} -
⚠ - {Tr( - "All chat history and settings are stored in the local browser" )} -
-

- )} - {chatStore.systemMessageContent.trim() && ( -
-
Prompt
-
setShowSettings(true)} - > - {chatStore.systemMessageContent} -
-
- )} - - {chatStore.history.map((_, messageIndex) => ( - - ))} - {showGenerating && ( -

- {generatingMessage || Tr("Generating...")} - ... -

- )} -

- {chatStore.history.length > 0 && ( - - )} - {chatStore.develop_mode && chatStore.history.length > 0 && ( - - )} -

-

- {chatStore.postBeginIndex !== 0 && ( - <> -
- {Tr("Info: chat history is too long, forget messages")}:{" "} - {chatStore.postBeginIndex} - - )} -

- - {showRetry && ( -

- -

- )} -
- - {images.length > 0 && ( -
- {images.map((image, index) => ( -
- {image.type === "image_url" && ( - - )} -
- ))} -
- )} - - {generatingMessage && ( -
- - -
- )} - -
-
- { - setInputMsg(event.target.value); - autoHeight(event.target); - }} - onKeyPress={(event: any) => { - if (event.ctrlKey && event.code === "Enter") { - send(event.target.value, true); - setInputMsg(""); - event.target.value = ""; - autoHeight(event.target); - return; - } - autoHeight(event.target); - setInputMsg(event.target.value); - }} - className="min-h-12 resize-none rounded-lg bg-background border-0 p-3 shadow-none focus-visible:ring-0" - /> -
- - - {chatStore.whisper_api && chatStore.whisper_key && ( - <> - + +
+
+ + {chatStore.history.filter((msg) => !msg.example).length == 0 && ( +
+

+ {Tr("Saved prompt templates")} + +

+
+
+ - Use Microphone +
+
+ )} + {chatStore.history.length === 0 && ( +

+ {Tr("No chat history here")} +
⚙{Tr("Model")}: {chatStore.model} +
⬆{Tr("Click above to change the settings of this chat")} +
↖{Tr("Click the conor to create a new chat")} +
⚠ + {Tr( + "All chat history and settings are stored in the local browser" + )} +
+

+ )} + {chatStore.systemMessageContent.trim() && ( +
+
Prompt
+
setShowSettings(true)} + > + {chatStore.systemMessageContent} +
+
+ )} + {chatStore.history.map((_, messageIndex) => ( + + ))} + {showGenerating && ( +

+ {generatingMessage || Tr("Generating...")} + ... +

+ )} +

+ {chatStore.history.length > 0 && ( + + )} + {chatStore.develop_mode && chatStore.history.length > 0 && ( + + )} +

+

+ {chatStore.postBeginIndex !== 0 && ( + <> +
+ {Tr("Info: chat history is too long, forget messages")}:{" "} + {chatStore.postBeginIndex} )} - - +

+ + {showRetry && ( +

+ +

+ )} +
+
+ {images.length > 0 && ( +
+ {images.map((image, index) => ( +
+ {image.type === "image_url" && ( + + )} +
+ ))}
- - - {showAddImage && ( - )} + + {generatingMessage && ( +
+ + +
+ )} + +
+
+ { + setInputMsg(event.target.value); + autoHeight(event.target); + }} + onKeyPress={(event: any) => { + if (event.ctrlKey && event.code === "Enter") { + send(event.target.value, true); + setInputMsg(""); + event.target.value = ""; + autoHeight(event.target); + return; + } + autoHeight(event.target); + setInputMsg(event.target.value); + }} + className="min-h-12 resize-none rounded-lg bg-background border-0 p-3 shadow-none focus-visible:ring-0" + /> +
+ + + {chatStore.whisper_api && chatStore.whisper_key && ( + <> + + Use Microphone + + )} + + +
+ + + {showAddImage && ( + + )} +
-
+ ); }