mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
🧹 chore: pre-release cleanup (#3595)
* fix: Update health endpoint URL * refactor: use Constants for saved tag default value, do not place Saved as first always * refactor: check trimmed currentText before appending parsedText in useSubmitMessage * refactor: move `scrollToEnd()` to `createdHandler` and increase delay before execution slightly * chore: Add back TypeScript linting rules for unnecessary conditions and strict boolean expressions * chore: Update librechat-data-provider package.json version to 0.7.4.0
This commit is contained in:
parent
e05a6d306d
commit
473859b0e2
11 changed files with 16 additions and 25 deletions
|
|
@ -120,6 +120,8 @@ module.exports = {
|
||||||
],
|
],
|
||||||
rules: {
|
rules: {
|
||||||
'@typescript-eslint/no-explicit-any': 'error',
|
'@typescript-eslint/no-explicit-any': 'error',
|
||||||
|
'@typescript-eslint/no-unnecessary-condition': 'warn',
|
||||||
|
'@typescript-eslint/strict-boolean-expressions': 'warn',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@ const ConversationTag = require('./schema/conversationTagSchema');
|
||||||
const Conversation = require('./schema/convoSchema');
|
const Conversation = require('./schema/convoSchema');
|
||||||
const logger = require('~/config/winston');
|
const logger = require('~/config/winston');
|
||||||
|
|
||||||
const SAVED_TAG = 'Saved';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves all conversation tags for a user.
|
* Retrieves all conversation tags for a user.
|
||||||
* @param {string} user - The user ID.
|
* @param {string} user - The user ID.
|
||||||
|
|
@ -11,19 +9,7 @@ const SAVED_TAG = 'Saved';
|
||||||
*/
|
*/
|
||||||
const getConversationTags = async (user) => {
|
const getConversationTags = async (user) => {
|
||||||
try {
|
try {
|
||||||
const cTags = await ConversationTag.find({ user }).sort({ position: 1 }).lean();
|
return await ConversationTag.find({ user }).sort({ position: 1 }).lean();
|
||||||
|
|
||||||
cTags.sort((a, b) => {
|
|
||||||
if (a.tag === SAVED_TAG) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (b.tag === SAVED_TAG) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
|
|
||||||
return cTags;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('[getConversationTags] Error getting conversation tags', error);
|
logger.error('[getConversationTags] Error getting conversation tags', error);
|
||||||
throw new Error('Error getting conversation tags');
|
throw new Error('Error getting conversation tags');
|
||||||
|
|
@ -248,7 +234,6 @@ const updateTagsForConversation = async (user, conversationId, tags) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
SAVED_TAG,
|
|
||||||
getConversationTags,
|
getConversationTags,
|
||||||
createConversationTag,
|
createConversationTag,
|
||||||
updateConversationTag,
|
updateConversationTag,
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ import { Spinner } from '~/components';
|
||||||
import { cn } from '~/utils';
|
import { cn } from '~/utils';
|
||||||
import store from '~/store';
|
import store from '~/store';
|
||||||
|
|
||||||
const SAVED_TAG = 'Saved';
|
|
||||||
const BookmarkMenu: FC = () => {
|
const BookmarkMenu: FC = () => {
|
||||||
const localize = useLocalize();
|
const localize = useLocalize();
|
||||||
|
|
||||||
|
|
@ -47,7 +46,7 @@ const BookmarkMenu: FC = () => {
|
||||||
if (conversation && conversationId) {
|
if (conversation && conversationId) {
|
||||||
await mutateAsync(
|
await mutateAsync(
|
||||||
{
|
{
|
||||||
tags: [SAVED_TAG],
|
tags: [Constants.SAVED_TAG as 'Saved'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
onSuccess: (newTags: string[]) => {
|
onSuccess: (newTags: string[]) => {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import {
|
import {
|
||||||
|
Constants,
|
||||||
EToolResources,
|
EToolResources,
|
||||||
LocalStorageKeys,
|
LocalStorageKeys,
|
||||||
InfiniteCollections,
|
InfiniteCollections,
|
||||||
|
|
@ -322,9 +323,9 @@ export const useConversationTagMutation = (
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
tag: 'Saved',
|
|
||||||
count: 1,
|
count: 1,
|
||||||
position: 0,
|
position: 0,
|
||||||
|
tag: Constants.SAVED_TAG,
|
||||||
createdAt: new Date().toISOString(),
|
createdAt: new Date().toISOString(),
|
||||||
updatedAt: new Date().toISOString(),
|
updatedAt: new Date().toISOString(),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@ import type {
|
||||||
import type { SetterOrUpdater } from 'recoil';
|
import type { SetterOrUpdater } from 'recoil';
|
||||||
import type { TAskFunction, ExtendedFile } from '~/common';
|
import type { TAskFunction, ExtendedFile } from '~/common';
|
||||||
import useSetFilesToDelete from '~/hooks/Files/useSetFilesToDelete';
|
import useSetFilesToDelete from '~/hooks/Files/useSetFilesToDelete';
|
||||||
import { getEndpointField, logger, scrollToEnd } from '~/utils';
|
|
||||||
import useGetSender from '~/hooks/Conversations/useGetSender';
|
import useGetSender from '~/hooks/Conversations/useGetSender';
|
||||||
|
import { getEndpointField, logger } from '~/utils';
|
||||||
import useUserKey from '~/hooks/Input/useUserKey';
|
import useUserKey from '~/hooks/Input/useUserKey';
|
||||||
import store from '~/store';
|
import store from '~/store';
|
||||||
|
|
||||||
|
|
@ -250,7 +250,6 @@ export default function useChatFunctions({
|
||||||
setLatestMessage(initialResponse);
|
setLatestMessage(initialResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollToEnd();
|
|
||||||
setSubmission(submission);
|
setSubmission(submission);
|
||||||
logger.log('Submission:');
|
logger.log('Submission:');
|
||||||
logger.dir(submission, { depth: null });
|
logger.dir(submission, { depth: null });
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ export default function useSubmitMessage(helpers?: { clearDraft?: () => void })
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentText = methods.getValues('text');
|
const currentText = methods.getValues('text');
|
||||||
const newText = currentText ? `\n${parsedText}` : parsedText;
|
const newText = currentText?.trim()?.length > 1 ? `\n${parsedText}` : parsedText;
|
||||||
setActivePrompt(newText);
|
setActivePrompt(newText);
|
||||||
},
|
},
|
||||||
[autoSendPrompts, submitMessage, setActivePrompt, methods, user],
|
[autoSendPrompts, submitMessage, setActivePrompt, methods, user],
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import type {
|
||||||
import type { SetterOrUpdater, Resetter } from 'recoil';
|
import type { SetterOrUpdater, Resetter } from 'recoil';
|
||||||
import type { TResData, ConvoGenerator } from '~/common';
|
import type { TResData, ConvoGenerator } from '~/common';
|
||||||
import {
|
import {
|
||||||
|
scrollToEnd,
|
||||||
addConversation,
|
addConversation,
|
||||||
deleteConversation,
|
deleteConversation,
|
||||||
updateConversation,
|
updateConversation,
|
||||||
|
|
@ -291,6 +292,8 @@ export default function useEventHandlers({
|
||||||
if (resetLatestMessage) {
|
if (resetLatestMessage) {
|
||||||
resetLatestMessage();
|
resetLatestMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scrollToEnd();
|
||||||
},
|
},
|
||||||
[setMessages, setConversation, queryClient, isAddedRequest, resetLatestMessage],
|
[setMessages, setConversation, queryClient, isAddedRequest, resetLatestMessage],
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -50,5 +50,5 @@ export const scrollToEnd = () => {
|
||||||
if (messagesEndElement) {
|
if (messagesEndElement) {
|
||||||
messagesEndElement.scrollIntoView({ behavior: 'instant' });
|
messagesEndElement.scrollIntoView({ behavior: 'instant' });
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 750);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "librechat-data-provider",
|
"name": "librechat-data-provider",
|
||||||
"version": "0.7.4",
|
"version": "0.7.4.0",
|
||||||
"description": "data services for librechat apps",
|
"description": "data services for librechat apps",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"module": "dist/index.es.js",
|
"module": "dist/index.es.js",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import type { AssistantsEndpoint } from './schemas';
|
import type { AssistantsEndpoint } from './schemas';
|
||||||
|
|
||||||
export const health = () => '/api/health';
|
export const health = () => '/health';
|
||||||
export const user = () => '/api/user';
|
export const user = () => '/api/user';
|
||||||
|
|
||||||
export const balance = () => '/api/balance';
|
export const balance = () => '/api/balance';
|
||||||
|
|
|
||||||
|
|
@ -957,6 +957,8 @@ export enum Constants {
|
||||||
COMMANDS_MAX_LENGTH = 56,
|
COMMANDS_MAX_LENGTH = 56,
|
||||||
/** Default Stream Rate (ms) */
|
/** Default Stream Rate (ms) */
|
||||||
DEFAULT_STREAM_RATE = 1,
|
DEFAULT_STREAM_RATE = 1,
|
||||||
|
/** Saved Tag */
|
||||||
|
SAVED_TAG = 'Saved',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum LocalStorageKeys {
|
export enum LocalStorageKeys {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue