Spaces:
Running
Running
llm-era/ ├── backend/ │ ├── app.py # FastAPI/Flask backend │ ├── llm_engine.py # Handles prompt, query, and response using DeepSeek-V2 │ ├── document_parser.py # Extracts and cleans data from PDFs, DOCX, Emails │ ├── vector_store.py # FAISS index creation and semantic search │ └── prompt-engine/ │ └── prompt.txt # The LLM prompt for DeepSeek-V2 ├── .env # Store API keys here ├── requirements.txt # Python dependencies └── README.md - Initial Deployment
213dbb6 verified Download index.html from Muzzammil777/doc-parse: direct link, hf CLI and curl.
- Browser
- Download file 15.8 kB
-
https://huggingface.co/spaces/Muzzammil777/doc-parse/resolve/main/index.html
- Command line
-
hf download hf://spaces/Muzzammil777/doc-parse/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Muzzammil777/doc-parse/resolve/main/index.html
15.8 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Document Reasoning Assistant</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <style> | |
| .document-preview { | |
| height: 300px; | |
| overflow-y: auto; | |
| background-color: #f8f9fa; | |
| border: 1px dashed #ccc; | |
| } | |
| .result-json { | |
| font-family: monospace; | |
| white-space: pre-wrap; | |
| background-color: #f8f9fa; | |
| } | |
| .animate-pulse { | |
| animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; | |
| } | |
| @keyframes pulse { | |
| 0%, 100% { | |
| opacity: 1; | |
| } | |
| 50% { | |
| opacity: 0.5; | |
| } | |
| } | |
| .file-upload-label:hover { | |
| background-color: #e9ecef; | |
| } | |
| .clause-card:hover { | |
| transform: translateY(-2px); | |
| box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-50 min-h-screen"> | |
| <div class="container mx-auto px-4 py-8"> | |
| <!-- Header --> | |
| <header class="mb-8"> | |
| <div class="flex items-center justify-between"> | |
| <div> | |
| <h1 class="text-3xl font-bold text-indigo-700"> | |
| <i class="fas fa-brain mr-2"></i>Document Reasoning Assistant | |
| </h1> | |
| <p class="text-gray-600 mt-2"> | |
| Process natural language queries against unstructured documents with AI-powered reasoning | |
| </p> | |
| </div> | |
| <div class="hidden md:block"> | |
| <div class="flex items-center space-x-2 bg-indigo-50 px-4 py-2 rounded-full"> | |
| <span class="h-3 w-3 bg-green-500 rounded-full animate-pulse"></span> | |
| <span class="text-sm text-indigo-700">DeepSeek-V2 Active</span> | |
| </div> | |
| </div> | |
| </div> | |
| </header> | |
| <div class="grid grid-cols-1 lg:grid-cols-3 gap-6"> | |
| <!-- Left Column - Input Section --> | |
| <div class="lg:col-span-2 space-y-6"> | |
| <!-- Query Input --> | |
| <div class="bg-white rounded-xl shadow-sm p-6"> | |
| <h2 class="text-xl font-semibold text-gray-800 mb-4"> | |
| <i class="fas fa-search mr-2 text-indigo-600"></i>Enter Your Query | |
| </h2> | |
| <div class="relative"> | |
| <textarea id="queryInput" rows="3" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500" placeholder="Example: Describe your insurance claim scenario in natural language"></textarea> | |
| <div class="absolute bottom-3 right-3 flex space-x-2"> | |
| <button class="text-gray-500 hover:text-indigo-600"> | |
| <i class="fas fa-microphone"></i> | |
| </button> | |
| <button class="text-gray-500 hover:text-indigo-600"> | |
| <i class="fas fa-magic"></i> | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Document Upload --> | |
| <div class="bg-white rounded-xl shadow-sm p-6"> | |
| <h2 class="text-xl font-semibold text-gray-800 mb-4"> | |
| <i class="fas fa-file-upload mr-2 text-indigo-600"></i>Upload Documents | |
| </h2> | |
| <div class="flex flex-col md:flex-row gap-4"> | |
| <label for="documentUpload" class="file-upload-label flex-1 cursor-pointer"> | |
| <div class="border-2 border-dashed border-gray-300 rounded-lg p-8 text-center hover:border-indigo-500 transition-colors"> | |
| <i class="fas fa-cloud-upload-alt text-4xl text-gray-400 mb-3"></i> | |
| <p class="text-gray-600">Drag & drop files or <span class="text-indigo-600">browse</span></p> | |
| <p class="text-xs text-gray-500 mt-2">PDF, DOCX, TXT, or Email files</p> | |
| </div> | |
| <input id="documentUpload" type="file" class="hidden" multiple accept=".pdf,.docx,.txt,.eml"> | |
| </label> | |
| <div class="flex-1"> | |
| <div class="document-preview rounded-lg p-4"> | |
| <p class="text-gray-500 text-center py-10">Uploaded documents will appear here</p> | |
| <div id="uploadedFiles" class="hidden"> | |
| <!-- Files will be added here dynamically --> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Submit Button --> | |
| <div class="flex justify-end"> | |
| <button id="processButton" class="bg-indigo-600 hover:bg-indigo-700 text-white font-medium py-3 px-6 rounded-lg flex items-center transition-colors"> | |
| <i class="fas fa-play-circle mr-2"></i> Process Query | |
| </button> | |
| </div> | |
| </div> | |
| <!-- Right Column - Results Section --> | |
| <div class="lg:col-span-1"> | |
| <div class="bg-white rounded-xl shadow-sm p-6 sticky top-6"> | |
| <h2 class="text-xl font-semibold text-gray-800 mb-4"> | |
| <i class="fas fa-poll mr-2 text-indigo-600"></i>Results | |
| </h2> | |
| <div id="loadingIndicator" class="hidden text-center py-8"> | |
| <div class="animate-spin rounded-full h-12 w-12 border-b-2 border-indigo-600 mx-auto mb-4"></div> | |
| <p class="text-gray-600">Analyzing documents with DeepSeek-V2...</p> | |
| </div> | |
| <div id="resultsContainer" class="hidden"> | |
| <!-- Decision Card --> | |
| <div class="bg-gradient-to-r from-indigo-50 to-blue-50 rounded-lg p-4 mb-4 border border-indigo-100"> | |
| <div class="flex items-center justify-between mb-2"> | |
| <h3 class="font-semibold text-gray-800">Decision</h3> | |
| <span id="decisionBadge" class="px-3 py-1 rounded-full text-sm font-medium"></span> | |
| </div> | |
| <p id="decisionAmount" class="text-xl font-bold text-indigo-700 mb-1"></p> | |
| <p id="decisionJustification" class="text-sm text-gray-600"></p> | |
| </div> | |
| <!-- Referenced Clauses --> | |
| <div class="mb-4"> | |
| <h3 class="font-semibold text-gray-800 mb-2">Referenced Clauses</h3> | |
| <div id="clausesContainer" class="space-y-3"> | |
| <!-- Clause cards will be added here dynamically --> | |
| </div> | |
| </div> | |
| <!-- Raw JSON --> | |
| <div> | |
| <div class="flex items-center justify-between mb-2"> | |
| <h3 class="font-semibold text-gray-800">JSON Output</h3> | |
| <button id="copyJsonButton" class="text-indigo-600 hover:text-indigo-800 text-sm flex items-center"> | |
| <i class="fas fa-copy mr-1"></i> Copy | |
| </button> | |
| </div> | |
| <div class="result-json text-xs p-3 rounded bg-gray-50 overflow-x-auto" id="jsonOutput"></div> | |
| </div> | |
| </div> | |
| <div id="emptyState" class="text-center py-8"> | |
| <i class="fas fa-file-alt text-4xl text-gray-300 mb-4"></i> | |
| <p class="text-gray-600">Submit a query to see results</p> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Mock data for demonstration | |
| const mockResponse = { | |
| "decision": "Approved", | |
| "amount": "₹1,00,000", | |
| "justification": "Knee surgery is covered after 3 months of policy initiation as per clause 12.2", | |
| "referenced_clauses": [ | |
| { | |
| "clause_id": "12.2", | |
| "text": "Surgical procedures such as knee replacement are covered after 90 days of continuous insurance." | |
| }, | |
| { | |
| "clause_id": "4.1", | |
| "text": "Coverage extends to all major hospitals within India, including those in Pune metropolitan area." | |
| } | |
| ] | |
| }; | |
| // Handle file upload display | |
| const fileUpload = document.getElementById('documentUpload'); | |
| const uploadedFilesContainer = document.getElementById('uploadedFiles'); | |
| fileUpload.addEventListener('change', function(e) { | |
| const files = e.target.files; | |
| if (files.length > 0) { | |
| uploadedFilesContainer.classList.remove('hidden'); | |
| uploadedFilesContainer.innerHTML = ''; | |
| for (let i = 0; i < files.length; i++) { | |
| const file = files[i]; | |
| const fileElement = document.createElement('div'); | |
| fileElement.className = 'flex items-center justify-between bg-gray-50 p-2 rounded mb-2'; | |
| fileElement.innerHTML = ` | |
| <div class="flex items-center"> | |
| <i class="fas fa-file-alt text-gray-500 mr-3"></i> | |
| <span class="text-sm truncate max-w-xs">${file.name}</span> | |
| </div> | |
| <span class="text-xs text-gray-500">${(file.size / 1024).toFixed(1)} KB</span> | |
| `; | |
| uploadedFilesContainer.appendChild(fileElement); | |
| } | |
| // Show document preview placeholder | |
| document.querySelector('.document-preview > p').classList.add('hidden'); | |
| } | |
| }); | |
| // Process button click handler | |
| document.getElementById('processButton').addEventListener('click', function() { | |
| const query = document.getElementById('queryInput').value.trim(); | |
| if (!query) { | |
| alert('Please enter a query'); | |
| return; | |
| } | |
| // Show loading state | |
| document.getElementById('emptyState').classList.add('hidden'); | |
| document.getElementById('loadingIndicator').classList.remove('hidden'); | |
| document.getElementById('resultsContainer').classList.add('hidden'); | |
| // Simulate API call with timeout | |
| setTimeout(function() { | |
| displayResults(mockResponse); | |
| }, 2000); | |
| }); | |
| // Display results function | |
| function displayResults(data) { | |
| document.getElementById('loadingIndicator').classList.add('hidden'); | |
| document.getElementById('resultsContainer').classList.remove('hidden'); | |
| // Set decision | |
| const decisionBadge = document.getElementById('decisionBadge'); | |
| decisionBadge.textContent = data.decision; | |
| if (data.decision.toLowerCase() === 'approved') { | |
| decisionBadge.className = 'px-3 py-1 rounded-full text-sm font-medium bg-green-100 text-green-800'; | |
| } else { | |
| decisionBadge.className = 'px-3 py-1 rounded-full text-sm font-medium bg-red-100 text-red-800'; | |
| } | |
| // Set amount and justification | |
| document.getElementById('decisionAmount').textContent = data.amount || 'N/A'; | |
| document.getElementById('decisionJustification').textContent = data.justification; | |
| // Set clauses | |
| const clausesContainer = document.getElementById('clausesContainer'); | |
| clausesContainer.innerHTML = ''; | |
| data.referenced_clauses.forEach(clause => { | |
| const clauseCard = document.createElement('div'); | |
| clauseCard.className = 'clause-card bg-gray-50 p-3 rounded border border-gray-200 transition-all'; | |
| clauseCard.innerHTML = ` | |
| <div class="flex justify-between items-start mb-1"> | |
| <span class="bg-indigo-100 text-indigo-800 text-xs px-2 py-1 rounded">Clause ${clause.clause_id}</span> | |
| <button class="text-gray-400 hover:text-indigo-600 text-sm"> | |
| <i class="fas fa-bookmark"></i> | |
| </button> | |
| </div> | |
| <p class="text-sm text-gray-700">${clause.text}</p> | |
| `; | |
| clausesContainer.appendChild(clauseCard); | |
| }); | |
| // Set raw JSON | |
| document.getElementById('jsonOutput').textContent = JSON.stringify(data, null, 2); | |
| // Set up copy button | |
| document.getElementById('copyJsonButton').addEventListener('click', function() { | |
| navigator.clipboard.writeText(JSON.stringify(data, null, 2)); | |
| const icon = this.querySelector('i'); | |
| icon.className = 'fas fa-check mr-1'; | |
| setTimeout(() => { | |
| icon.className = 'fas fa-copy mr-1'; | |
| }, 2000); | |
| }); | |
| } | |
| // Sample query button (for demo) | |
| document.querySelector('.fa-magic').parentElement.addEventListener('click', function() { | |
| document.getElementById('queryInput').value = "I need to make a claim for a recent medical procedure"; | |
| }); | |
| }); | |
| </script> | |
| <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Muzzammil777/doc-parse" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |