mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-30 15:18:50 +01:00
chore: address ESLint comments
This commit is contained in:
parent
69772317b2
commit
cee11d3353
9 changed files with 31 additions and 31 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import React from 'react';
|
||||
import { X, FileText, Image, Upload } from 'lucide-react';
|
||||
import type { ExtendedFile } from 'librechat-data-provider';
|
||||
import type { ExtendedFile } from '~/common';
|
||||
import { useLocalize } from '~/hooks';
|
||||
import { cn } from '~/utils';
|
||||
|
||||
|
|
@ -59,16 +59,16 @@ const PromptFileRow: React.FC<PromptFileRowProps> = ({
|
|||
{file.filename}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
{getFileStatus(file)}
|
||||
|
||||
|
||||
{!isReadOnly && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => onRemoveFile(file.temp_file_id || file.file_id || '')}
|
||||
className={cn(
|
||||
'ml-1 flex h-5 w-5 items-center justify-center rounded-full',
|
||||
'hover:bg-surface-hover text-text-secondary hover:text-text-primary',
|
||||
'text-text-secondary hover:bg-surface-hover hover:text-text-primary',
|
||||
'transition-colors duration-200',
|
||||
)}
|
||||
title={localize('com_ui_remove_file')}
|
||||
|
|
@ -83,4 +83,3 @@ const PromptFileRow: React.FC<PromptFileRowProps> = ({
|
|||
};
|
||||
|
||||
export default PromptFileRow;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import React, { useRef, useState, useMemo } from 'react';
|
||||
import { Paperclip, Upload, Folder } from 'lucide-react';
|
||||
import { Upload, Folder } from 'lucide-react';
|
||||
import {
|
||||
Button,
|
||||
TooltipAnchor,
|
||||
|
|
@ -8,12 +8,12 @@ import {
|
|||
FileUpload,
|
||||
} from '@librechat/client';
|
||||
import { EToolResources } from 'librechat-data-provider';
|
||||
import type { ExtendedFile } from 'librechat-data-provider';
|
||||
import { useLocalize } from '~/hooks';
|
||||
import type { ExtendedFile } from '~/common';
|
||||
import { usePromptFileHandling } from '~/hooks/Prompts';
|
||||
import PromptFileRow from './PromptFileRow';
|
||||
import { cn } from '~/utils';
|
||||
import * as Ariakit from '@ariakit/react';
|
||||
import { useLocalize } from '~/hooks';
|
||||
import { cn } from '~/utils';
|
||||
|
||||
interface PromptFileUploadProps {
|
||||
files: ExtendedFile[];
|
||||
|
|
@ -64,12 +64,6 @@ const PromptFileUpload: React.FC<PromptFileUploadProps> = ({
|
|||
}
|
||||
};
|
||||
|
||||
const handleButtonClick = () => {
|
||||
if (fileInputRef.current) {
|
||||
fileInputRef.current.click();
|
||||
}
|
||||
};
|
||||
|
||||
const handleRemoveFile = (fileId: string) => {
|
||||
const updatedFiles = promptFiles.filter(
|
||||
(file) => file.temp_file_id !== fileId && file.file_id !== fileId,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,2 @@
|
|||
export { default as PromptFileUpload } from './PromptFileUpload';
|
||||
export { default as PromptFileRow } from './PromptFileRow';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { useState, useMemo, memo } from 'react';
|
||||
import { Menu as MenuIcon, Edit as EditIcon, EarthIcon, TextSearch, Paperclip } from 'lucide-react';
|
||||
import { Menu as MenuIcon, Edit as EditIcon, EarthIcon, TextSearch } from 'lucide-react';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuItem,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import React, { useState, useCallback, useMemo, useEffect } from 'react';
|
|||
import { useRecoilState } from 'recoil';
|
||||
import { ListFilter, User, Share2 } from 'lucide-react';
|
||||
import { SystemCategories } from 'librechat-data-provider';
|
||||
import { Dropdown, AnimatedSearchInput, AttachmentIcon } from '@librechat/client';
|
||||
import { Dropdown, AnimatedSearchInput } from '@librechat/client';
|
||||
import type { Option } from '~/common';
|
||||
import { useLocalize, useCategories } from '~/hooks';
|
||||
import { usePromptGroupsContext } from '~/Providers';
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@ import { replaceSpecialVars } from 'librechat-data-provider';
|
|||
import type { TPromptGroup, AgentToolResources } from 'librechat-data-provider';
|
||||
import { codeNoExecution } from '~/components/Chat/Messages/Content/MarkdownComponents';
|
||||
import { useLocalize, useAuthContext } from '~/hooks';
|
||||
import PromptFilesPreview from './PromptFilesPreview';
|
||||
import CategoryIcon from './Groups/CategoryIcon';
|
||||
import PromptVariables from './PromptVariables';
|
||||
import { PromptVariableGfm } from './Markdown';
|
||||
import Description from './Description';
|
||||
import Command from './Command';
|
||||
import PromptFilesPreview from './PromptFilesPreview';
|
||||
|
||||
const PromptDetails = ({ group }: { group?: TPromptGroup }) => {
|
||||
const localize = useLocalize();
|
||||
|
|
@ -26,7 +26,7 @@ const PromptDetails = ({ group }: { group?: TPromptGroup }) => {
|
|||
return replaceSpecialVars({ text: initialText, user });
|
||||
}, [group?.productionPrompt?.prompt, user]);
|
||||
|
||||
const toolResources = useMemo(() => {
|
||||
const toolResources = useMemo((): AgentToolResources | undefined => {
|
||||
return group?.productionPrompt?.tool_resources;
|
||||
}, [group?.productionPrompt?.tool_resources]);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,9 +11,14 @@ import {
|
|||
ResourceType,
|
||||
PermissionBits,
|
||||
PermissionTypes,
|
||||
EToolResources,
|
||||
} from 'librechat-data-provider';
|
||||
import type { TCreatePrompt, TPrompt, TPromptGroup } from 'librechat-data-provider';
|
||||
import type {
|
||||
TCreatePrompt,
|
||||
TPrompt,
|
||||
TPromptGroup,
|
||||
AgentToolResources,
|
||||
} from 'librechat-data-provider';
|
||||
import type { ExtendedFile } from '~/common';
|
||||
import {
|
||||
useGetPrompts,
|
||||
useGetPromptGroup,
|
||||
|
|
@ -283,7 +288,6 @@ const PromptForm = () => {
|
|||
},
|
||||
});
|
||||
|
||||
// Helper function to get tool resources from a specific files array
|
||||
const getToolResourcesFromFiles = useCallback((files: ExtendedFile[]) => {
|
||||
if (files.length === 0) {
|
||||
return undefined;
|
||||
|
|
@ -292,14 +296,12 @@ const PromptForm = () => {
|
|||
const toolResources: AgentToolResources = {};
|
||||
|
||||
files.forEach((file) => {
|
||||
if (!file.file_id) return; // Skip files that haven't been uploaded yet
|
||||
if (!file.file_id || !file.tool_resource) return; // Skip files that haven't been uploaded yet
|
||||
|
||||
// Initialize the tool resource if it doesn't exist
|
||||
if (!toolResources[file.tool_resource]) {
|
||||
toolResources[file.tool_resource] = { file_ids: [] };
|
||||
}
|
||||
|
||||
// Add file_id to the appropriate tool resource
|
||||
if (!toolResources[file.tool_resource]!.file_ids!.includes(file.file_id)) {
|
||||
toolResources[file.tool_resource]!.file_ids!.push(file.file_id);
|
||||
}
|
||||
|
|
@ -360,7 +362,14 @@ const PromptForm = () => {
|
|||
// We're adding to an existing group, so use the addPromptToGroup mutation
|
||||
addPromptToGroupMutation.mutate({ ...tempPrompt, groupId });
|
||||
},
|
||||
[selectedPrompt, group, addPromptToGroupMutation, canEdit, getToolResources],
|
||||
[
|
||||
selectedPrompt,
|
||||
group,
|
||||
addPromptToGroupMutation,
|
||||
canEdit,
|
||||
getToolResources,
|
||||
getToolResourcesFromFiles,
|
||||
],
|
||||
);
|
||||
|
||||
const handleLoadingComplete = useCallback(() => {
|
||||
|
|
@ -390,7 +399,7 @@ const PromptForm = () => {
|
|||
} else {
|
||||
loadFromToolResources(undefined);
|
||||
}
|
||||
}, [selectedPrompt, group, setValue]);
|
||||
}, [selectedPrompt, group, setValue, loadFromToolResources]);
|
||||
|
||||
useEffect(() => {
|
||||
const handleResize = () => {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { v4 } from 'uuid';
|
||||
import { cloneDeep } from 'lodash';
|
||||
import { useMemo } from 'react';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import {
|
||||
Constants,
|
||||
|
|
|
|||
|
|
@ -513,7 +513,7 @@ export type TPromptGroup = {
|
|||
category?: string;
|
||||
projectIds?: string[];
|
||||
productionId?: string | null;
|
||||
productionPrompt?: Pick<TPrompt, 'prompt'> | null;
|
||||
productionPrompt?: Pick<TPrompt, 'prompt' | 'tool_resources'> | null;
|
||||
author: string;
|
||||
authorName: string;
|
||||
createdAt?: Date;
|
||||
|
|
@ -592,7 +592,7 @@ export type TMakePromptProductionResponse = {
|
|||
export type TMakePromptProductionRequest = {
|
||||
id: string;
|
||||
groupId: string;
|
||||
productionPrompt: Pick<TPrompt, 'prompt'>;
|
||||
productionPrompt: Pick<TPrompt, 'prompt' | 'tool_resources'>;
|
||||
};
|
||||
|
||||
export type TUpdatePromptLabelsRequest = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue