import { StateUpdater } from "preact/hooks"; import { ChatStore } from "./app"; const Help = (props: { children: any; help: string }) => { return (

{props.children}

); }; const Input = (props: { chatStore: ChatStore; setChatStore: (cs: ChatStore) => void; field: "apiKey" | "systemMessageContent" | "apiEndpoint"; help: string; }) => { return ( { props.chatStore[props.field] = event.target.value; props.setChatStore({ ...props.chatStore }); }} > ); }; const Number = (props: { chatStore: ChatStore; setChatStore: (cs: ChatStore) => void; field: "totalTokens" | "maxTokens" | "tokenMargin" | "postBeginIndex"; readOnly: boolean; help: string; }) => { return ( { console.log("type", typeof event.target.value); let newNumber = parseInt(event.target.value); if (newNumber < 0) newNumber = 0; props.chatStore[props.field] = newNumber; props.setChatStore({ ...props.chatStore }); }} > ); }; const Choice = (props: { chatStore: ChatStore; setChatStore: (cs: ChatStore) => void; field: "streamMode"; help: string; }) => { return ( { props.chatStore[props.field] = event.target.checked; props.setChatStore({ ...props.chatStore }); }} > ); }; export default (props: { chatStore: ChatStore; setChatStore: (cs: ChatStore) => void; show: boolean; setShow: StateUpdater; }) => { if (!props.show) return
; const link = location.protocol + "//" + location.host + location.pathname + `?key=${encodeURIComponent( props.chatStore.apiKey )}&api=${encodeURIComponent(props.chatStore.apiEndpoint)}&mode=${ props.chatStore.streamMode ? "stream" : "fetch" }&sys=${encodeURIComponent(props.chatStore.systemMessageContent)}`; return (

Settings



); };