Merge pull request #488 from langflow-ai/folder-upload-types
validate and filter in one place + fix copy
This commit is contained in:
commit
ccd99e48f6
2 changed files with 32 additions and 30 deletions
|
|
@ -43,6 +43,33 @@ import {
|
||||||
} from "@/lib/upload-utils";
|
} from "@/lib/upload-utils";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
// Supported file extensions - single source of truth
|
||||||
|
const SUPPORTED_EXTENSIONS = [
|
||||||
|
".pdf",
|
||||||
|
".doc",
|
||||||
|
".docx",
|
||||||
|
".pptx",
|
||||||
|
".ppt",
|
||||||
|
".xlsx",
|
||||||
|
".xls",
|
||||||
|
".csv",
|
||||||
|
".txt",
|
||||||
|
".md",
|
||||||
|
".html",
|
||||||
|
".htm",
|
||||||
|
".rtf",
|
||||||
|
".odt",
|
||||||
|
".asciidoc",
|
||||||
|
".adoc",
|
||||||
|
".png",
|
||||||
|
".jpg",
|
||||||
|
".jpeg",
|
||||||
|
".gif",
|
||||||
|
".bmp",
|
||||||
|
".tiff",
|
||||||
|
".webp",
|
||||||
|
];
|
||||||
|
|
||||||
export function KnowledgeDropdown() {
|
export function KnowledgeDropdown() {
|
||||||
const { addTask } = useTask();
|
const { addTask } = useTask();
|
||||||
const { refetch: refetchTasks } = useGetTasksQuery();
|
const { refetch: refetchTasks } = useGetTasksQuery();
|
||||||
|
|
@ -247,43 +274,18 @@ export function KnowledgeDropdown() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const fileList = Array.from(files);
|
const fileList = Array.from(files);
|
||||||
const supportedExtensions = [
|
|
||||||
".pdf",
|
|
||||||
".doc",
|
|
||||||
".docx",
|
|
||||||
".pptx",
|
|
||||||
".ppt",
|
|
||||||
".xlsx",
|
|
||||||
".xls",
|
|
||||||
".csv",
|
|
||||||
".txt",
|
|
||||||
".md",
|
|
||||||
".html",
|
|
||||||
".htm",
|
|
||||||
".rtf",
|
|
||||||
".odt",
|
|
||||||
".asciidoc",
|
|
||||||
".adoc",
|
|
||||||
".png",
|
|
||||||
".jpg",
|
|
||||||
".jpeg",
|
|
||||||
".gif",
|
|
||||||
".bmp",
|
|
||||||
".tiff",
|
|
||||||
".webp",
|
|
||||||
];
|
|
||||||
|
|
||||||
const filteredFiles = fileList.filter((file) => {
|
const filteredFiles = fileList.filter((file) => {
|
||||||
const ext = file.name
|
const ext = file.name
|
||||||
.substring(file.name.lastIndexOf("."))
|
.substring(file.name.lastIndexOf("."))
|
||||||
.toLowerCase();
|
.toLowerCase();
|
||||||
return supportedExtensions.includes(ext);
|
return SUPPORTED_EXTENSIONS.includes(ext);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (filteredFiles.length === 0) {
|
if (filteredFiles.length === 0) {
|
||||||
toast.error("No supported files found", {
|
toast.error("No supported files found", {
|
||||||
description:
|
description:
|
||||||
"Please select a folder containing PDF, DOC, DOCX, TXT, MD, RTF, or ODT files.",
|
"Please select a folder containing supported document files (PDF, DOCX, PPTX, XLSX, CSV, HTML, images, etc.).",
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -543,7 +545,7 @@ export function KnowledgeDropdown() {
|
||||||
type="file"
|
type="file"
|
||||||
onChange={handleFileChange}
|
onChange={handleFileChange}
|
||||||
className="hidden"
|
className="hidden"
|
||||||
accept=".pdf,.doc,.docx,.txt,.md,.rtf,.odt"
|
accept={SUPPORTED_EXTENSIONS.join(",")}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<input
|
<input
|
||||||
|
|
|
||||||
4
uv.lock
generated
4
uv.lock
generated
|
|
@ -1,5 +1,5 @@
|
||||||
version = 1
|
version = 1
|
||||||
revision = 2
|
revision = 3
|
||||||
requires-python = ">=3.13"
|
requires-python = ">=3.13"
|
||||||
resolution-markers = [
|
resolution-markers = [
|
||||||
"platform_machine == 'x86_64' and sys_platform == 'linux'",
|
"platform_machine == 'x86_64' and sys_platform == 'linux'",
|
||||||
|
|
@ -2352,7 +2352,7 @@ wheels = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openrag"
|
name = "openrag"
|
||||||
version = "0.1.35"
|
version = "0.1.37"
|
||||||
source = { editable = "." }
|
source = { editable = "." }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "agentd" },
|
{ name = "agentd" },
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue