import { createRef } from "preact"; import { StateUpdater, useState } from "preact/hooks"; import { ChatStore, clearTotalCost, getTotalCost } from "./app"; import models from "./models"; import { TemplateChatStore } from "./chatbox"; const Help = (props: { children: any; help: string }) => { return (
{props.children}
Total cost in this session ${props.chatStore.cost.toFixed(4)}
Accumulated cost in all sessions ${totalCost.toFixed(4)}
{ const file = importFileRef.current.files[0]; console.log("file to import", file); if (!file || file.type !== "application/json") { alert("Please select a json file"); return; } const reader = new FileReader(); reader.onload = () => { console.log("import content", reader.result); if (!reader) { alert("Empty file"); return; } try { const newChatStore: ChatStore = JSON.parse( reader.result as string ); if (!newChatStore.chatgpt_api_web_version) { throw "This is not an exported chatgpt-api-web chatstore file. The key 'chatgpt_api_web_version' is missing!"; } props.setChatStore({ ...newChatStore }); } catch (e) { alert(`Import error on parsing json: ${e}`); } }; reader.readAsText(file); }} />
chatgpt-api-web ChatStore Version{" "} {props.chatStore.chatgpt_api_web_version}