Spaces:
Running
Running
Deploy ProVerBs LaW with logo support
Browse files
app.py
CHANGED
|
@@ -1,866 +1,538 @@
|
|
| 1 |
-
"""
|
| 2 |
-
ProVerBs Legal AI -
|
| 3 |
-
Features
|
| 4 |
-
"""
|
| 5 |
-
|
| 6 |
-
import gradio as gr
|
| 7 |
-
from huggingface_hub import InferenceClient
|
| 8 |
-
import json
|
| 9 |
-
import os
|
| 10 |
-
from datetime import datetime
|
| 11 |
-
from typing import Dict, List, Optional
|
| 12 |
-
import base64
|
| 13 |
-
from pathlib import Path
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
from
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
def
|
| 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 |
-
|
| 296 |
-
)
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
**
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
"""
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
.
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
.
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
<
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
'file/assets/logo_1.jpg',
|
| 540 |
-
'file/assets/logo_2.jpg',
|
| 541 |
-
'file/assets/logo_3.jpg'
|
| 542 |
-
];
|
| 543 |
-
|
| 544 |
-
function randomizeWatermarks() {
|
| 545 |
-
watermarks.forEach((watermark) => {
|
| 546 |
-
// Fade out
|
| 547 |
-
watermark.classList.remove('active');
|
| 548 |
-
watermark.classList.add('hidden');
|
| 549 |
-
|
| 550 |
-
setTimeout(() => {
|
| 551 |
-
// Pick random logo
|
| 552 |
-
const randomLogo = logoImages[Math.floor(Math.random() * logoImages.length)];
|
| 553 |
-
watermark.src = randomLogo;
|
| 554 |
-
|
| 555 |
-
// Fade in
|
| 556 |
-
watermark.classList.remove('hidden');
|
| 557 |
-
watermark.classList.add('active');
|
| 558 |
-
}, 2000);
|
| 559 |
-
});
|
| 560 |
-
}
|
| 561 |
-
|
| 562 |
-
// Initial randomization
|
| 563 |
-
randomizeWatermarks();
|
| 564 |
-
|
| 565 |
-
// Change watermarks every 30 seconds with random logos
|
| 566 |
-
setInterval(randomizeWatermarks, 30000);
|
| 567 |
-
}
|
| 568 |
-
|
| 569 |
-
// Initialize both rotations
|
| 570 |
-
if (document.readyState === 'loading') {
|
| 571 |
-
document.addEventListener('DOMContentLoaded', function() {
|
| 572 |
-
rotateHeaderLogo();
|
| 573 |
-
rotateWatermarks();
|
| 574 |
-
});
|
| 575 |
-
} else {
|
| 576 |
-
rotateHeaderLogo();
|
| 577 |
-
rotateWatermarks();
|
| 578 |
-
}
|
| 579 |
-
</script>
|
| 580 |
-
"""
|
| 581 |
-
|
| 582 |
-
# Create the main application
|
| 583 |
-
demo = gr.Blocks(title="ProVerBs Legal AI Platform")
|
| 584 |
-
|
| 585 |
-
with demo:
|
| 586 |
-
|
| 587 |
-
# Watermark background logos
|
| 588 |
-
gr.HTML(f"""
|
| 589 |
-
<div class="watermark-container">
|
| 590 |
-
<img src="file/assets/logo_1.jpg" class="watermark-logo watermark-1 active" alt="Watermark 1">
|
| 591 |
-
<img src="file/assets/logo_2.jpg" class="watermark-logo watermark-2 active" alt="Watermark 2">
|
| 592 |
-
<img src="file/assets/logo_3.jpg" class="watermark-logo watermark-3 active" alt="Watermark 3">
|
| 593 |
-
<img src="file/assets/logo_1.jpg" class="watermark-logo watermark-4 active" alt="Watermark 4">
|
| 594 |
-
<img src="file/assets/logo_2.jpg" class="watermark-logo watermark-5 active" alt="Watermark 5">
|
| 595 |
-
</div>
|
| 596 |
-
|
| 597 |
-
<style>{custom_css}</style>
|
| 598 |
-
{rotating_logo_js}
|
| 599 |
-
|
| 600 |
-
<!-- Header with Rotating Logos -->
|
| 601 |
-
<div class="header-section">
|
| 602 |
-
<div class="logo-container">
|
| 603 |
-
<img src="file/assets/logo_1.jpg" class="rotating-logo" alt="Logo 1" style="display: block;">
|
| 604 |
-
<img src="file/assets/logo_2.jpg" class="rotating-logo" alt="Logo 2" style="display: none;">
|
| 605 |
-
<img src="file/assets/logo_3.jpg" class="rotating-logo" alt="Logo 3" style="display: none;">
|
| 606 |
-
</div>
|
| 607 |
-
<h1>⚖️ ProVerBs Legal AI Platform</h1>
|
| 608 |
-
<p>Lawful vs. Legal: Dual Analysis "Adappt'plication"</p>
|
| 609 |
-
<p style="font-size: 1rem; margin-top: 10px;">
|
| 610 |
-
Multi-AI Legal System | 5 AI Models Working Together 🚀
|
| 611 |
-
</p>
|
| 612 |
-
</div>
|
| 613 |
-
""")
|
| 614 |
-
|
| 615 |
-
gr.Markdown("---")
|
| 616 |
-
|
| 617 |
-
# Main Tabs
|
| 618 |
-
with gr.Tabs():
|
| 619 |
-
|
| 620 |
-
# Tab 1: Welcome
|
| 621 |
-
with gr.Tab("🏠 Welcome"):
|
| 622 |
-
gr.Markdown("""
|
| 623 |
-
## Welcome to ProVerBs Legal AI Platform
|
| 624 |
-
|
| 625 |
-
### 🤖 5 AI Models Integrated:
|
| 626 |
-
|
| 627 |
-
1. **DeepSeek-OCR** - Extract text from scanned documents
|
| 628 |
-
2. **ERNIE-4.5-VL** - Advanced vision-language understanding
|
| 629 |
-
3. **OpenAI GDPVAL** - Legal knowledge dataset
|
| 630 |
-
4. **Meta Llama 3.3** - General AI assistance
|
| 631 |
-
5. **MiniMax-M2** - Advanced text generation
|
| 632 |
-
|
| 633 |
-
### ⚖️ 7 Specialized Modes:
|
| 634 |
-
|
| 635 |
-
- 📍 Navigation Guide
|
| 636 |
-
- 💬 General Legal Assistant (with GDPVAL)
|
| 637 |
-
- 📄 Document Validator (OCR + Vision AI)
|
| 638 |
-
- 🔍 Legal Research (GDPVAL-powered)
|
| 639 |
-
- 📚 Etymology Expert
|
| 640 |
-
- 💼 Case Management
|
| 641 |
-
- 📋 Regulatory Updates
|
| 642 |
-
|
| 643 |
-
### ✨ Unique Features:
|
| 644 |
-
|
| 645 |
-
- **Multi-AI Document Analysis**: Combines OCR + Vision AI
|
| 646 |
-
- **Legal Knowledge Base**: Access to GDPVAL dataset
|
| 647 |
-
- **Rotating Custom Logos**: Your professional branding
|
| 648 |
-
- **Complete Legal Solution**: All-in-one platform
|
| 649 |
-
""")
|
| 650 |
-
|
| 651 |
-
# Tab 2: AI Legal Chatbot
|
| 652 |
-
with gr.Tab("🤖 AI Legal Chatbot"):
|
| 653 |
-
gr.Markdown("""
|
| 654 |
-
## Multi-AI Legal Chatbot
|
| 655 |
-
|
| 656 |
-
**Powered by 5 AI Models** for comprehensive legal assistance!
|
| 657 |
-
|
| 658 |
-
**Choose Your AI Model:**
|
| 659 |
-
- **Meta Llama 3.3** - Fast, efficient, streaming responses
|
| 660 |
-
- **MiniMax-M2** - Advanced text generation capabilities
|
| 661 |
-
""")
|
| 662 |
-
|
| 663 |
-
mode_selector = gr.Dropdown(
|
| 664 |
-
choices=[
|
| 665 |
-
"navigation",
|
| 666 |
-
"general",
|
| 667 |
-
"document_validation",
|
| 668 |
-
"legal_research",
|
| 669 |
-
"etymology",
|
| 670 |
-
"case_management",
|
| 671 |
-
"regulatory_updates"
|
| 672 |
-
],
|
| 673 |
-
value="navigation",
|
| 674 |
-
label="Select AI Assistant Mode"
|
| 675 |
-
)
|
| 676 |
-
|
| 677 |
-
model_selector = gr.Dropdown(
|
| 678 |
-
choices=[
|
| 679 |
-
"Meta Llama 3.3",
|
| 680 |
-
"MiniMax-M2"
|
| 681 |
-
],
|
| 682 |
-
value="Meta Llama 3.3",
|
| 683 |
-
label="Select AI Model"
|
| 684 |
-
)
|
| 685 |
-
|
| 686 |
-
gr.Markdown("---")
|
| 687 |
-
|
| 688 |
-
chatbot = gr.ChatInterface(
|
| 689 |
-
respond_with_mode,
|
| 690 |
-
chatbot=gr.Chatbot(height=500),
|
| 691 |
-
additional_inputs=[
|
| 692 |
-
mode_selector,
|
| 693 |
-
model_selector,
|
| 694 |
-
gr.Slider(128, 4096, value=2048, label="Max Tokens"),
|
| 695 |
-
gr.Slider(0.1, 2.0, value=0.7, label="Temperature"),
|
| 696 |
-
gr.Slider(0.1, 1.0, value=0.95, label="Top-p"),
|
| 697 |
-
],
|
| 698 |
-
examples=[
|
| 699 |
-
["How do I use the multi-AI document analysis?"],
|
| 700 |
-
["Search GDPVAL for contract law information"],
|
| 701 |
-
["Analyze a document with vision AI"],
|
| 702 |
-
],
|
| 703 |
-
)
|
| 704 |
-
|
| 705 |
-
# Tab 3: Document Analysis (NEW!)
|
| 706 |
-
with gr.Tab("📄 Document Analysis"):
|
| 707 |
-
gr.Markdown("""
|
| 708 |
-
## 📄 Document Upload & AI Analysis
|
| 709 |
-
|
| 710 |
-
Upload legal documents for comprehensive AI analysis!
|
| 711 |
-
""")
|
| 712 |
-
|
| 713 |
-
with gr.Row():
|
| 714 |
-
with gr.Column(scale=1):
|
| 715 |
-
doc_upload = gr.File(
|
| 716 |
-
label="📎 Upload Document",
|
| 717 |
-
file_types=[".pdf", ".jpg", ".jpeg", ".png", ".txt"]
|
| 718 |
-
)
|
| 719 |
-
|
| 720 |
-
analysis_type = gr.Radio(
|
| 721 |
-
choices=[
|
| 722 |
-
"Complete Analysis",
|
| 723 |
-
"OCR Only",
|
| 724 |
-
"Visual Only",
|
| 725 |
-
"Legal Validation"
|
| 726 |
-
],
|
| 727 |
-
value="Complete Analysis",
|
| 728 |
-
label="Analysis Type"
|
| 729 |
-
)
|
| 730 |
-
|
| 731 |
-
analyze_btn = gr.Button("🔍 Analyze", variant="primary", size="lg")
|
| 732 |
-
|
| 733 |
-
with gr.Column(scale=2):
|
| 734 |
-
analysis_output = gr.Markdown("Upload a document to begin analysis.")
|
| 735 |
-
|
| 736 |
-
def analyze_doc(file_path, analysis_type):
|
| 737 |
-
if not file_path:
|
| 738 |
-
return "⚠️ Please upload a document first."
|
| 739 |
-
|
| 740 |
-
filename = file_path.split('/')[-1] if '/' in file_path else file_path.split('\\')[-1]
|
| 741 |
-
|
| 742 |
-
return f"""
|
| 743 |
-
## 📄 Document Analysis Results
|
| 744 |
-
|
| 745 |
-
**File:** {filename}
|
| 746 |
-
**Analysis Type:** {analysis_type}
|
| 747 |
-
|
| 748 |
-
### ⚠️ Preview Mode
|
| 749 |
-
|
| 750 |
-
**What happens in production:**
|
| 751 |
-
- **DeepSeek-OCR** extracts text from images
|
| 752 |
-
- **ERNIE-4.5-VL** analyzes document structure
|
| 753 |
-
- **Legal AI** validates completeness
|
| 754 |
-
|
| 755 |
-
**Demo Output:**
|
| 756 |
-
- Document uploaded successfully ✅
|
| 757 |
-
- File format supported ✅
|
| 758 |
-
- Ready for AI analysis ✅
|
| 759 |
-
|
| 760 |
-
**Note:** Full analysis available after HF deployment.
|
| 761 |
-
|
| 762 |
-
**Try it:** Upload any legal document (PDF, image, text) to see the interface!
|
| 763 |
-
"""
|
| 764 |
-
|
| 765 |
-
analyze_btn.click(
|
| 766 |
-
fn=analyze_doc,
|
| 767 |
-
inputs=[doc_upload, analysis_type],
|
| 768 |
-
outputs=analysis_output
|
| 769 |
-
)
|
| 770 |
-
|
| 771 |
-
# Tab 4: Features
|
| 772 |
-
with gr.Tab("✨ Features"):
|
| 773 |
-
gr.Markdown("""
|
| 774 |
-
## Advanced AI Features
|
| 775 |
-
|
| 776 |
-
### 🤖 Integrated AI Models:
|
| 777 |
-
|
| 778 |
-
1. **DeepSeek-OCR**
|
| 779 |
-
- Text extraction from images
|
| 780 |
-
- Document scanning
|
| 781 |
-
- High accuracy OCR
|
| 782 |
-
|
| 783 |
-
2. **ERNIE-4.5-VL** (Baidu)
|
| 784 |
-
- Vision-language understanding
|
| 785 |
-
- Document layout analysis
|
| 786 |
-
- Visual question answering
|
| 787 |
-
|
| 788 |
-
3. **OpenAI GDPVAL**
|
| 789 |
-
- Legal knowledge dataset
|
| 790 |
-
- Case law and precedents
|
| 791 |
-
- Regulatory information
|
| 792 |
-
|
| 793 |
-
4. **Meta Llama 3.3**
|
| 794 |
-
- General AI assistance
|
| 795 |
-
- Legal reasoning
|
| 796 |
-
- Natural conversation
|
| 797 |
-
|
| 798 |
-
5. **MiniMax-M2** ⭐ NEW!
|
| 799 |
-
- Advanced text generation
|
| 800 |
-
- High-quality responses
|
| 801 |
-
- Alternative AI model option
|
| 802 |
-
|
| 803 |
-
### 🎯 What This Means:
|
| 804 |
-
|
| 805 |
-
- **Most Advanced**: 5 AI models working together
|
| 806 |
-
- **Best Analysis**: Multiple AI perspectives
|
| 807 |
-
- **Model Choice**: Select the best AI for your task
|
| 808 |
-
- **Comprehensive**: Text + Vision + Knowledge
|
| 809 |
-
- **Professional**: Your custom branding with logos
|
| 810 |
-
""")
|
| 811 |
-
|
| 812 |
-
# Tab 4: About
|
| 813 |
-
with gr.Tab("ℹ️ About"):
|
| 814 |
-
gr.Markdown("""
|
| 815 |
-
## About ProVerBs Legal AI - Complete Edition
|
| 816 |
-
|
| 817 |
-
### 🚀 Version 2.1.0 - Complete Multi-AI Integration
|
| 818 |
-
|
| 819 |
-
**This is the most advanced version** with all AI capabilities:
|
| 820 |
-
|
| 821 |
-
- ✅ 7 Specialized AI Modes
|
| 822 |
-
- ✅ 3 Rotating Custom Logos
|
| 823 |
-
- ✅ DeepSeek-OCR Integration
|
| 824 |
-
- ✅ ERNIE-4.5-VL Vision AI
|
| 825 |
-
- ✅ OpenAI GDPVAL Dataset
|
| 826 |
-
- ✅ Meta Llama 3.3 AI
|
| 827 |
-
- ✅ MiniMax-M2 AI ⭐ NEW!
|
| 828 |
-
|
| 829 |
-
### 📊 Technical Stack:
|
| 830 |
-
|
| 831 |
-
- **Frontend**: Gradio 4.x
|
| 832 |
-
- **OCR**: DeepSeek-OCR
|
| 833 |
-
- **Vision**: ERNIE-4.5-VL-28B
|
| 834 |
-
- **Dataset**: OpenAI GDPVAL
|
| 835 |
-
- **LLM 1**: Meta Llama 3.3-70B
|
| 836 |
-
- **LLM 2**: MiniMax-M2
|
| 837 |
-
- **Platform**: Hugging Face Spaces
|
| 838 |
-
|
| 839 |
-
### ⚠️ Disclaimer:
|
| 840 |
-
|
| 841 |
-
This platform provides general legal information only.
|
| 842 |
-
Always consult with a qualified attorney for specific legal matters.
|
| 843 |
-
|
| 844 |
-
---
|
| 845 |
-
|
| 846 |
-
**Version 2.1.0** | Built by Solomon7890 | 5-Model AI Legal Platform
|
| 847 |
-
""")
|
| 848 |
-
|
| 849 |
-
# Footer
|
| 850 |
-
gr.Markdown("""
|
| 851 |
-
---
|
| 852 |
-
<div style="text-align: center; padding: 20px;">
|
| 853 |
-
<p><strong>⚖️ ProVerBs Legal AI Platform</strong> | Version 2.1.0 - 5-Model AI Edition</p>
|
| 854 |
-
<p>Powered by: DeepSeek-OCR • ERNIE-4.5-VL • GDPVAL • Llama 3.3 • MiniMax-M2</p>
|
| 855 |
-
<p>© 2024 ProVerBs Legal AI</p>
|
| 856 |
-
</div>
|
| 857 |
-
""")
|
| 858 |
-
|
| 859 |
-
if __name__ == "__main__":
|
| 860 |
-
demo.queue(max_size=20)
|
| 861 |
-
demo.launch(
|
| 862 |
-
server_name="0.0.0.0",
|
| 863 |
-
server_port=7860,
|
| 864 |
-
share=False,
|
| 865 |
-
show_error=True
|
| 866 |
-
)
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
ProVerBs Legal AI - Integrated Landing Page with Rotating Logos
|
| 3 |
+
Features your custom logos with 60-second rotation
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
import gradio as gr
|
| 7 |
+
from huggingface_hub import InferenceClient
|
| 8 |
+
import json
|
| 9 |
+
import os
|
| 10 |
+
from datetime import datetime
|
| 11 |
+
from typing import Dict, List, Optional
|
| 12 |
+
import base64
|
| 13 |
+
from pathlib import Path
|
| 14 |
+
|
| 15 |
+
class AILegalChatbotIntegration:
|
| 16 |
+
"""
|
| 17 |
+
Integration of your AI Legal Chatbot into Gradio
|
| 18 |
+
Supports all specialized modes from your original chatbot
|
| 19 |
+
"""
|
| 20 |
+
|
| 21 |
+
def __init__(self):
|
| 22 |
+
self.specialized_modes = {
|
| 23 |
+
"navigation": "Application Navigation Guide",
|
| 24 |
+
"general": "General Legal Assistant",
|
| 25 |
+
"document_validation": "Document Validator",
|
| 26 |
+
"legal_research": "Legal Research Assistant",
|
| 27 |
+
"etymology": "Legal Etymology Lookup",
|
| 28 |
+
"case_management": "Case Management Helper",
|
| 29 |
+
"regulatory_updates": "Regulatory Update Monitor"
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
def get_mode_system_prompt(self, mode: str) -> str:
|
| 33 |
+
"""Get specialized system prompt based on mode"""
|
| 34 |
+
prompts = {
|
| 35 |
+
"navigation": """You are a ProVerBs Application Navigation Guide. Help users navigate the application's features:
|
| 36 |
+
|
| 37 |
+
**Available Features:**
|
| 38 |
+
- Legal Action Advisor: Get recommendations for seeking justice
|
| 39 |
+
- Document Analysis: Upload and analyze legal documents
|
| 40 |
+
- Legal Research: Access comprehensive legal databases
|
| 41 |
+
- Communications: SMS, email, and phone integration
|
| 42 |
+
- Document Generation: Create legal documents with AI
|
| 43 |
+
|
| 44 |
+
Guide users to the right features and explain how to use them effectively.""",
|
| 45 |
+
|
| 46 |
+
"general": """You are a General Legal Assistant for ProVerBs Legal AI Platform. Provide accurate legal information while noting that you cannot provide legal advice. Always recommend consulting with a licensed attorney for specific legal matters. Be professional, thorough, and cite relevant legal principles when possible.""",
|
| 47 |
+
|
| 48 |
+
"document_validation": """You are a Document Validator. Analyze legal documents for:
|
| 49 |
+
- Completeness and required elements
|
| 50 |
+
- Legal terminology accuracy
|
| 51 |
+
- Structural integrity
|
| 52 |
+
- Common issues and red flags
|
| 53 |
+
Provide specific feedback on document quality and validity.""",
|
| 54 |
+
|
| 55 |
+
"legal_research": """You are a Legal Research Assistant. Help users:
|
| 56 |
+
- Find relevant case law and precedents
|
| 57 |
+
- Understand statutes and regulations
|
| 58 |
+
- Research legal principles and concepts
|
| 59 |
+
- Cite authoritative legal sources
|
| 60 |
+
Provide comprehensive research guidance.""",
|
| 61 |
+
|
| 62 |
+
"etymology": """You are a Legal Etymology Expert. Explain the origins and meanings of legal terms:
|
| 63 |
+
- Latin and historical roots
|
| 64 |
+
- Evolution of legal terminology
|
| 65 |
+
- Modern usage and interpretation
|
| 66 |
+
- Related legal concepts
|
| 67 |
+
Make legal language accessible and understandable.""",
|
| 68 |
+
|
| 69 |
+
"case_management": """You are a Case Management Helper. Assist with:
|
| 70 |
+
- Organizing case information
|
| 71 |
+
- Tracking deadlines and milestones
|
| 72 |
+
- Managing documents and evidence
|
| 73 |
+
- Coordinating case activities
|
| 74 |
+
Provide practical case management advice.""",
|
| 75 |
+
|
| 76 |
+
"regulatory_updates": """You are a Regulatory Update Monitor. Keep users informed about:
|
| 77 |
+
- Recent legal and regulatory changes
|
| 78 |
+
- Industry-specific compliance updates
|
| 79 |
+
- Important legislative developments
|
| 80 |
+
- Impact analysis of new regulations
|
| 81 |
+
Provide timely and relevant regulatory information."""
|
| 82 |
+
}
|
| 83 |
+
return prompts.get(mode, prompts["general"])
|
| 84 |
+
|
| 85 |
+
def format_navigation_response(self, query: str) -> str:
|
| 86 |
+
"""Format response for navigation queries"""
|
| 87 |
+
query_lower = query.lower()
|
| 88 |
+
|
| 89 |
+
recommendations = []
|
| 90 |
+
|
| 91 |
+
if any(word in query_lower for word in ["document", "contract", "agreement", "analyze"]):
|
| 92 |
+
recommendations.append("📄 **Document Analysis** - Upload and analyze your documents")
|
| 93 |
+
|
| 94 |
+
if any(word in query_lower for word in ["research", "case", "law", "statute"]):
|
| 95 |
+
recommendations.append("🔍 **Legal Research** - Access comprehensive legal databases")
|
| 96 |
+
|
| 97 |
+
if any(word in query_lower for word in ["action", "remedy", "justice", "sue"]):
|
| 98 |
+
recommendations.append("⚖️ **Legal Action Advisor** - Get recommendations for your situation")
|
| 99 |
+
|
| 100 |
+
if any(word in query_lower for word in ["create", "generate", "template", "form"]):
|
| 101 |
+
recommendations.append("📝 **Document Generation** - Create legal documents with AI")
|
| 102 |
+
|
| 103 |
+
if any(word in query_lower for word in ["communicate", "message", "sms", "email"]):
|
| 104 |
+
recommendations.append("📧 **Communications** - Integrated messaging system")
|
| 105 |
+
|
| 106 |
+
if recommendations:
|
| 107 |
+
return "### I can help you with these features:\n\n" + "\n".join(recommendations) + "\n\n**What would you like to explore?**"
|
| 108 |
+
|
| 109 |
+
return None
|
| 110 |
+
|
| 111 |
+
def respond_with_mode(
|
| 112 |
+
message,
|
| 113 |
+
history: list,
|
| 114 |
+
mode: str,
|
| 115 |
+
max_tokens: int,
|
| 116 |
+
temperature: float,
|
| 117 |
+
top_p: float,
|
| 118 |
+
hf_token: gr.OAuthToken | None = None
|
| 119 |
+
):
|
| 120 |
+
"""Generate AI response based on selected mode"""
|
| 121 |
+
chatbot_integration = AILegalChatbotIntegration()
|
| 122 |
+
|
| 123 |
+
system_message = chatbot_integration.get_mode_system_prompt(mode)
|
| 124 |
+
|
| 125 |
+
if mode == "navigation":
|
| 126 |
+
nav_response = chatbot_integration.format_navigation_response(message)
|
| 127 |
+
if nav_response:
|
| 128 |
+
yield nav_response
|
| 129 |
+
return
|
| 130 |
+
|
| 131 |
+
token = hf_token.token if hf_token else None
|
| 132 |
+
client = InferenceClient(token=token, model="meta-llama/Llama-3.3-70B-Instruct")
|
| 133 |
+
|
| 134 |
+
messages = [{"role": "system", "content": system_message}]
|
| 135 |
+
|
| 136 |
+
for user_msg, assistant_msg in history:
|
| 137 |
+
if user_msg:
|
| 138 |
+
messages.append({"role": "user", "content": user_msg})
|
| 139 |
+
if assistant_msg:
|
| 140 |
+
messages.append({"role": "assistant", "content": assistant_msg})
|
| 141 |
+
|
| 142 |
+
messages.append({"role": "user", "content": message})
|
| 143 |
+
|
| 144 |
+
response = ""
|
| 145 |
+
try:
|
| 146 |
+
for message_chunk in client.chat_completion(
|
| 147 |
+
messages,
|
| 148 |
+
max_tokens=max_tokens,
|
| 149 |
+
stream=True,
|
| 150 |
+
temperature=temperature,
|
| 151 |
+
top_p=top_p,
|
| 152 |
+
):
|
| 153 |
+
if message_chunk.choices and message_chunk.choices[0].delta.content:
|
| 154 |
+
token = message_chunk.choices[0].delta.content
|
| 155 |
+
response += token
|
| 156 |
+
yield response
|
| 157 |
+
except Exception as e:
|
| 158 |
+
yield f"Error: {str(e)}"
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
# Custom CSS with rotating logo animation
|
| 162 |
+
custom_css = """
|
| 163 |
+
.gradio-container {
|
| 164 |
+
max-width: 1200px !important;
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
.header-section {
|
| 168 |
+
text-align: center;
|
| 169 |
+
padding: 40px 20px;
|
| 170 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 171 |
+
color: white;
|
| 172 |
+
border-radius: 12px;
|
| 173 |
+
margin-bottom: 30px;
|
| 174 |
+
position: relative;
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
.logo-container {
|
| 178 |
+
margin-bottom: 20px;
|
| 179 |
+
display: flex;
|
| 180 |
+
justify-content: center;
|
| 181 |
+
align-items: center;
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
.rotating-logo {
|
| 185 |
+
width: 150px;
|
| 186 |
+
height: 150px;
|
| 187 |
+
border-radius: 50%;
|
| 188 |
+
object-fit: cover;
|
| 189 |
+
border: 4px solid rgba(255, 255, 255, 0.8);
|
| 190 |
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
|
| 191 |
+
animation: fadeInOut 60s infinite;
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
@keyframes fadeInOut {
|
| 195 |
+
0%, 20% { opacity: 1; }
|
| 196 |
+
25%, 45% { opacity: 0; }
|
| 197 |
+
50%, 70% { opacity: 1; }
|
| 198 |
+
75%, 95% { opacity: 0; }
|
| 199 |
+
100% { opacity: 1; }
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
.logo-1 { animation-delay: 0s; }
|
| 203 |
+
.logo-2 { animation-delay: 20s; }
|
| 204 |
+
.logo-3 { animation-delay: 40s; }
|
| 205 |
+
|
| 206 |
+
.header-section h1 {
|
| 207 |
+
font-size: 3rem;
|
| 208 |
+
margin-bottom: 10px;
|
| 209 |
+
font-weight: 700;
|
| 210 |
+
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
.mode-selector {
|
| 214 |
+
font-size: 1.1rem !important;
|
| 215 |
+
font-weight: 600 !important;
|
| 216 |
+
padding: 12px !important;
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
.tab-nav button {
|
| 220 |
+
font-size: 16px;
|
| 221 |
+
font-weight: 600;
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
.feature-card {
|
| 225 |
+
border: 2px solid #e0e0e0;
|
| 226 |
+
border-radius: 12px;
|
| 227 |
+
padding: 20px;
|
| 228 |
+
margin: 10px;
|
| 229 |
+
background: #f8f9fa;
|
| 230 |
+
transition: all 0.3s;
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
.feature-card:hover {
|
| 234 |
+
border-color: #667eea;
|
| 235 |
+
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
|
| 236 |
+
transform: translateY(-2px);
|
| 237 |
+
}
|
| 238 |
+
"""
|
| 239 |
+
|
| 240 |
+
# JavaScript for rotating logos
|
| 241 |
+
rotating_logo_js = """
|
| 242 |
+
<script>
|
| 243 |
+
function rotateLogo() {
|
| 244 |
+
const logos = document.querySelectorAll('.rotating-logo');
|
| 245 |
+
let currentIndex = 0;
|
| 246 |
+
|
| 247 |
+
function showNextLogo() {
|
| 248 |
+
logos.forEach((logo, index) => {
|
| 249 |
+
logo.style.display = 'none';
|
| 250 |
+
});
|
| 251 |
+
|
| 252 |
+
logos[currentIndex].style.display = 'block';
|
| 253 |
+
|
| 254 |
+
currentIndex = (currentIndex + 1) % logos.length;
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
// Show first logo initially
|
| 258 |
+
showNextLogo();
|
| 259 |
+
|
| 260 |
+
// Rotate every 60 seconds
|
| 261 |
+
setInterval(showNextLogo, 60000);
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
// Start rotation when page loads
|
| 265 |
+
if (document.readyState === 'loading') {
|
| 266 |
+
document.addEventListener('DOMContentLoaded', rotateLogo);
|
| 267 |
+
} else {
|
| 268 |
+
rotateLogo();
|
| 269 |
+
}
|
| 270 |
+
</script>
|
| 271 |
+
"""
|
| 272 |
+
|
| 273 |
+
# Create the main application
|
| 274 |
+
demo = gr.Blocks(title="ProVerBs Legal AI Platform")
|
| 275 |
+
demo.css = custom_css
|
| 276 |
+
|
| 277 |
+
with demo:
|
| 278 |
+
|
| 279 |
+
# Header with Rotating Logos
|
| 280 |
+
gr.HTML(f"""
|
| 281 |
+
<div class="header-section">
|
| 282 |
+
<div class="logo-container">
|
| 283 |
+
<img src="file/assets/logo_1.jpg" class="rotating-logo logo-1" alt="ProVerBs Logo 1" style="display: block;">
|
| 284 |
+
<img src="file/assets/logo_2.jpg" class="rotating-logo logo-2" alt="ProVerBs Logo 2" style="display: none;">
|
| 285 |
+
<img src="file/assets/logo_3.jpg" class="rotating-logo logo-3" alt="ProVerBs Logo 3" style="display: none;">
|
| 286 |
+
</div>
|
| 287 |
+
<h1>⚖️ ProVerBs Legal AI Platform</h1>
|
| 288 |
+
<p>Lawful vs. Legal: Dual Analysis "Adappt'plication"</p>
|
| 289 |
+
<p style="font-size: 1rem; margin-top: 10px;">
|
| 290 |
+
Professional Legal AI System | Multi-Module Platform | Powered by Advanced AI
|
| 291 |
+
</p>
|
| 292 |
+
</div>
|
| 293 |
+
{rotating_logo_js}
|
| 294 |
+
""")
|
| 295 |
+
|
| 296 |
+
# Login Section (commented out for local preview)
|
| 297 |
+
# with gr.Row():
|
| 298 |
+
# with gr.Column(scale=1):
|
| 299 |
+
# gr.LoginButton(size="lg")
|
| 300 |
+
# with gr.Column(scale=5):
|
| 301 |
+
# gr.Markdown("👈 **Login with your Hugging Face account** for full access")
|
| 302 |
+
|
| 303 |
+
gr.Markdown("---")
|
| 304 |
+
|
| 305 |
+
# Main Tabs
|
| 306 |
+
with gr.Tabs() as tabs:
|
| 307 |
+
|
| 308 |
+
# Tab 1: Welcome
|
| 309 |
+
with gr.Tab("🏠 Welcome", id="welcome"):
|
| 310 |
+
gr.Markdown("""
|
| 311 |
+
## Welcome to ProVerBs Legal AI Platform
|
| 312 |
+
|
| 313 |
+
A comprehensive legal AI system with **multiple specialized assistants** to help you navigate legal matters.
|
| 314 |
+
|
| 315 |
+
### 🎯 Choose Your AI Assistant Mode
|
| 316 |
+
|
| 317 |
+
Our platform features **7 specialized AI modes** to serve your specific needs:
|
| 318 |
+
|
| 319 |
+
- **📍 Navigation Guide** - Help finding features in the platform
|
| 320 |
+
- **💬 General Legal Assistant** - Broad legal questions and guidance
|
| 321 |
+
- **📄 Document Validator** - Analyze and validate legal documents
|
| 322 |
+
- **🔍 Legal Research** - Case law and statutory research
|
| 323 |
+
- **📚 Etymology Expert** - Understanding legal terminology origins
|
| 324 |
+
- **💼 Case Management** - Organizing and tracking legal cases
|
| 325 |
+
- **📋 Regulatory Updates** - Stay informed about legal changes
|
| 326 |
+
|
| 327 |
+
### ⚖️ Platform Features
|
| 328 |
+
|
| 329 |
+
- **Legal Action Advisor** - Get personalized recommendations
|
| 330 |
+
- **Document Analysis** - AI-powered document processing
|
| 331 |
+
- **Legal Research Tools** - Comprehensive databases
|
| 332 |
+
- **Communications** - Integrated SMS, email, phone
|
| 333 |
+
- **Document Generation** - Create legal documents with AI
|
| 334 |
+
|
| 335 |
+
**Ready to start?** Click the "AI Legal Chatbot" tab to begin!
|
| 336 |
+
""")
|
| 337 |
+
|
| 338 |
+
# Tab 2: AI Legal Chatbot
|
| 339 |
+
with gr.Tab("🤖 AI Legal Chatbot", id="chatbot"):
|
| 340 |
+
gr.Markdown("""
|
| 341 |
+
## AI Legal Chatbot - Multiple Specialized Modes
|
| 342 |
+
|
| 343 |
+
Select your assistant mode below and start chatting!
|
| 344 |
+
""")
|
| 345 |
+
|
| 346 |
+
mode_selector = gr.Dropdown(
|
| 347 |
+
choices=list({
|
| 348 |
+
"navigation": "📍 Navigation Guide - Find features in the app",
|
| 349 |
+
"general": "💬 General Legal Assistant - Broad legal questions",
|
| 350 |
+
"document_validation": "📄 Document Validator - Analyze documents",
|
| 351 |
+
"legal_research": "🔍 Legal Research - Case law & statutes",
|
| 352 |
+
"etymology": "📚 Etymology Expert - Legal term origins",
|
| 353 |
+
"case_management": "💼 Case Management - Organize cases",
|
| 354 |
+
"regulatory_updates": "📋 Regulatory Updates - Legal changes"
|
| 355 |
+
}.items()),
|
| 356 |
+
value="navigation",
|
| 357 |
+
label="Select AI Assistant Mode",
|
| 358 |
+
elem_classes=["mode-selector"]
|
| 359 |
+
)
|
| 360 |
+
|
| 361 |
+
gr.Markdown("---")
|
| 362 |
+
|
| 363 |
+
chatbot = gr.ChatInterface(
|
| 364 |
+
lambda message, history, mode, max_tokens, temperature, top_p, hf_token:
|
| 365 |
+
respond_with_mode(message, history, mode.split(":")[0], max_tokens, temperature, top_p, hf_token),
|
| 366 |
+
chatbot=gr.Chatbot(
|
| 367 |
+
height=500,
|
| 368 |
+
placeholder="💬 Select a mode above and ask your question...",
|
| 369 |
+
show_label=False,
|
| 370 |
+
),
|
| 371 |
+
textbox=gr.Textbox(
|
| 372 |
+
placeholder="Type your question here...",
|
| 373 |
+
container=False,
|
| 374 |
+
scale=7
|
| 375 |
+
),
|
| 376 |
+
additional_inputs=[
|
| 377 |
+
mode_selector,
|
| 378 |
+
gr.Slider(128, 4096, value=2048, step=128, label="Max Tokens"),
|
| 379 |
+
gr.Slider(0.1, 2.0, value=0.7, step=0.1, label="Temperature"),
|
| 380 |
+
gr.Slider(0.1, 1.0, value=0.95, step=0.05, label="Top-p"),
|
| 381 |
+
],
|
| 382 |
+
examples=[
|
| 383 |
+
["How do I navigate to the document analysis feature?"],
|
| 384 |
+
["What is the difference between lawful and legal?"],
|
| 385 |
+
["Can you help me validate a contract?"],
|
| 386 |
+
["I need to research case law about contracts"],
|
| 387 |
+
["What does 'habeas corpus' mean?"],
|
| 388 |
+
["How do I organize my legal case documents?"],
|
| 389 |
+
["What are the latest regulatory changes in business law?"],
|
| 390 |
+
],
|
| 391 |
+
cache_examples=False,
|
| 392 |
+
)
|
| 393 |
+
|
| 394 |
+
gr.Markdown("""
|
| 395 |
+
### 💡 Tips for Best Results
|
| 396 |
+
|
| 397 |
+
- **Choose the right mode** for your question type
|
| 398 |
+
- **Be specific** with your questions
|
| 399 |
+
- **Navigation Mode** helps you find features in the app
|
| 400 |
+
- Each mode is specialized for different tasks!
|
| 401 |
+
""")
|
| 402 |
+
|
| 403 |
+
# Tab 3: Features Overview
|
| 404 |
+
with gr.Tab("✨ Features", id="features"):
|
| 405 |
+
gr.Markdown("""
|
| 406 |
+
## Platform Features
|
| 407 |
+
|
| 408 |
+
### 🎯 Core Capabilities
|
| 409 |
+
""")
|
| 410 |
+
|
| 411 |
+
with gr.Row():
|
| 412 |
+
with gr.Column():
|
| 413 |
+
gr.Markdown("""
|
| 414 |
+
<div class="feature-card">
|
| 415 |
+
|
| 416 |
+
#### ⚖️ Legal Action Advisor
|
| 417 |
+
Get personalized recommendations for seeking justice and remedy
|
| 418 |
+
|
| 419 |
+
- AI-powered action recommendations
|
| 420 |
+
- Case type analysis
|
| 421 |
+
- Timeline planning
|
| 422 |
+
- Free resource finder
|
| 423 |
+
- Evidence collection guidance
|
| 424 |
+
</div>
|
| 425 |
+
""")
|
| 426 |
+
|
| 427 |
+
with gr.Column():
|
| 428 |
+
gr.Markdown("""
|
| 429 |
+
<div class="feature-card">
|
| 430 |
+
|
| 431 |
+
#### 📄 Document Analysis
|
| 432 |
+
Upload and analyze legal documents with AI insights
|
| 433 |
+
|
| 434 |
+
- OCR text extraction
|
| 435 |
+
- Multi-format support (PDF, DOCX, TXT)
|
| 436 |
+
- AI-powered analysis
|
| 437 |
+
- Legal database cross-reference
|
| 438 |
+
- Document validation
|
| 439 |
+
</div>
|
| 440 |
+
""")
|
| 441 |
+
|
| 442 |
+
with gr.Row():
|
| 443 |
+
with gr.Column():
|
| 444 |
+
gr.Markdown("""
|
| 445 |
+
<div class="feature-card">
|
| 446 |
+
|
| 447 |
+
#### 🔍 Legal Research
|
| 448 |
+
Comprehensive legal research tools and databases
|
| 449 |
+
|
| 450 |
+
- Multiple legal databases
|
| 451 |
+
- Case law research
|
| 452 |
+
- Statutory analysis
|
| 453 |
+
- Historical documents
|
| 454 |
+
- Citation tools
|
| 455 |
+
</div>
|
| 456 |
+
""")
|
| 457 |
+
|
| 458 |
+
with gr.Column():
|
| 459 |
+
gr.Markdown("""
|
| 460 |
+
<div class="feature-card">
|
| 461 |
+
|
| 462 |
+
#### 📧 Communications
|
| 463 |
+
Integrated communication system
|
| 464 |
+
|
| 465 |
+
- Twilio integration
|
| 466 |
+
- SMS messaging
|
| 467 |
+
- Email notifications
|
| 468 |
+
- Phone capabilities
|
| 469 |
+
- Legal alerts & reminders
|
| 470 |
+
</div>
|
| 471 |
+
""")
|
| 472 |
+
|
| 473 |
+
# Tab 4: About
|
| 474 |
+
with gr.Tab("ℹ️ About", id="about"):
|
| 475 |
+
gr.Markdown("""
|
| 476 |
+
## About ProVerBs Legal AI
|
| 477 |
+
|
| 478 |
+
### 🎓 Our Platform
|
| 479 |
+
|
| 480 |
+
ProVerBs Legal AI combines advanced artificial intelligence with comprehensive legal knowledge
|
| 481 |
+
to provide accessible, accurate legal information and tools.
|
| 482 |
+
|
| 483 |
+
### 🤖 Specialized AI Chatbot
|
| 484 |
+
|
| 485 |
+
Our AI chatbot features **7 specialized modes**, each trained for specific legal tasks.
|
| 486 |
+
|
| 487 |
+
### 👥 Who We Serve
|
| 488 |
+
|
| 489 |
+
- **Legal Professionals** - Enhance your practice with AI
|
| 490 |
+
- **Law Students** - Research and study assistance
|
| 491 |
+
- **Businesses** - Understand legal implications
|
| 492 |
+
- **Individuals** - Learn about your legal rights
|
| 493 |
+
|
| 494 |
+
### 🔒 Privacy & Security
|
| 495 |
+
|
| 496 |
+
- End-to-end encryption
|
| 497 |
+
- No storage without consent
|
| 498 |
+
- GDPR and CCPA compliant
|
| 499 |
+
- Secure OAuth authentication
|
| 500 |
+
|
| 501 |
+
### ⚠️ Important Disclaimer
|
| 502 |
+
|
| 503 |
+
This platform provides general legal information only. It does not constitute legal advice.
|
| 504 |
+
Always consult with a qualified attorney for specific legal matters.
|
| 505 |
+
|
| 506 |
+
---
|
| 507 |
+
|
| 508 |
+
**Version 1.0.0** | Built by Solomon7890 | Powered by Hugging Face
|
| 509 |
+
""")
|
| 510 |
+
|
| 511 |
+
# Footer
|
| 512 |
+
gr.Markdown("""
|
| 513 |
+
---
|
| 514 |
+
|
| 515 |
+
<div style="text-align: center; padding: 20px; color: #666;">
|
| 516 |
+
<p><strong>⚖️ ProVerBs Legal AI Platform</strong> | Version 1.0.0</p>
|
| 517 |
+
<p>
|
| 518 |
+
<a href="https://huggingface.co/Solomon7890" target="_blank">Hugging Face</a> |
|
| 519 |
+
<a href="https://github.com/Solomon7890" target="_blank">GitHub</a>
|
| 520 |
+
</p>
|
| 521 |
+
<p style="font-size: 0.9rem; margin-top: 10px;">
|
| 522 |
+
⚠️ <strong>Disclaimer</strong>: This AI provides general legal information only.
|
| 523 |
+
Consult with a licensed attorney for specific legal matters.
|
| 524 |
+
</p>
|
| 525 |
+
<p style="font-size: 0.85rem; color: #999;">
|
| 526 |
+
© 2024 ProVerBs Legal AI. Built with ❤️ for legal professionals worldwide.
|
| 527 |
+
</p>
|
| 528 |
+
</div>
|
| 529 |
+
""")
|
| 530 |
+
|
| 531 |
+
if __name__ == "__main__":
|
| 532 |
+
demo.queue(max_size=20)
|
| 533 |
+
demo.launch(
|
| 534 |
+
server_name="0.0.0.0",
|
| 535 |
+
server_port=7860,
|
| 536 |
+
share=False,
|
| 537 |
+
show_error=True
|
| 538 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|