import { themeChange } from "theme-change"; import { createRef } from "preact"; import { StateUpdater, useContext, useEffect, useState, Dispatch, } from "preact/hooks"; import { clearTotalCost, getTotalCost } from "@/utils/totalCost"; import { ChatStore, TemplateChatStore, TemplateAPI, TemplateTools, } from "@/types/chatstore"; import { models } from "@/types/models"; import { tr, Tr, langCodeContext, LANG_OPTIONS } from "@/translate"; import { isVailedJSON } from "@/message"; import { SetAPIsTemplate } from "@/setAPIsTemplate"; import { autoHeight } from "@/textarea"; import { getDefaultParams } from "@/utils/getDefaultParam"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, } from "@/components/ui/sheet"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "@/components/ui/accordion"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "@/components/ui/tooltip"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; import { Checkbox } from "@/components/ui/checkbox"; import { Textarea } from "@/components/ui/textarea"; import { BanIcon, CheckIcon, CircleEllipsisIcon, CogIcon, Ellipsis, EyeIcon, InfoIcon, KeyIcon, ListIcon, MoveHorizontalIcon, } from "lucide-react"; import { Separator } from "./components/ui/separator"; import { Slider } from "./components/ui/slider"; const TTS_VOICES: string[] = [ "alloy", "echo", "fable", "onyx", "nova", "shimmer", ]; const TTS_FORMAT: string[] = ["mp3", "opus", "aac", "flac"]; const Help = (props: { children: any; help: string; field: string }) => { return (
); }; const SelectModel = (props: { chatStore: ChatStore; setChatStore: (cs: ChatStore) => void; help: string; }) => { let shouldIUseCustomModel: boolean = true; for (const model in models) { if (props.chatStore.model === model) { shouldIUseCustomModel = false; } } const [useCustomModel, setUseCustomModel] = useState(shouldIUseCustomModel); return (
setUseCustomModel(!useCustomModel)} />
{useCustomModel ? ( ) => { props.chatStore.model = e.target.value; props.setChatStore({ ...props.chatStore }); }} /> ) : ( )}
); }; const LongInput = (props: { chatStore: ChatStore; setChatStore: (cs: ChatStore) => void; field: "systemMessageContent" | "toolsString"; label: string; help: string; }) => { return (