🐛 fix(formModal): add support for prompt in updateLastMessage function to update chat message template

🔀 merge(types): add prompt property to ChatMessageType to support chat message templates
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-09-28 09:12:33 -03:00
commit 00c1a946c0
2 changed files with 10 additions and 2 deletions

View file

@ -124,12 +124,13 @@ export default function FormModal({
function updateLastMessage({
str,
thought,
prompt,
end = false,
files,
}: {
str?: string;
thought?: string;
// end param default is false
prompt?: string;
end?: boolean;
files?: Array<any>;
}) {
@ -149,6 +150,9 @@ export default function FormModal({
if (files) {
newChat[newChat.length - 1].files = files;
}
if (prompt) {
newChat[newChat.length - 1].template = prompt;
}
return newChat;
});
}
@ -244,7 +248,10 @@ export default function FormModal({
isStream = false;
}
if (data.type === "stream" && isStream) {
updateLastMessage({ str: data.message });
if (data.prompt) {
} else {
updateLastMessage({ str: data.message });
}
}
}

View file

@ -8,5 +8,6 @@ export type ChatMessageType = {
isSend: boolean;
thought?: string;
files?: Array<{ data: string; type: string; data_type: string }>;
prompt?: string;
chatKey: string;
};