import { ArrowUpDown, Database } from 'lucide-react'; import { FileSources, FileContext } from 'librechat-data-provider'; import type { ColumnDef } from '@tanstack/react-table'; import type { TFile } from 'librechat-data-provider'; import ImagePreview from '~/components/Chat/Input/Files/ImagePreview'; import FilePreview from '~/components/Chat/Input/Files/FilePreview'; import { SortFilterHeader } from './SortFilterHeader'; import { OpenAIMinimalIcon } from '~/components/svg'; import { Button, Checkbox } from '~/components/ui'; import { formatDate, getFileType } from '~/utils'; const contextMap = { [FileContext.avatar]: 'Avatar', [FileContext.unknown]: 'Unknown', [FileContext.assistants]: 'Assistants', [FileContext.image_generation]: 'Image Gen', [FileContext.assistants_output]: 'Assistant Output', [FileContext.message_attachment]: 'Attachment', }; export const columns: ColumnDef[] = [ { id: 'select', header: ({ table }) => ( table.toggleAllPageRowsSelected(!!value)} aria-label="Select all" className="flex" /> ), cell: ({ row }) => ( row.toggleSelected(!!value)} aria-label="Select row" className="flex" /> ), enableSorting: false, enableHiding: false, }, { meta: { size: '150px', }, accessorKey: 'filename', header: ({ column }) => { return ( ); }, cell: ({ row }) => { const file = row.original; if (file.type?.startsWith('image')) { return (
{file.filename}
); } const fileType = getFileType(file.type); return (
{fileType && } {file.filename}
); }, }, { accessorKey: 'updatedAt', header: ({ column }) => { return ( ); }, cell: ({ row }) => formatDate(row.original.updatedAt), }, { accessorKey: 'source', header: ({ column }) => { return ( value === FileSources.local || value === FileSources.openai, ), }} valueMap={{ [FileSources.openai]: 'OpenAI', [FileSources.local]: 'Host', }} /> ); }, cell: ({ row }) => { const { source } = row.original; if (source === FileSources.openai) { return (
{'OpenAI'}
); } return (
{'Host'}
); }, }, { accessorKey: 'context', header: ({ column }) => { return ( value === FileContext[value ?? ''], ), }} valueMap={contextMap} /> ); }, cell: ({ row }) => { const { context } = row.original; return (
{contextMap[context ?? FileContext.unknown] ?? 'Unknown'}
); }, }, { accessorKey: 'bytes', header: ({ column }) => { return ( ); }, cell: ({ row }) => { const suffix = ' MB'; const value = Number((Number(row.original.bytes) / 1024 / 1024).toFixed(2)); if (value < 0.01) { return '< 0.01 MB'; } return `${value}${suffix}`; }, }, ];