show all saved apis

This commit is contained in:
2024-01-16 17:48:41 +08:00
parent 36f2ce57d5
commit 0eabcc0d0a
2 changed files with 64 additions and 72 deletions

View File

@@ -464,81 +464,62 @@ export default function ChatBOX(props: {
{Tr("Please click above to set")} API Endpoint {Tr("Please click above to set")} API Endpoint
</p> </p>
)} )}
{templateAPIs.length > 0 && {templateAPIs.length > 0 && (
(chatStore.develop_mode || <ListAPIs
chatStore.history.filter((msg) => !msg.example).length == 0 || label="API"
!chatStore.apiEndpoint || tmps={templateAPIs}
!chatStore.apiKey) && ( setTmps={setTemplateAPIs}
<ListAPIs chatStore={chatStore}
label="API" setChatStore={setChatStore}
tmps={templateAPIs} apiField="apiEndpoint"
setTmps={setTemplateAPIs} keyField="apiKey"
chatStore={chatStore} />
setChatStore={setChatStore} )}
apiField="apiEndpoint"
keyField="apiKey"
/>
)}
{templateAPIsWhisper.length > 0 && {templateAPIsWhisper.length > 0 && (
(chatStore.develop_mode || <ListAPIs
chatStore.history.filter((msg) => !msg.example).length == 0 || label="Whisper API"
!chatStore.whisper_api || tmps={templateAPIsWhisper}
!chatStore.whisper_key) && ( setTmps={setTemplateAPIsWhisper}
<ListAPIs chatStore={chatStore}
label="Whisper API" setChatStore={setChatStore}
tmps={templateAPIsWhisper} apiField="whisper_api"
setTmps={setTemplateAPIsWhisper} keyField="whisper_key"
chatStore={chatStore} />
setChatStore={setChatStore} )}
apiField="whisper_api"
keyField="whisper_key"
/>
)}
{templateAPIsTTS.length > 0 && {templateAPIsTTS.length > 0 && (
(chatStore.develop_mode || <ListAPIs
chatStore.history.filter((msg) => !msg.example).length == 0 || label="TTS API"
!chatStore.tts_api || tmps={templateAPIsTTS}
!chatStore.tts_key) && ( setTmps={setTemplateAPIsTTS}
<ListAPIs chatStore={chatStore}
label="TTS API" setChatStore={setChatStore}
tmps={templateAPIsTTS} apiField="tts_api"
setTmps={setTemplateAPIsTTS} keyField="tts_key"
chatStore={chatStore} />
setChatStore={setChatStore} )}
apiField="tts_api"
keyField="tts_key"
/>
)}
{templateAPIsImageGen.length > 0 && {templateAPIsImageGen.length > 0 && (
(chatStore.develop_mode || <ListAPIs
chatStore.history.filter((msg) => !msg.example).length == 0 || label="Image Gen API"
!chatStore.image_gen_api || tmps={templateAPIsImageGen}
!chatStore.image_gen_key) && ( setTmps={setTemplateAPIsImageGen}
<ListAPIs chatStore={chatStore}
label="Image Gen API" setChatStore={setChatStore}
tmps={templateAPIsImageGen} apiField="image_gen_api"
setTmps={setTemplateAPIsImageGen} keyField="image_gen_key"
chatStore={chatStore} />
setChatStore={setChatStore} )}
apiField="image_gen_api"
keyField="image_gen_key"
/>
)}
{toolsTemplates.length > 0 && {toolsTemplates.length > 0 && (
(chatStore.develop_mode || <ListToolsTempaltes
chatStore.history.filter((msg) => !msg.example).length == 0 || templateTools={toolsTemplates}
!chatStore.toolsString) && ( setTemplateTools={setTemplateTools}
<ListToolsTempaltes chatStore={chatStore}
templateTools={toolsTemplates} setChatStore={setChatStore}
setTemplateTools={setTemplateTools} />
chatStore={chatStore} )}
setChatStore={setChatStore}
/>
)}
{chatStore.history.filter((msg) => !msg.example).length == 0 && ( {chatStore.history.filter((msg) => !msg.example).length == 0 && (
<div className="break-all opacity-80 p-3 rounded bg-white my-3 text-left dark:text-black"> <div className="break-all opacity-80 p-3 rounded bg-white my-3 text-left dark:text-black">

View File

@@ -15,7 +15,18 @@ export function ListToolsTempaltes({
}: Props) { }: Props) {
return ( return (
<div className="break-all opacity-80 p-3 rounded bg-white my-3 text-left dark:text-black"> <div className="break-all opacity-80 p-3 rounded bg-white my-3 text-left dark:text-black">
<h2>{Tr(`Saved tools templates`)}</h2> <h2>
<span>{Tr(`Saved tools templates`)}</span>
<button
className="mx-2 underline cursor-pointer"
onClick={() => {
chatStore.toolsString = "";
setChatStore({ ...chatStore });
}}
>
{Tr(`Clear`)}
</button>
</h2>
<hr className="my-2" /> <hr className="my-2" />
<div className="flex flex-wrap"> <div className="flex flex-wrap">
{templateTools.map((t, index) => ( {templateTools.map((t, index) => (