mirror of
https://github.com/zebrajr/localGPT.git
synced 2025-12-06 12:20:53 +01:00
feat: Update frontend file validation to accept MD, DOC, TXT, and HTML formats
- Update IndexForm.tsx to accept .md, .doc, .txt, .html, .htm file extensions - Update IndexWizard.tsx file input accept attribute for new formats - Update chat-input.tsx validation logic to handle new MIME types and extensions - Update empty-chat-state.tsx validation logic for comprehensive file support - Update test-upload.html to accept all supported file formats - Resolves frontend file upload restrictions for unstructured document formats Co-Authored-By: PromptEngineer <jnfarooq@outlook.com>
This commit is contained in:
parent
583c72e340
commit
8f3417af15
|
|
@ -99,7 +99,7 @@ export function IndexForm({ onClose, onIndexed }: Props) {
|
||||||
>
|
>
|
||||||
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" className="mb-2 text-white/80"><path d="M4 16v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"/><polyline points="7 10 12 5 17 10"/><line x1="12" y1="5" x2="12" y2="16"/></svg>
|
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" className="mb-2 text-white/80"><path d="M4 16v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"/><polyline points="7 10 12 5 17 10"/><line x1="12" y1="5" x2="12" y2="16"/></svg>
|
||||||
<span className="text-xs text-gray-400">Drag & Drop documents here or click to browse</span>
|
<span className="text-xs text-gray-400">Drag & Drop documents here or click to browse</span>
|
||||||
<input id="file-upload" type="file" accept="application/pdf,.docx,.html,.htm" multiple className="hidden" onChange={(e)=>setFiles(e.target.files)} />
|
<input id="file-upload" type="file" accept="application/pdf,.docx,.doc,.html,.htm,.md,.txt" multiple className="hidden" onChange={(e)=>setFiles(e.target.files)} />
|
||||||
</label>
|
</label>
|
||||||
{files && <p className="mt-1 text-xs text-green-400">{files.length} file(s) selected</p>}
|
{files && <p className="mt-1 text-xs text-green-400">{files.length} file(s) selected</p>}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -220,4 +220,4 @@ export function IndexForm({ onClose, onIndexed }: Props) {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -25,7 +25,7 @@ export function IndexWizard({ onClose }: Props) {
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm mb-1">Document files</label>
|
<label className="block text-sm mb-1">Document files</label>
|
||||||
<input type="file" accept="application/pdf,.docx,.html,.htm" multiple onChange={handleFile} className="text-sm" />
|
<input type="file" accept="application/pdf,.docx,.doc,.html,.htm,.md,.txt" multiple onChange={handleFile} className="text-sm" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="grid grid-cols-2 gap-4">
|
<div className="grid grid-cols-2 gap-4">
|
||||||
|
|
@ -69,4 +69,4 @@ export function IndexWizard({ onClose }: Props) {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -91,10 +91,17 @@ export function ChatInput({
|
||||||
|
|
||||||
if (file.type === 'application/pdf' ||
|
if (file.type === 'application/pdf' ||
|
||||||
file.type === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ||
|
file.type === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ||
|
||||||
|
file.type === 'application/msword' ||
|
||||||
file.type === 'text/html' ||
|
file.type === 'text/html' ||
|
||||||
|
file.type === 'text/markdown' ||
|
||||||
|
file.type === 'text/plain' ||
|
||||||
|
file.name.toLowerCase().endsWith('.pdf') ||
|
||||||
|
file.name.toLowerCase().endsWith('.docx') ||
|
||||||
|
file.name.toLowerCase().endsWith('.doc') ||
|
||||||
file.name.toLowerCase().endsWith('.html') ||
|
file.name.toLowerCase().endsWith('.html') ||
|
||||||
file.name.toLowerCase().endsWith('.htm') ||
|
file.name.toLowerCase().endsWith('.htm') ||
|
||||||
file.name.toLowerCase().endsWith('.docx')) {
|
file.name.toLowerCase().endsWith('.md') ||
|
||||||
|
file.name.toLowerCase().endsWith('.txt')) {
|
||||||
newFiles.push({
|
newFiles.push({
|
||||||
id: crypto.randomUUID(),
|
id: crypto.randomUUID(),
|
||||||
name: file.name,
|
name: file.name,
|
||||||
|
|
@ -157,7 +164,7 @@ export function ChatInput({
|
||||||
|
|
||||||
<div className="bg-white/5 backdrop-blur border border-white/10 rounded-2xl px-5 pt-4 pb-3 space-y-2">
|
<div className="bg-white/5 backdrop-blur border border-white/10 rounded-2xl px-5 pt-4 pb-3 space-y-2">
|
||||||
{/* Hidden file input (kept for future use) */}
|
{/* Hidden file input (kept for future use) */}
|
||||||
<input ref={fileInputRef} type="file" accept=".pdf,.docx,.html,.htm" multiple onChange={handleFileChange} className="hidden" />
|
<input ref={fileInputRef} type="file" accept=".pdf,.docx,.doc,.html,.htm,.md,.txt" multiple onChange={handleFileChange} className="hidden" />
|
||||||
|
|
||||||
{/* Textarea */}
|
{/* Textarea */}
|
||||||
<textarea
|
<textarea
|
||||||
|
|
@ -204,4 +211,4 @@ export function ChatInput({
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -117,10 +117,17 @@ export function EmptyChatState({
|
||||||
const file = files[i];
|
const file = files[i];
|
||||||
if (file.type === 'application/pdf' ||
|
if (file.type === 'application/pdf' ||
|
||||||
file.type === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ||
|
file.type === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ||
|
||||||
|
file.type === 'application/msword' ||
|
||||||
file.type === 'text/html' ||
|
file.type === 'text/html' ||
|
||||||
|
file.type === 'text/markdown' ||
|
||||||
|
file.type === 'text/plain' ||
|
||||||
|
file.name.toLowerCase().endsWith('.pdf') ||
|
||||||
|
file.name.toLowerCase().endsWith('.docx') ||
|
||||||
|
file.name.toLowerCase().endsWith('.doc') ||
|
||||||
file.name.toLowerCase().endsWith('.html') ||
|
file.name.toLowerCase().endsWith('.html') ||
|
||||||
file.name.toLowerCase().endsWith('.htm') ||
|
file.name.toLowerCase().endsWith('.htm') ||
|
||||||
file.name.toLowerCase().endsWith('.docx')) {
|
file.name.toLowerCase().endsWith('.md') ||
|
||||||
|
file.name.toLowerCase().endsWith('.txt')) {
|
||||||
newFiles.push({
|
newFiles.push({
|
||||||
id: crypto.randomUUID(),
|
id: crypto.randomUUID(),
|
||||||
name: file.name,
|
name: file.name,
|
||||||
|
|
@ -224,7 +231,7 @@ export function EmptyChatState({
|
||||||
<input
|
<input
|
||||||
ref={fileInputRef}
|
ref={fileInputRef}
|
||||||
type="file"
|
type="file"
|
||||||
accept=".pdf,.docx,.html,.htm"
|
accept=".pdf,.docx,.doc,.html,.htm,.md,.txt"
|
||||||
multiple
|
multiple
|
||||||
onChange={handleFileChange}
|
onChange={handleFileChange}
|
||||||
className="hidden"
|
className="hidden"
|
||||||
|
|
@ -282,4 +289,4 @@ export function EmptyChatState({
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
<body>
|
<body>
|
||||||
<h1>Test PDF Upload</h1>
|
<h1>Test PDF Upload</h1>
|
||||||
<form id="uploadForm">
|
<form id="uploadForm">
|
||||||
<input type="file" id="fileInput" accept=".pdf,.docx,.html,.htm" />
|
<input type="file" id="fileInput" accept=".pdf,.docx,.doc,.html,.htm,.md,.txt" />
|
||||||
<button type="submit">Upload PDF</button>
|
<button type="submit">Upload PDF</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
@ -51,4 +51,4 @@
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Loading…
Reference in New Issue
Block a user