|
@@ -363,7 +363,7 @@
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
- const chatCompletedHandler = async (modelId, responseMessageId, messages) => {
|
|
|
|
|
|
+ const chatCompletedHandler = async (chatId, modelId, responseMessageId, messages) => {
|
|
await mermaid.run({
|
|
await mermaid.run({
|
|
querySelector: '.mermaid'
|
|
querySelector: '.mermaid'
|
|
});
|
|
});
|
|
@@ -377,7 +377,7 @@
|
|
info: m.info ? m.info : undefined,
|
|
info: m.info ? m.info : undefined,
|
|
timestamp: m.timestamp
|
|
timestamp: m.timestamp
|
|
})),
|
|
})),
|
|
- chat_id: $chatId,
|
|
|
|
|
|
+ chat_id: chatId,
|
|
session_id: $socket?.id,
|
|
session_id: $socket?.id,
|
|
id: responseMessageId
|
|
id: responseMessageId
|
|
}).catch((error) => {
|
|
}).catch((error) => {
|
|
@@ -399,9 +399,21 @@
|
|
};
|
|
};
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if ($chatId == chatId) {
|
|
|
|
+ if ($settings.saveChatHistory ?? true) {
|
|
|
|
+ chat = await updateChatById(localStorage.token, chatId, {
|
|
|
|
+ models: selectedModels,
|
|
|
|
+ messages: messages,
|
|
|
|
+ history: history,
|
|
|
|
+ params: params
|
|
|
|
+ });
|
|
|
|
+ await chats.set(await getChatList(localStorage.token));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
};
|
|
};
|
|
|
|
|
|
- const chatActionHandler = async (actionId, modelId, responseMessageId) => {
|
|
|
|
|
|
+ const chatActionHandler = async (chatId, actionId, modelId, responseMessageId) => {
|
|
const res = await chatAction(localStorage.token, actionId, {
|
|
const res = await chatAction(localStorage.token, actionId, {
|
|
model: modelId,
|
|
model: modelId,
|
|
messages: messages.map((m) => ({
|
|
messages: messages.map((m) => ({
|
|
@@ -411,7 +423,7 @@
|
|
info: m.info ? m.info : undefined,
|
|
info: m.info ? m.info : undefined,
|
|
timestamp: m.timestamp
|
|
timestamp: m.timestamp
|
|
})),
|
|
})),
|
|
- chat_id: $chatId,
|
|
|
|
|
|
+ chat_id: chatId,
|
|
session_id: $socket?.id,
|
|
session_id: $socket?.id,
|
|
id: responseMessageId
|
|
id: responseMessageId
|
|
}).catch((error) => {
|
|
}).catch((error) => {
|
|
@@ -432,6 +444,18 @@
|
|
};
|
|
};
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if ($chatId == chatId) {
|
|
|
|
+ if ($settings.saveChatHistory ?? true) {
|
|
|
|
+ chat = await updateChatById(localStorage.token, chatId, {
|
|
|
|
+ models: selectedModels,
|
|
|
|
+ messages: messages,
|
|
|
|
+ history: history,
|
|
|
|
+ params: params
|
|
|
|
+ });
|
|
|
|
+ await chats.set(await getChatList(localStorage.token));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
};
|
|
};
|
|
|
|
|
|
const getChatEventEmitter = async (modelId: string, chatId: string = '') => {
|
|
const getChatEventEmitter = async (modelId: string, chatId: string = '') => {
|
|
@@ -801,7 +825,7 @@
|
|
controller.abort('User: Stop Response');
|
|
controller.abort('User: Stop Response');
|
|
} else {
|
|
} else {
|
|
const messages = createMessagesList(responseMessageId);
|
|
const messages = createMessagesList(responseMessageId);
|
|
- await chatCompletedHandler(model.id, responseMessageId, messages);
|
|
|
|
|
|
+ await chatCompletedHandler(_chatId, model.id, responseMessageId, messages);
|
|
}
|
|
}
|
|
|
|
|
|
_response = responseMessage.content;
|
|
_response = responseMessage.content;
|
|
@@ -1113,7 +1137,7 @@
|
|
} else {
|
|
} else {
|
|
const messages = createMessagesList(responseMessageId);
|
|
const messages = createMessagesList(responseMessageId);
|
|
|
|
|
|
- await chatCompletedHandler(model.id, responseMessageId, messages);
|
|
|
|
|
|
+ await chatCompletedHandler(_chatId, model.id, responseMessageId, messages);
|
|
}
|
|
}
|
|
|
|
|
|
_response = responseMessage.content;
|
|
_response = responseMessage.content;
|