mirror of
https://github.com/sqlchat/sqlchat.git
synced 2026-03-13 07:59:44 +08:00
chore: re-arrange addMessage to avoid returning partial error
Strange I can only observe this in prod. Not in local env even using `next build && next start`
This commit is contained in:
@@ -150,18 +150,6 @@ const ConversationView = () => {
|
||||
};
|
||||
messageStore.addMessage(userMessage);
|
||||
|
||||
// Add PENDING assistant message to the store.
|
||||
const assistantMessage: Message = {
|
||||
id: generateUUID(),
|
||||
conversationId: currentConversation.id,
|
||||
creatorId: currentConversation.assistantId,
|
||||
creatorRole: CreatorRole.Assistant,
|
||||
createdAt: Date.now(),
|
||||
content: "",
|
||||
status: "LOADING",
|
||||
};
|
||||
messageStore.addMessage(assistantMessage);
|
||||
|
||||
// Construct the system prompt
|
||||
const messageList = messageStore
|
||||
.getState()
|
||||
@@ -264,13 +252,30 @@ const ConversationView = () => {
|
||||
} catch (error) {
|
||||
// do nth
|
||||
}
|
||||
messageStore.updateMessage(assistantMessage.id, {
|
||||
messageStore.addMessage({
|
||||
id: generateUUID(),
|
||||
conversationId: currentConversation.id,
|
||||
creatorId: currentConversation.assistantId,
|
||||
creatorRole: CreatorRole.Assistant,
|
||||
createdAt: Date.now(),
|
||||
content: errorMessage,
|
||||
status: "FAILED",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Add PENDING assistant message to the store.
|
||||
const assistantMessage: Message = {
|
||||
id: generateUUID(),
|
||||
conversationId: currentConversation.id,
|
||||
creatorId: currentConversation.assistantId,
|
||||
creatorRole: CreatorRole.Assistant,
|
||||
createdAt: Date.now(),
|
||||
content: "",
|
||||
status: "LOADING",
|
||||
};
|
||||
messageStore.addMessage(assistantMessage);
|
||||
|
||||
const data = rawRes.body;
|
||||
if (!data) {
|
||||
toast.error("No data return");
|
||||
|
||||
Reference in New Issue
Block a user