Skip to content

Commit

Permalink
fix: support markdown files (#213)
Browse files Browse the repository at this point in the history
* feat: have global system prompt and decription

* fix: don't auto collapse output schema in UI

* fix: don't delete the sorting functionality, hide observability cols, and other nits

* feat: add documentation

* fix: fixing errors from user study

* fix: accepting markdown files

* fix: accepting markdown files
  • Loading branch information
shreyashankar authored Nov 27, 2024
1 parent ae9b797 commit bbd54bc
Showing 1 changed file with 17 additions and 26 deletions.
43 changes: 17 additions & 26 deletions website/src/components/FileExplorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,20 @@ function mergeFileList(
return dt.files;
}

// Add this type to handle File with relativePath
interface FileWithPath extends File {
relativePath?: string;
}

const SUPPORTED_EXTENSIONS = [
".pdf",
".docx",
".doc",
".txt",
".html",
".pptx",
".md",
] as const;

async function getAllFiles(entry: FileSystemEntry): Promise<FileWithPath[]> {
const files: FileWithPath[] = [];

Expand All @@ -102,16 +111,10 @@ async function getAllFiles(entry: FileSystemEntry): Promise<FileWithPath[]> {
});

// Check if file has supported extension
const supportedExtensions = [
".pdf",
".docx",
".doc",
".txt",
".html",
".pptx",
];
if (
supportedExtensions.some((ext) => file.name.toLowerCase().endsWith(ext))
SUPPORTED_EXTENSIONS.some((ext) =>
file.name.toLowerCase().endsWith(ext)
)
) {
// Create a new file with the full path
const fullPath = path ? `${path}/${file.name}` : file.name;
Expand Down Expand Up @@ -143,10 +146,6 @@ async function getAllFiles(entry: FileSystemEntry): Promise<FileWithPath[]> {

type ConversionMethod = "docling" | "azure";

interface UploadedDataset {
[key: string]: unknown;
}

async function validateJsonDataset(file: Blob): Promise<void> {
const text = await file.text();
let data: unknown;
Expand Down Expand Up @@ -329,16 +328,8 @@ export const FileExplorer: React.FC<FileExplorerProps> = ({
// Handle regular file input
// @ts-expect-error FileList type conversion needs explicit cast
const file = item as FileWithPath;
const supportedExtensions = [
".pdf",
".docx",
".doc",
".txt",
".html",
".pptx",
];
if (
supportedExtensions.some((ext) =>
SUPPORTED_EXTENSIONS.some((ext) =>
file.name.toLowerCase().endsWith(ext)
)
) {
Expand Down Expand Up @@ -838,7 +829,7 @@ export const FileExplorer: React.FC<FileExplorerProps> = ({
type="file"
multiple
className="hidden"
accept=".pdf,.docx,.doc,.txt,.html,.pptx,.md"
accept={SUPPORTED_EXTENSIONS.join(",")}
onChange={(e) => {
if (e.target.files) {
handleFolderUpload(e.target.files);
Expand Down Expand Up @@ -871,7 +862,7 @@ export const FileExplorer: React.FC<FileExplorerProps> = ({
<div className="min-w-0 flex-1 overflow-hidden">
<div className="flex items-center">
<p className="text-sm font-medium text-gray-700 truncate">
{/* @ts-ignore */}
{/* @ts-expect-error FileWithPath type is not fully defined */}
{(file as FileWithPath).relativePath || file.name}
</p>
</div>
Expand Down Expand Up @@ -908,7 +899,7 @@ export const FileExplorer: React.FC<FileExplorerProps> = ({
type="file"
multiple
className="hidden"
accept=".pdf,.docx,.doc,.txt,.html,.pptx"
accept={SUPPORTED_EXTENSIONS.join(",")}
onChange={(e) => {
if (e.target.files) {
handleFolderUpload(e.target.files);
Expand Down

0 comments on commit bbd54bc

Please sign in to comment.