diff --git a/src/listAPIs.tsx b/src/listAPIs.tsx index 62c9e38..a48f4fe 100644 --- a/src/listAPIs.tsx +++ b/src/listAPIs.tsx @@ -14,18 +14,20 @@ import { AppContext } from "./pages/App"; interface Props { label: string; + shortLabel: string; apiField: string; keyField: string; } -export function ListAPIs({ label, apiField, keyField }: Props) { +export function ListAPIs({ label, shortLabel, apiField, keyField }: Props) { const ctx = useContext(AppContext); if (ctx === null) return <>; return ( - {label}{" "} + {shortLabel} + {label}{" "} {ctx.templateAPIs.find( (t) => ctx.chatStore[apiField as keyof ChatStore] === t.endpoint && diff --git a/src/pages/Chatbox.tsx b/src/pages/Chatbox.tsx index 1e45148..f8d2b5f 100644 --- a/src/pages/Chatbox.tsx +++ b/src/pages/Chatbox.tsx @@ -1,8 +1,7 @@ -import { IDBPDatabase } from "idb"; import { useContext, useRef } from "react"; -import { useEffect, useState, Dispatch } from "react"; -import { Tr, langCodeContext, LANG_OPTIONS } from "@/translate"; -import { addTotalCost, getTotalCost } from "@/utils/totalCost"; +import { useEffect, useState } from "react"; +import { Tr } from "@/translate"; +import { addTotalCost } from "@/utils/totalCost"; import ChatGPT, { calculate_token_length, FetchResponse, @@ -12,30 +11,19 @@ import ChatGPT, { Logprobs, Usage, } from "@/chatgpt"; -import { - ChatStore, - ChatStoreMessage, - TemplateChatStore, - TemplateAPI, - TemplateTools, -} from "../types/chatstore"; +import { ChatStoreMessage } from "../types/chatstore"; import Message from "@/message"; import { models } from "@/types/models"; import { AddImage } from "@/addImage"; import { ListAPIs } from "@/listAPIs"; import { ListToolsTemplates } from "@/listToolsTemplates"; import { autoHeight } from "@/utils/textAreaHelp"; -import Templates from "@/components/Templates"; import VersionHint from "@/components/VersionHint"; import WhisperButton from "@/components/WhisperButton"; -import AddToolMsg from "./AddToolMsg"; -import { Textarea } from "@/components/ui/textarea"; import { Button } from "@/components/ui/button"; -import { Input } from "@/components/ui/input"; import { ChatInput } from "@/components/ui/chat/chat-input"; import { ChatBubble, - ChatBubbleAvatar, ChatBubbleMessage, ChatBubbleAction, ChatBubbleActionWrapper, @@ -43,33 +31,22 @@ import { import { ChatMessageList } from "@/components/ui/chat/chat-message-list"; import { - AlertTriangleIcon, - ArrowUpIcon, + ArrowDownToDotIcon, CornerDownLeftIcon, CornerLeftUpIcon, - CornerUpLeftIcon, - GlobeIcon, + CornerRightUpIcon, ImageIcon, InfoIcon, - KeyIcon, - SearchIcon, - Settings2, - Settings2Icon, + ScissorsIcon, } from "lucide-react"; import { Switch } from "@/components/ui/switch"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { NavigationMenu, - NavigationMenuContent, - NavigationMenuItem, - NavigationMenuLink, NavigationMenuList, - NavigationMenuTrigger, - navigationMenuTriggerStyle, } from "@/components/ui/navigation-menu"; import { AppContext } from "./App"; -import { addToRange } from "react-day-picker"; export default function ChatBOX() { const ctx = useContext(AppContext); @@ -428,21 +405,33 @@ export default function ChatBOX() { {ctx.templateAPIs.length > 0 && ( - + )} {ctx.templateAPIsWhisper.length > 0 && ( )} {ctx.templateAPIsTTS.length > 0 && ( - + )} {ctx.templateAPIsImageGen.length > 0 && ( @@ -453,52 +442,31 @@ export default function ChatBOX() {
- {chatStore.history.filter((msg) => !msg.example).length == 0 && ( -
-

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

-
-
- -
-
- )} {chatStore.history.length === 0 && ( - {Tr("No chat history here")} + + {Tr("This is a new chat session, start by typing a message")} +
- + - {Tr("Model")}: {chatStore.model} - -
-
- - - {Tr("Click above to change the settings of this chat")} + {Tr( + "Settings button located at the top right corner can be used to change the settings of this chat" + )}
- {Tr("Click the corner to create a new chat")} + + {Tr( + "'New' button located at the top left corner can be used to create a new chat" + )} +
- + {Tr( "All chat history and settings are stored in the local browser" @@ -525,8 +493,13 @@ export default function ChatBOX() { } - // TODO: add a button to show settings + icon={} + onClick={() => { + chatStore.systemMessageContent = ""; + chatStore.toolsString = ""; + chatStore.history = []; + setChatStore({ ...chatStore }); + }} /> diff --git a/src/translate/zh_CN.ts b/src/translate/zh_CN.ts index 11a8863..a4eeb3a 100644 --- a/src/translate/zh_CN.ts +++ b/src/translate/zh_CN.ts @@ -14,6 +14,12 @@ const LANG_MAP: Record = { "saved api templates": "已保存的 API 模板", "saved prompt templates": "已保存的提示模板", "no chat history here": "暂无历史对话记录", + "This is a new chat session, start by typing a message": + "这是一个新对话,开始输入消息", + "Settings button located at the top right corner can be used to change the settings of this chat": + "右上角的设置按钮可用于更改此对话的设置", + "'New' button located at the top left corner can be used to create a new chat": + "左上角的 '新' 按钮可用于创建新对话", "click above to change the settings of this chat": "点击上方更改此对话的参数(请勿泄漏)", "click the NEW to create a new chat": "点击左上角 NEW 新建对话",