import { createRef } from "preact"; import { StateUpdater, useContext, useEffect, useState } from "preact/hooks"; import { ChatStore, TemplateAPI, TemplateTools, clearTotalCost, getTotalCost, } from "./app"; import models from "./models"; import { TemplateChatStore } from "./chatbox"; import { tr, Tr, langCodeContext, LANG_OPTIONS } from "./translate"; import p from "preact-markdown"; import { isVailedJSON } from "./message"; import { SetAPIsTemplate } from "./setAPIsTemplate"; import { autoHeight } from "./textarea"; import getDefaultParams from "./getDefaultParam"; 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 }) => { return (
{props.children}
{Tr("Total cost in this session")} ${props.chatStore.cost.toFixed(4)}
{Tr("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(tr("Please select a json file", langCode)); return; } const reader = new FileReader(); reader.onload = () => { console.log("import content", reader.result); if (!reader) { alert(tr("Empty file", langCode)); return; } try { const newChatStore: ChatStore = JSON.parse( reader.result as string ); if (!newChatStore.chatgpt_api_web_version) { throw tr( "This is not an exported chatgpt-api-web chatstore file. The key 'chatgpt_api_web_version' is missing!", langCode ); } props.setChatStore({ ...newChatStore }); } catch (e) { alert( tr(`Import error on parsing json:`, langCode) + `${e}` ); } }; reader.readAsText(file); }} />
chatgpt-api-web ChatStore {Tr("Version")}{" "} {props.chatStore.chatgpt_api_web_version}
⚠{Tr("Documents and source code are avaliable here")}:{" "} github.com/heimoshuiyu/chatgpt-api-web