fix: Wait for Initial Message Save & Correct Latest Message (#3399)

* chore: assistants, unsupported assistant, better logging

* chore: remove unnecessary logger in validateAssistant middleware

* fix: resolve initial conversation save/promise before saving response

* chore: Import and organize dependencies in Speech component

* fix: conversation statefulness
- Latest Message (at index 0) should not be reset if existing convo
- add debugging context for clearAllLatestMessages
- Added logging concerning latest Message updates (dev mode only)
- update latest message Set logic, also checks for change in conversation Id
- consolidated latest message helpers to client/src/utils/messages.ts
This commit is contained in:
Danny Avila 2024-07-20 01:51:59 -04:00 committed by GitHub
parent 9e7615f832
commit 2ad097647c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 275 additions and 113 deletions

View file

@ -1,7 +1,7 @@
import { useSetRecoilState } from 'recoil';
import { useNavigate } from 'react-router-dom';
import { useQueryClient } from '@tanstack/react-query';
import { QueryKeys, EModelEndpoint, LocalStorageKeys } from 'librechat-data-provider';
import { QueryKeys, EModelEndpoint, LocalStorageKeys, Constants } from 'librechat-data-provider';
import type { TConversation, TEndpointsConfig, TModelsConfig } from 'librechat-data-provider';
import { buildDefaultConvo, getDefaultEndpoint, getEndpointField } from '~/utils';
import store from '~/store';
@ -10,7 +10,7 @@ const useNavigateToConvo = (index = 0) => {
const navigate = useNavigate();
const queryClient = useQueryClient();
const clearAllConversations = store.useClearConvoState();
const clearAllLatestMessages = store.useClearLatestMessages();
const clearAllLatestMessages = store.useClearLatestMessages(`useNavigateToConvo ${index}`);
const setSubmission = useSetRecoilState(store.submissionByIndex(index));
const { setConversation } = store.useCreateConversationAtom(index);
@ -50,10 +50,10 @@ const useNavigateToConvo = (index = 0) => {
}
clearAllConversations(true);
setConversation(convo);
navigate(`/c/${convo.conversationId ?? 'new'}`);
navigate(`/c/${convo.conversationId ?? Constants.NEW_CONVO}`);
};
const navigateWithLastTools = (conversation: TConversation) => {
const navigateWithLastTools = (conversation: TConversation, _resetLatestMessage?: boolean) => {
// set conversation to the new conversation
if (conversation?.endpoint === EModelEndpoint.gptPlugins) {
let lastSelectedTools = [];
@ -63,12 +63,15 @@ const useNavigateToConvo = (index = 0) => {
} catch (e) {
// console.error(e);
}
navigateToConvo({
...conversation,
tools: conversation?.tools?.length ? conversation?.tools : lastSelectedTools,
});
navigateToConvo(
{
...conversation,
tools: conversation?.tools?.length ? conversation?.tools : lastSelectedTools,
},
_resetLatestMessage,
);
} else {
navigateToConvo(conversation);
navigateToConvo(conversation, _resetLatestMessage);
}
};