Spaces:
Running
Running
File size: 15,823 Bytes
213dbb6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | <!DOCTYPE html>
<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> |