add reset current to prompt

This commit is contained in:
2023-11-03 11:44:03 +08:00
parent cc143f6796
commit 9c2a30d23d
2 changed files with 74 additions and 63 deletions

View File

@@ -8,6 +8,7 @@ import {
STORAGE_NAME_TEMPLATE_API,
TemplateAPI,
addTotalCost,
newChatStore,
} from "./app";
import ChatGPT, {
calculate_token_length,
@@ -376,10 +377,21 @@ export default function ChatBOX(props: {
</div>
</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">
<h2>{Tr("Saved prompt templates")}</h2>
<h2>
<span>{Tr("Saved prompt templates")}</span>
<button
className="mx-2 underline cursor-pointer"
onClick={() => {
chatStore.systemMessageContent = "";
chatStore.history = [];
setChatStore({ ...chatStore });
}}
>
{Tr("Reset Current")}
</button>
</h2>
<hr className="my-2" />
<div className="flex flex-wrap">
{templates.map((t, index) => (
@@ -422,9 +434,7 @@ export default function ChatBOX(props: {
</button>
<button
onClick={() => {
if (
!confirm("Are you sure to delete this template?")
) {
if (!confirm("Are you sure to delete this template?")) {
return;
}
templates.splice(index, 1);

View File

@@ -53,6 +53,7 @@ const LANG_MAP: Record<string, string> = {
reset: "重置",
example: "示例",
render: "渲染",
"reset current": "清空当前会话",
};
export default LANG_MAP;