handle files on end

This commit is contained in:
anovazzi1 2023-05-09 20:07:48 -03:00
commit 08dacd7042

View file

@ -60,11 +60,14 @@ export default function ChatModal({
str, str,
thought, thought,
end = false, end = false,
files
}: { }: {
str?: string; str?: string;
thought?: string; thought?: string;
// end param default is false // end param default is false
end?: boolean; end?: boolean;
files?: Array<any>
}) { }) {
setChatHistory((old) => { setChatHistory((old) => {
let newChat = [...old]; let newChat = [...old];
@ -79,6 +82,9 @@ export default function ChatModal({
if (thought) { if (thought) {
newChat[newChat.length - 1].thought = thought; newChat[newChat.length - 1].thought = thought;
} }
if(files){
newChat[newChat.length - 1].files = files;
}
return newChat; return newChat;
}); });
} }
@ -133,18 +139,23 @@ export default function ChatModal({
} }
if (data.type === "end") { if (data.type === "end") {
if (data.intermediate_steps) { if (data.intermediate_steps) {
updateLastMessage({ updateLastMessage({
str: data.message, str: data.message,
thought: data.intermediate_steps, thought: data.intermediate_steps,
end: true, end: true,
}); });
} }
if(data.files){
updateLastMessage({
end: true,
files: data.files
});
}
setLockChat(false); setLockChat(false);
isStream = false; isStream = false;
} }
if (data.type === "file") {
console.log(data);
}
if (data.type === "stream" && isStream) { if (data.type === "stream" && isStream) {
updateLastMessage({ str: data.message }); updateLastMessage({ str: data.message });
} }