mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-26 05:08:50 +01:00
⌚ feat: Add Current Datetime to Assistants (v1/v2) (#4952)
* Feature: Added ability to send current date and time to v1 and v2 assistants * remove date_feature.patch * fix: rename append_today_date to append_current_datetime * feat: Refactor time handling in chatV1 and chatV2, add date and time utility functions * fix: Add warning log and response for missing run values in abortRun middleware --------- Co-authored-by: Max Sanna <max@maxsanna.com>
This commit is contained in:
parent
b5c9144127
commit
1dbe6ee75d
38 changed files with 378 additions and 67 deletions
|
|
@ -258,6 +258,8 @@ export const useCreateSharedLinkMutation = (
|
|||
return;
|
||||
}
|
||||
|
||||
const isPublic = vars.isPublic === true;
|
||||
|
||||
queryClient.setQueryData<t.SharedLinkListData>([QueryKeys.sharedLinks], (sharedLink) => {
|
||||
if (!sharedLink) {
|
||||
return sharedLink;
|
||||
|
|
@ -265,24 +267,22 @@ export const useCreateSharedLinkMutation = (
|
|||
const pageSize = sharedLink.pages[0].pageSize as number;
|
||||
return normalizeData(
|
||||
// If the shared link is public, add it to the shared links cache list
|
||||
vars.isPublic
|
||||
? addSharedLink(sharedLink, _data)
|
||||
: deleteSharedLink(sharedLink, _data.shareId),
|
||||
isPublic ? addSharedLink(sharedLink, _data) : deleteSharedLink(sharedLink, _data.shareId),
|
||||
InfiniteCollections.SHARED_LINKS,
|
||||
pageSize,
|
||||
);
|
||||
});
|
||||
|
||||
queryClient.setQueryData([QueryKeys.sharedLinks, _data.shareId], _data);
|
||||
if (!vars.isPublic) {
|
||||
if (!isPublic) {
|
||||
const current = queryClient.getQueryData<t.ConversationData>([QueryKeys.sharedLinks]);
|
||||
refetch({
|
||||
refetchPage: (page, index) => index === (current?.pages.length || 1) - 1,
|
||||
refetchPage: (page, index) => index === ((current?.pages.length ?? 0) || 1) - 1,
|
||||
});
|
||||
}
|
||||
onSuccess?.(_data, vars, context);
|
||||
},
|
||||
...(_options || {}),
|
||||
..._options,
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -298,6 +298,8 @@ export const useUpdateSharedLinkMutation = (
|
|||
return;
|
||||
}
|
||||
|
||||
const isPublic = vars.isPublic === true;
|
||||
|
||||
queryClient.setQueryData<t.SharedLinkListData>([QueryKeys.sharedLinks], (sharedLink) => {
|
||||
if (!sharedLink) {
|
||||
return sharedLink;
|
||||
|
|
@ -305,7 +307,7 @@ export const useUpdateSharedLinkMutation = (
|
|||
|
||||
return normalizeData(
|
||||
// If the shared link is public, add it to the shared links cache list.
|
||||
vars.isPublic
|
||||
isPublic
|
||||
? // Even if the SharedLink data exists in the database, it is not registered in the cache when isPublic is false.
|
||||
// Therefore, when isPublic is true, use addSharedLink instead of updateSharedLink.
|
||||
addSharedLink(sharedLink, _data)
|
||||
|
|
@ -316,16 +318,16 @@ export const useUpdateSharedLinkMutation = (
|
|||
});
|
||||
|
||||
queryClient.setQueryData([QueryKeys.sharedLinks, _data.shareId], _data);
|
||||
if (!vars.isPublic) {
|
||||
if (!isPublic) {
|
||||
const current = queryClient.getQueryData<t.ConversationData>([QueryKeys.sharedLinks]);
|
||||
refetch({
|
||||
refetchPage: (page, index) => index === (current?.pages.length || 1) - 1,
|
||||
refetchPage: (page, index) => index === ((current?.pages.length ?? 0) || 1) - 1,
|
||||
});
|
||||
}
|
||||
|
||||
onSuccess?.(_data, vars, context);
|
||||
},
|
||||
...(_options || {}),
|
||||
..._options,
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -466,7 +468,11 @@ export const useDeleteTagInConversations = () => {
|
|||
for (let pageIndex = 0; pageIndex < newData.pages.length; pageIndex++) {
|
||||
const page = newData.pages[pageIndex];
|
||||
page.conversations = page.conversations.map((conversation) => {
|
||||
if (conversation.conversationId && conversation.tags?.includes(deletedTag)) {
|
||||
if (
|
||||
conversation.conversationId != null &&
|
||||
conversation.conversationId &&
|
||||
conversation.tags?.includes(deletedTag) === true
|
||||
) {
|
||||
conversationIdsWithTag.push(conversation.conversationId);
|
||||
conversation.tags = conversation.tags.filter((t) => t !== deletedTag);
|
||||
}
|
||||
|
|
@ -833,11 +839,12 @@ export const useUpdateAssistantMutation = (
|
|||
if (!prev) {
|
||||
return prev;
|
||||
}
|
||||
prev.map((doc) => {
|
||||
return prev.map((doc) => {
|
||||
if (doc.assistant_id === variables.assistant_id) {
|
||||
return {
|
||||
...doc,
|
||||
conversation_starters: updatedAssistant.conversation_starters,
|
||||
append_current_datetime: variables.data.append_current_datetime,
|
||||
};
|
||||
}
|
||||
return doc;
|
||||
|
|
@ -976,7 +983,9 @@ export const useUpdateAction = (
|
|||
}
|
||||
return action;
|
||||
})
|
||||
.concat(variables.action_id ? [] : [updateActionResponse[2]]);
|
||||
.concat(
|
||||
variables.action_id != null && variables.action_id ? [] : [updateActionResponse[2]],
|
||||
);
|
||||
});
|
||||
|
||||
return options?.onSuccess?.(updateActionResponse, variables, context);
|
||||
|
|
@ -1032,7 +1041,7 @@ export const useDeleteAction = (
|
|||
return {
|
||||
...assistant,
|
||||
tools: (assistant.tools ?? []).filter(
|
||||
(tool) => !tool.function?.name.includes(domain ?? ''),
|
||||
(tool) => !(tool.function?.name.includes(domain ?? '') ?? false),
|
||||
),
|
||||
};
|
||||
}
|
||||
|
|
@ -1230,7 +1239,11 @@ export const useUpdateAgentAction = (
|
|||
}
|
||||
return action;
|
||||
})
|
||||
.concat(variables.action_id ? [] : [updateAgentActionResponse[1]]);
|
||||
.concat(
|
||||
variables.action_id != null && variables.action_id
|
||||
? []
|
||||
: [updateAgentActionResponse[1]],
|
||||
);
|
||||
});
|
||||
|
||||
return options?.onSuccess?.(updateAgentActionResponse, variables, context);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue