fix: if streaming did not work, get message from end
This commit is contained in:
parent
b5a1fec33d
commit
234358bc6e
1 changed files with 367 additions and 351 deletions
|
|
@ -56,15 +56,27 @@ export default function ChatModal({
|
||||||
|
|
||||||
//add proper type signature for function
|
//add proper type signature for function
|
||||||
|
|
||||||
function updateLastMessage({str,thought}:{str?: string, thought?: string}) {
|
function updateLastMessage({
|
||||||
|
str,
|
||||||
|
thought,
|
||||||
|
end = false,
|
||||||
|
}: {
|
||||||
|
str?: string;
|
||||||
|
thought?: string;
|
||||||
|
// end param default is false
|
||||||
|
end?: boolean;
|
||||||
|
}) {
|
||||||
setChatHistory((old) => {
|
setChatHistory((old) => {
|
||||||
let newChat = [...old];
|
let newChat = [...old];
|
||||||
if (str) {
|
if (str) {
|
||||||
|
if (end && !newChat[newChat.length - 1].message) {
|
||||||
|
newChat[newChat.length - 1].message = str;
|
||||||
|
}
|
||||||
newChat[newChat.length - 1].message =
|
newChat[newChat.length - 1].message =
|
||||||
newChat[newChat.length - 1].message + str;
|
newChat[newChat.length - 1].message + str;
|
||||||
}
|
}
|
||||||
if (thought) {
|
if (thought) {
|
||||||
newChat[newChat.length - 1].thought = thought
|
newChat[newChat.length - 1].thought = thought;
|
||||||
}
|
}
|
||||||
return newChat;
|
return newChat;
|
||||||
});
|
});
|
||||||
|
|
@ -120,7 +132,11 @@ export default function ChatModal({
|
||||||
}
|
}
|
||||||
if (data.type === "end") {
|
if (data.type === "end") {
|
||||||
if (data.intermediate_steps) {
|
if (data.intermediate_steps) {
|
||||||
updateLastMessage({thought:data.intermediate_steps});
|
updateLastMessage({
|
||||||
|
str: data.message,
|
||||||
|
thought: data.intermediate_steps,
|
||||||
|
end: true,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
setLockChat(false);
|
setLockChat(false);
|
||||||
isStream = false;
|
isStream = false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue