Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
UI Page MemoryPrompt Masks [Chat Commands] (#47)
Browse files Browse the repository at this point in the history
* UI Page MemoryPrompt Masks [Chat Commands]

[+] feat(command): add support for 'updatemasks' command in ChatCommands interface
[+] feat(chat.tsx): implement 'updatemasks' command logic in _Chat component
[+] feat(cn.ts): add translation for 'updatemasks' command
[+] feat(en.ts): add translation for 'updatemasks' command
[+] feat(id.ts): add translation for 'updatemasks' command

* Feat UI Page MemoryPrompt Masks [Chat Commands]

[+] feat(chat.tsx): add toast notification for successful update of masks in chat component
[+] feat(cn.ts): add UI locale for successful update of masks
[+] feat(en.ts): add UI locale for successful update of masks
[+] feat(id.ts): add UI locale for successful update of masks
  • Loading branch information
H0llyW00dzZ authored Oct 9, 2023
1 parent 0d8f7a6 commit dc9694e
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ interface ChatCommands {
save?: Command;
load?: Command;
copymemoryai?: Command;
updatemasks?: Command;
}

export const ChatCommandPrefix = ":";
Expand Down
30 changes: 30 additions & 0 deletions app/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,36 @@ function _Chat() {
showToast(Locale.Copy.Failed);
}
},
updatemasks: () => {
chatStore.updateCurrentSession((session) => {
const memoryPrompt = session.memoryPrompt;
const currentDate = new Date().toISOString(); // Get the current date and time as a string
const existingContext = session.mask.context;
let currentContext = existingContext[0]; // Get the current context message

if (!currentContext || currentContext.role !== "system") {
// If the current context message doesn't exist or doesn't have the role "system"
currentContext = {
role: "system",
content: memoryPrompt,
date: currentDate,
id: "", // Generate or set the ID for the new message
// Add any other properties you want to set for the context messages
};
existingContext.unshift(currentContext); // Add the new message at the beginning of the context array
showToast(Locale.Chat.Commands.UI.MasksSuccess);
} else {
// If the current context message already exists and has the role "system"
currentContext.content = memoryPrompt; // Update the content
currentContext.date = currentDate; // Update the date
// You can update other properties of the current context message here
}

// Set any other properties you want to update in the session
session.mask.context = existingContext;
showToast(Locale.Chat.Commands.UI.MasksSuccess);
});
},
});

// only search prompts when user input is short
Expand Down
5 changes: 5 additions & 0 deletions app/locales/cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ const cn = {
save: "保存当前会话聊天",
load: "加载会话聊天",
copymemoryai: "复制一个记忆会话的提示AI",
updatemasks: "更新一个用于掩码的记忆会话提示",
UI: {
MasksSuccess: "成功更新了掩码会话",
MasksFail: "无法更新掩码会话",
},
},
InputActions: {
Stop: "停止响应",
Expand Down
5 changes: 5 additions & 0 deletions app/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ const en: LocaleType = {
save: "Save a current session chat",
load: "Load a session chat",
copymemoryai: "Copy a session of memory prompt ai",
updatemasks: "Update a session of memory prompt for a mask",
UI: {
MasksSuccess: "Successfully updated session of masks",
MasksFail: "Failed to update session of masks",
},
},
InputActions: {
Stop: "Stop",
Expand Down
5 changes: 5 additions & 0 deletions app/locales/id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ const id: PartialLocaleType = {
save: "Simpan Percakapan Sesi Saat Ini",
load: "Muat Percakapan Sesi",
copymemoryai: "Salin sesi memori prompt AI",
updatemasks: "Perbarui sesi memori prompt untuk sebuah topeng",
UI: {
MasksSuccess: "Berhasil memperbarui sesi topeng",
MasksFail: "Gagal memperbarui sesi topeng",
},
},
InputActions: {
Stop: "Berhenti",
Expand Down

0 comments on commit dc9694e

Please sign in to comment.