import { ChatStore, ChatStoreMessage } from "@/types/chatstore"; import { calculate_token_length } from "@/chatgpt"; import { Tr } from "@/translate"; import { Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger, } from "@/components/ui/drawer"; import { Button } from "./components/ui/button"; interface Props { chat: ChatStoreMessage; chatStore: ChatStore; setChatStore: (cs: ChatStore) => void; setShowEdit: (se: boolean) => void; } export function EditMessageDetail({ chat, chatStore, setChatStore, setShowEdit, }: Props) { if (typeof chat.content !== "object") return
error
; return ( Open Edit Message Detail Modify the content of the message.
{chat.content.map((mdt, index) => (
{mdt.type === "text" ? ( ) : (
{ window.open(mdt.image_url?.url, "_blank"); }} /> { if (typeof chat.content === "string") return; const obj = chat.content[index].image_url; if (obj === undefined) return; obj.detail = obj.detail === "high" ? "low" : "high"; chat.token = calculate_token_length(chat.content); setChatStore({ ...chatStore }); }} >
)}
))}
); }