add reset current to prompt
This commit is contained in:
136
src/chatbox.tsx
136
src/chatbox.tsx
@@ -8,6 +8,7 @@ import {
|
|||||||
STORAGE_NAME_TEMPLATE_API,
|
STORAGE_NAME_TEMPLATE_API,
|
||||||
TemplateAPI,
|
TemplateAPI,
|
||||||
addTotalCost,
|
addTotalCost,
|
||||||
|
newChatStore,
|
||||||
} from "./app";
|
} from "./app";
|
||||||
import ChatGPT, {
|
import ChatGPT, {
|
||||||
calculate_token_length,
|
calculate_token_length,
|
||||||
@@ -376,69 +377,78 @@ export default function ChatBOX(props: {
|
|||||||
</div>
|
</div>
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
{templates.length > 0 &&
|
{chatStore.history.filter((msg) => !msg.example).length == 0 && (
|
||||||
chatStore.history.filter((msg) => !msg.example).length == 0 && (
|
<p className="break-all opacity-80 p-3 rounded bg-white my-3 text-left dark:text-black">
|
||||||
<p className="break-all opacity-80 p-3 rounded bg-white my-3 text-left dark:text-black">
|
<h2>
|
||||||
<h2>{Tr("Saved prompt templates")}</h2>
|
<span>{Tr("Saved prompt templates")}</span>
|
||||||
<hr className="my-2" />
|
<button
|
||||||
<div className="flex flex-wrap">
|
className="mx-2 underline cursor-pointer"
|
||||||
{templates.map((t, index) => (
|
onClick={() => {
|
||||||
<div
|
chatStore.systemMessageContent = "";
|
||||||
className="cursor-pointer rounded bg-green-400 w-fit p-2 m-1 flex flex-col"
|
chatStore.history = [];
|
||||||
onClick={() => {
|
setChatStore({ ...chatStore });
|
||||||
const newChatStore: ChatStore = structuredClone(t);
|
}}
|
||||||
// @ts-ignore
|
>
|
||||||
delete newChatStore.name;
|
{Tr("Reset Current")}
|
||||||
if (!newChatStore.apiEndpoint) {
|
</button>
|
||||||
newChatStore.apiEndpoint = getDefaultParams(
|
</h2>
|
||||||
"api",
|
<hr className="my-2" />
|
||||||
chatStore.apiEndpoint
|
<div className="flex flex-wrap">
|
||||||
);
|
{templates.map((t, index) => (
|
||||||
}
|
<div
|
||||||
if (!newChatStore.apiKey) {
|
className="cursor-pointer rounded bg-green-400 w-fit p-2 m-1 flex flex-col"
|
||||||
newChatStore.apiKey = getDefaultParams(
|
onClick={() => {
|
||||||
"key",
|
const newChatStore: ChatStore = structuredClone(t);
|
||||||
chatStore.apiKey
|
// @ts-ignore
|
||||||
);
|
delete newChatStore.name;
|
||||||
}
|
if (!newChatStore.apiEndpoint) {
|
||||||
newChatStore.cost = 0;
|
newChatStore.apiEndpoint = getDefaultParams(
|
||||||
setChatStore({ ...newChatStore });
|
"api",
|
||||||
}}
|
chatStore.apiEndpoint
|
||||||
>
|
);
|
||||||
<span className="w-full text-center">{t.name}</span>
|
}
|
||||||
<hr className="mt-2" />
|
if (!newChatStore.apiKey) {
|
||||||
<span className="flex justify-between">
|
newChatStore.apiKey = getDefaultParams(
|
||||||
<button
|
"key",
|
||||||
onClick={() => {
|
chatStore.apiKey
|
||||||
const name = prompt("Give template a name");
|
);
|
||||||
if (!name) {
|
}
|
||||||
return;
|
newChatStore.cost = 0;
|
||||||
}
|
setChatStore({ ...newChatStore });
|
||||||
t.name = name;
|
}}
|
||||||
setTemplates(structuredClone(templates));
|
>
|
||||||
}}
|
<span className="w-full text-center">{t.name}</span>
|
||||||
>
|
<hr className="mt-2" />
|
||||||
🖋
|
<span className="flex justify-between">
|
||||||
</button>
|
<button
|
||||||
<button
|
onClick={() => {
|
||||||
onClick={() => {
|
const name = prompt("Give template a name");
|
||||||
if (
|
if (!name) {
|
||||||
!confirm("Are you sure to delete this template?")
|
return;
|
||||||
) {
|
}
|
||||||
return;
|
t.name = name;
|
||||||
}
|
setTemplates(structuredClone(templates));
|
||||||
templates.splice(index, 1);
|
}}
|
||||||
setTemplates(structuredClone(templates));
|
>
|
||||||
}}
|
🖋
|
||||||
>
|
</button>
|
||||||
❌
|
<button
|
||||||
</button>
|
onClick={() => {
|
||||||
</span>
|
if (!confirm("Are you sure to delete this template?")) {
|
||||||
</div>
|
return;
|
||||||
))}
|
}
|
||||||
</div>
|
templates.splice(index, 1);
|
||||||
</p>
|
setTemplates(structuredClone(templates));
|
||||||
)}
|
}}
|
||||||
|
>
|
||||||
|
❌
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
{chatStore.history.length === 0 && (
|
{chatStore.history.length === 0 && (
|
||||||
<p className="break-all opacity-60 p-6 rounded bg-white my-3 text-left dark:text-black">
|
<p className="break-all opacity-60 p-6 rounded bg-white my-3 text-left dark:text-black">
|
||||||
{Tr("No chat history here")}
|
{Tr("No chat history here")}
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ const LANG_MAP: Record<string, string> = {
|
|||||||
reset: "重置",
|
reset: "重置",
|
||||||
example: "示例",
|
example: "示例",
|
||||||
render: "渲染",
|
render: "渲染",
|
||||||
|
"reset current": "清空当前会话",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default LANG_MAP;
|
export default LANG_MAP;
|
||||||
|
|||||||
Reference in New Issue
Block a user