mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 09:20:15 +01:00
🔍 refactor: Search & Message Retrieval (#6903)
* refactor: conversation search fetch * refactor: Message and Convo fetch with paramters and search * refactor: update search states and cleanup old store states * refactor: re-enable search API; fix: search conversation * fix: message's convo fetch * fix: redirect when searching * chore: use logger instead of console * fix: search message loading * feat: small optimizations * feat(Message): remove cache for search path * fix: handle delete of all archivedConversation and sharedLinks * chore: cleanup * fix: search messages * style: update ConvoOptions styles * refactor(SearchButtons): streamline conversation fetching and remove unused state * fix: ensure messages are invalidated after fetching conversation data * fix: add iconURL to conversation query selection --------- Co-authored-by: Danny Avila <danny@librechat.ai>
This commit is contained in:
parent
851938e7a6
commit
88f4ad7c47
30 changed files with 489 additions and 576 deletions
|
|
@ -30,16 +30,6 @@ export function deleteUser(): Promise<s.TPreset> {
|
|||
return request.delete(endpoints.deleteUser());
|
||||
}
|
||||
|
||||
export function getMessagesByConvoId(conversationId: string): Promise<s.TMessage[]> {
|
||||
if (
|
||||
conversationId === config.Constants.NEW_CONVO ||
|
||||
conversationId === config.Constants.PENDING_CONVO
|
||||
) {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
return request.get(endpoints.messages(conversationId));
|
||||
}
|
||||
|
||||
export function getSharedMessages(shareId: string): Promise<t.TSharedMessagesResponse> {
|
||||
return request.get(endpoints.shareMessages(shareId));
|
||||
}
|
||||
|
|
@ -70,31 +60,6 @@ export function deleteSharedLink(shareId: string): Promise<m.TDeleteSharedLinkRe
|
|||
return request.delete(endpoints.shareMessages(shareId));
|
||||
}
|
||||
|
||||
export function updateMessage(payload: t.TUpdateMessageRequest): Promise<unknown> {
|
||||
const { conversationId, messageId, text } = payload;
|
||||
if (!conversationId) {
|
||||
throw new Error('conversationId is required');
|
||||
}
|
||||
|
||||
return request.put(endpoints.messages(conversationId, messageId), { text });
|
||||
}
|
||||
|
||||
export const editArtifact = async ({
|
||||
messageId,
|
||||
...params
|
||||
}: m.TEditArtifactRequest): Promise<m.TEditArtifactResponse> => {
|
||||
return request.post(`/api/messages/artifact/${messageId}`, params);
|
||||
};
|
||||
|
||||
export function updateMessageContent(payload: t.TUpdateMessageContent): Promise<unknown> {
|
||||
const { conversationId, messageId, index, text } = payload;
|
||||
if (!conversationId) {
|
||||
throw new Error('conversationId is required');
|
||||
}
|
||||
|
||||
return request.put(endpoints.messages(conversationId, messageId), { text, index });
|
||||
}
|
||||
|
||||
export function updateUserKey(payload: t.TUpdateUserKeyRequest) {
|
||||
const { value } = payload;
|
||||
if (!value) {
|
||||
|
|
@ -602,24 +567,11 @@ export function clearAllConversations(): Promise<unknown> {
|
|||
export const listConversations = (
|
||||
params?: q.ConversationListParams,
|
||||
): Promise<q.ConversationListResponse> => {
|
||||
const isArchived = params?.isArchived ?? false;
|
||||
const sortBy = params?.sortBy;
|
||||
const sortDirection = params?.sortDirection;
|
||||
const tags = params?.tags || [];
|
||||
const search = params?.search || '';
|
||||
const cursor = params?.cursor;
|
||||
|
||||
if (search !== '' && isArchived === false) {
|
||||
return request.get(endpoints.search(search, cursor));
|
||||
} else {
|
||||
return request.get(
|
||||
endpoints.conversations(isArchived, sortBy, sortDirection, tags, search, cursor),
|
||||
);
|
||||
}
|
||||
return request.get(endpoints.conversations(params ?? {}));
|
||||
};
|
||||
|
||||
export function getConversations(cursor: string): Promise<t.TGetConversationsResponse> {
|
||||
return request.get(endpoints.conversations(undefined, undefined, undefined, [], '', cursor));
|
||||
return request.get(endpoints.conversations({ cursor }));
|
||||
}
|
||||
|
||||
export function getConversationById(id: string): Promise<s.TConversation> {
|
||||
|
|
@ -642,6 +594,45 @@ export function genTitle(payload: m.TGenTitleRequest): Promise<m.TGenTitleRespon
|
|||
return request.post(endpoints.genTitle(), payload);
|
||||
}
|
||||
|
||||
export const listMessages = (params?: q.MessagesListParams): Promise<q.MessagesListResponse> => {
|
||||
return request.get(endpoints.messages(params ?? {}));
|
||||
};
|
||||
|
||||
export function updateMessage(payload: t.TUpdateMessageRequest): Promise<unknown> {
|
||||
const { conversationId, messageId, text } = payload;
|
||||
if (!conversationId) {
|
||||
throw new Error('conversationId is required');
|
||||
}
|
||||
|
||||
return request.put(endpoints.messages({ conversationId, messageId }), { text });
|
||||
}
|
||||
|
||||
export function updateMessageContent(payload: t.TUpdateMessageContent): Promise<unknown> {
|
||||
const { conversationId, messageId, index, text } = payload;
|
||||
if (!conversationId) {
|
||||
throw new Error('conversationId is required');
|
||||
}
|
||||
|
||||
return request.put(endpoints.messages({ conversationId, messageId }), { text, index });
|
||||
}
|
||||
|
||||
export const editArtifact = async ({
|
||||
messageId,
|
||||
...params
|
||||
}: m.TEditArtifactRequest): Promise<m.TEditArtifactResponse> => {
|
||||
return request.post(`/api/messages/artifact/${messageId}`, params);
|
||||
};
|
||||
|
||||
export function getMessagesByConvoId(conversationId: string): Promise<s.TMessage[]> {
|
||||
if (
|
||||
conversationId === config.Constants.NEW_CONVO ||
|
||||
conversationId === config.Constants.PENDING_CONVO
|
||||
) {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
return request.get(endpoints.messages({ conversationId }));
|
||||
}
|
||||
|
||||
export function getPrompt(id: string): Promise<{ prompt: t.TPrompt }> {
|
||||
return request.get(endpoints.getPrompt(id));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue