From 9c2a30d23d19d47bc1459975eabc070786c73d74 Mon Sep 17 00:00:00 2001
From: heimoshuiyu
Date: Fri, 3 Nov 2023 11:44:03 +0800
Subject: [PATCH] add reset current to prompt
---
src/chatbox.tsx | 136 ++++++++++++++++++++++-------------------
src/translate/zh_CN.ts | 1 +
2 files changed, 74 insertions(+), 63 deletions(-)
diff --git a/src/chatbox.tsx b/src/chatbox.tsx
index 068d667..8276532 100644
--- a/src/chatbox.tsx
+++ b/src/chatbox.tsx
@@ -8,6 +8,7 @@ import {
STORAGE_NAME_TEMPLATE_API,
TemplateAPI,
addTotalCost,
+ newChatStore,
} from "./app";
import ChatGPT, {
calculate_token_length,
@@ -376,69 +377,78 @@ export default function ChatBOX(props: {
)}
- {templates.length > 0 &&
- chatStore.history.filter((msg) => !msg.example).length == 0 && (
-
-
{Tr("Saved prompt templates")}
-
-
- {templates.map((t, index) => (
-
{
- const newChatStore: ChatStore = structuredClone(t);
- // @ts-ignore
- delete newChatStore.name;
- if (!newChatStore.apiEndpoint) {
- newChatStore.apiEndpoint = getDefaultParams(
- "api",
- chatStore.apiEndpoint
- );
- }
- if (!newChatStore.apiKey) {
- newChatStore.apiKey = getDefaultParams(
- "key",
- chatStore.apiKey
- );
- }
- newChatStore.cost = 0;
- setChatStore({ ...newChatStore });
- }}
- >
- {t.name}
-
-
-
-
-
-
- ))}
-
-
- )}
+ {chatStore.history.filter((msg) => !msg.example).length == 0 && (
+
+
+ {Tr("Saved prompt templates")}
+
+
+
+
+ {templates.map((t, index) => (
+
{
+ const newChatStore: ChatStore = structuredClone(t);
+ // @ts-ignore
+ delete newChatStore.name;
+ if (!newChatStore.apiEndpoint) {
+ newChatStore.apiEndpoint = getDefaultParams(
+ "api",
+ chatStore.apiEndpoint
+ );
+ }
+ if (!newChatStore.apiKey) {
+ newChatStore.apiKey = getDefaultParams(
+ "key",
+ chatStore.apiKey
+ );
+ }
+ newChatStore.cost = 0;
+ setChatStore({ ...newChatStore });
+ }}
+ >
+ {t.name}
+
+
+
+
+
+
+ ))}
+
+
+ )}
{chatStore.history.length === 0 && (
{Tr("No chat history here")}
diff --git a/src/translate/zh_CN.ts b/src/translate/zh_CN.ts
index 123c68a..11a8863 100644
--- a/src/translate/zh_CN.ts
+++ b/src/translate/zh_CN.ts
@@ -53,6 +53,7 @@ const LANG_MAP: Record = {
reset: "重置",
example: "示例",
render: "渲染",
+ "reset current": "清空当前会话",
};
export default LANG_MAP;