mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
fix: will correctly switch endpoints and reset the convo if the first message returned was an error (#1225)
This commit is contained in:
parent
12209fe0dd
commit
4b289640f2
2 changed files with 7 additions and 4 deletions
|
|
@ -2,7 +2,7 @@ import { useState } from 'react';
|
|||
import { Settings } from 'lucide-react';
|
||||
import { EModelEndpoint } from 'librechat-data-provider';
|
||||
import type { FC } from 'react';
|
||||
import { useLocalize, useUserKey, useOriginNavigate } from '~/hooks';
|
||||
import { useLocalize, useUserKey } from '~/hooks';
|
||||
import { SetKeyDialog } from '~/components/Input/SetKeyDialog';
|
||||
import { useChatContext } from '~/Providers';
|
||||
import { icons } from './Icons';
|
||||
|
|
@ -30,7 +30,6 @@ const MenuItem: FC<MenuItemProps> = ({
|
|||
const [isDialogOpen, setDialogOpen] = useState(false);
|
||||
const { newConversation } = useChatContext();
|
||||
const { getExpiry } = useUserKey(endpoint);
|
||||
const navigate = useOriginNavigate();
|
||||
const localize = useLocalize();
|
||||
const expiryTime = getExpiry();
|
||||
|
||||
|
|
@ -41,8 +40,7 @@ const MenuItem: FC<MenuItemProps> = ({
|
|||
if (!expiryTime) {
|
||||
setDialogOpen(true);
|
||||
}
|
||||
newConversation({ template: { endpoint: newEndpoint } });
|
||||
navigate('new');
|
||||
newConversation({ template: { endpoint: newEndpoint, conversationId: 'new' } });
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue