fix: will correctly switch endpoints and reset the convo if the first message returned was an error (#1225)

This commit is contained in:
Danny Avila 2023-11-26 14:24:43 -05:00 committed by GitHub
parent 12209fe0dd
commit 4b289640f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View file

@ -23,6 +23,7 @@ type TResData = {
requestMessage: TMessage;
responseMessage: TMessage;
conversation: TConversation;
conversationId?: string;
};
export default function useSSE(submission: TSubmission | null, index = 0) {
@ -36,6 +37,7 @@ export default function useSSE(submission: TSubmission | null, index = 0) {
setIsSubmitting,
resetLatestMessage,
invalidateConvos,
newConversation,
} = useChatHelpers(index, paramId);
const { data: startupConfig } = useGetStartupConfig();
@ -210,6 +212,9 @@ export default function useSSE(submission: TSubmission | null, index = 0) {
});
setIsSubmitting(false);
setMessages([...messages, message, errorResponse]);
if (data.conversationId && paramId === 'new') {
newConversation({ template: { conversationId: data.conversationId } });
}
return;
};