mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
🔀 fix: Address Convo/Preset Switching Issues (#2709)
* fix(schemas): interchangeability between chatGptLabel <> modelLabel * fix: display error message from enforceModelSpecs when conversation already existed * fix(Mention): use activeIndex on mention tab/enter * fix: correctly navigate to new conversation when deleting/archiving a new, active convo
This commit is contained in:
parent
e42709bd1f
commit
94eeec354e
5 changed files with 74 additions and 51 deletions
|
|
@ -99,7 +99,7 @@ export default function Mention({
|
|||
} else if (e.key === 'ArrowUp') {
|
||||
setActiveIndex((prevIndex) => (prevIndex - 1 + matches.length) % matches.length);
|
||||
} else if (e.key === 'Enter' || e.key === 'Tab') {
|
||||
const mentionOption = matches[0] as MentionOption | undefined;
|
||||
const mentionOption = matches[activeIndex] as MentionOption | undefined;
|
||||
if (mentionOption?.type === 'endpoint') {
|
||||
e.preventDefault();
|
||||
} else if (e.key === 'Enter') {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
import { TooltipProvider, Tooltip, TooltipTrigger, TooltipContent } from '~/components/ui';
|
||||
import { useParams, useNavigate } from 'react-router-dom';
|
||||
import type { MouseEvent, FocusEvent, KeyboardEvent } from 'react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
|
||||
import { useArchiveConversationMutation } from '~/data-provider';
|
||||
|
||||
import { TooltipProvider, Tooltip, TooltipTrigger, TooltipContent } from '~/components/ui';
|
||||
import { useConversations, useLocalize, useNewConvo } from '~/hooks';
|
||||
import { useToastContext } from '~/Providers';
|
||||
import { useArchiveConversationMutation } from '~/data-provider';
|
||||
import { NotificationSeverity } from '~/common';
|
||||
import { useToastContext } from '~/Providers';
|
||||
|
||||
type ArchiveButtonProps = {
|
||||
conversationId: string;
|
||||
|
|
@ -23,8 +21,9 @@ export default function ArchiveButton({
|
|||
className = '',
|
||||
}: ArchiveButtonProps) {
|
||||
const localize = useLocalize();
|
||||
const { newConversation } = useNewConvo();
|
||||
const navigate = useNavigate();
|
||||
const { showToast } = useToastContext();
|
||||
const { newConversation } = useNewConvo();
|
||||
const { refreshConversations } = useConversations();
|
||||
const { conversationId: currentConvoId } = useParams();
|
||||
|
||||
|
|
@ -42,8 +41,9 @@ export default function ArchiveButton({
|
|||
{ conversationId, isArchived: shouldArchive },
|
||||
{
|
||||
onSuccess: () => {
|
||||
if (currentConvoId === conversationId) {
|
||||
if (currentConvoId === conversationId || currentConvoId === 'new') {
|
||||
newConversation();
|
||||
navigate('/c/new', { replace: true });
|
||||
}
|
||||
refreshConversations();
|
||||
retainView();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { useCallback } from 'react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { QueryKeys } from 'librechat-data-provider';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import { useParams, useNavigate } from 'react-router-dom';
|
||||
import type { TMessage } from 'librechat-data-provider';
|
||||
import { useDeleteConversationMutation } from '~/data-provider';
|
||||
import {
|
||||
|
|
@ -26,13 +26,15 @@ export default function DeleteButton({
|
|||
className = '',
|
||||
}) {
|
||||
const localize = useLocalize();
|
||||
const navigate = useNavigate();
|
||||
const queryClient = useQueryClient();
|
||||
const { newConversation } = useNewConvo();
|
||||
const { conversationId: currentConvoId } = useParams();
|
||||
const deleteConvoMutation = useDeleteConversationMutation({
|
||||
onSuccess: () => {
|
||||
if (currentConvoId === conversationId) {
|
||||
if (currentConvoId === conversationId || currentConvoId === 'new') {
|
||||
newConversation();
|
||||
navigate('/c/new', { replace: true });
|
||||
}
|
||||
retainView();
|
||||
},
|
||||
|
|
|
|||
|
|
@ -390,6 +390,11 @@ export default function useSSE(submission: TSubmission | null, index = 0) {
|
|||
});
|
||||
setIsSubmitting(false);
|
||||
return;
|
||||
} else if (!data.conversationId) {
|
||||
const errorResponse = parseErrorResponse(data);
|
||||
setMessages([...messages, message, errorResponse]);
|
||||
setIsSubmitting(false);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('Error:', data);
|
||||
|
|
|
|||
|
|
@ -400,10 +400,11 @@ export const openAISchema = tConversationSchema
|
|||
maxContextTokens: true,
|
||||
max_tokens: true,
|
||||
})
|
||||
.transform((obj) => ({
|
||||
.transform((obj) => {
|
||||
const result = {
|
||||
...obj,
|
||||
model: obj.model ?? openAISettings.model.default,
|
||||
chatGptLabel: obj.modelLabel ?? obj.chatGptLabel ?? null,
|
||||
chatGptLabel: obj.chatGptLabel ?? obj.modelLabel ?? null,
|
||||
promptPrefix: obj.promptPrefix ?? null,
|
||||
temperature: obj.temperature ?? openAISettings.temperature.default,
|
||||
top_p: obj.top_p ?? openAISettings.top_p.default,
|
||||
|
|
@ -418,7 +419,14 @@ export const openAISchema = tConversationSchema
|
|||
spec: obj.spec ?? undefined,
|
||||
maxContextTokens: obj.maxContextTokens ?? undefined,
|
||||
max_tokens: obj.max_tokens ?? undefined,
|
||||
}))
|
||||
};
|
||||
|
||||
if (obj.modelLabel) {
|
||||
result.modelLabel = null;
|
||||
}
|
||||
|
||||
return result;
|
||||
})
|
||||
.catch(() => ({
|
||||
model: openAISettings.model.default,
|
||||
chatGptLabel: null,
|
||||
|
|
@ -605,10 +613,11 @@ export const gptPluginsSchema = tConversationSchema
|
|||
spec: true,
|
||||
maxContextTokens: true,
|
||||
})
|
||||
.transform((obj) => ({
|
||||
.transform((obj) => {
|
||||
const result = {
|
||||
...obj,
|
||||
model: obj.model ?? 'gpt-3.5-turbo',
|
||||
chatGptLabel: obj.modelLabel ?? obj.chatGptLabel ?? null,
|
||||
chatGptLabel: obj.chatGptLabel ?? obj.modelLabel ?? null,
|
||||
promptPrefix: obj.promptPrefix ?? null,
|
||||
temperature: obj.temperature ?? 0.8,
|
||||
top_p: obj.top_p ?? 1,
|
||||
|
|
@ -625,7 +634,14 @@ export const gptPluginsSchema = tConversationSchema
|
|||
greeting: obj.greeting ?? undefined,
|
||||
spec: obj.spec ?? undefined,
|
||||
maxContextTokens: obj.maxContextTokens ?? undefined,
|
||||
}))
|
||||
};
|
||||
|
||||
if (obj.modelLabel) {
|
||||
result.modelLabel = null;
|
||||
}
|
||||
|
||||
return result;
|
||||
})
|
||||
.catch(() => ({
|
||||
model: 'gpt-3.5-turbo',
|
||||
chatGptLabel: null,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue