Spaces:
Sleeping
Sleeping
password protection added in frontend.
Browse files- .gitignore +1 -0
- app/static/chat.html +134 -4
- requirements.txt +10 -10
.gitignore
CHANGED
|
@@ -101,3 +101,4 @@ build/
|
|
| 101 |
*ws_transcriber.py
|
| 102 |
*speak.py
|
| 103 |
*transcribe.py
|
|
|
|
|
|
| 101 |
*ws_transcriber.py
|
| 102 |
*speak.py
|
| 103 |
*transcribe.py
|
| 104 |
+
*Testing.ipynb
|
app/static/chat.html
CHANGED
|
@@ -387,6 +387,7 @@
|
|
| 387 |
}
|
| 388 |
|
| 389 |
.form-group input[type="text"],
|
|
|
|
| 390 |
.form-group input[type="number"] {
|
| 391 |
width: 100%;
|
| 392 |
padding: 0.5rem;
|
|
@@ -512,6 +513,68 @@
|
|
| 512 |
margin-bottom: 0.25rem;
|
| 513 |
}
|
| 514 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 515 |
@media (max-width: 768px) {
|
| 516 |
.sidebar {
|
| 517 |
position: absolute;
|
|
@@ -552,7 +615,6 @@
|
|
| 552 |
<span>Connecting...</span>
|
| 553 |
</div>
|
| 554 |
|
| 555 |
-
|
| 556 |
<button id="clear" class="btn"
|
| 557 |
style="background: var(--error-color); color: white; border-radius: 4px; width: auto; padding: 0.5rem 1rem; margin-top: auto;">
|
| 558 |
<i class="fas fa-trash"></i> Clear Chat
|
|
@@ -581,6 +643,24 @@
|
|
| 581 |
</div>
|
| 582 |
</div>
|
| 583 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 584 |
<div class="settings-panel" id="settings-panel">
|
| 585 |
<div class="settings-header">
|
| 586 |
<h2>Settings</h2>
|
|
@@ -604,13 +684,15 @@
|
|
| 604 |
<script>
|
| 605 |
// Configuration
|
| 606 |
const config = {
|
| 607 |
-
// apiUrl: localStorage.getItem('apiUrl') || "http://127.0.0.1:8000",
|
| 608 |
apiUrl: localStorage.getItem('apiUrl') || "https://inveros-tech-iso-rag.hf.space",
|
| 609 |
maxChatHistory: 10,
|
| 610 |
typingIndicatorDelay: 300,
|
| 611 |
reconnectDelay: 5000
|
| 612 |
};
|
| 613 |
|
|
|
|
|
|
|
|
|
|
| 614 |
// Global variables
|
| 615 |
let chatState = [];
|
| 616 |
let memoryState = [];
|
|
@@ -619,6 +701,7 @@
|
|
| 619 |
let eventSource = null;
|
| 620 |
let reconnectAttempts = 0;
|
| 621 |
let maxReconnectAttempts = 3;
|
|
|
|
| 622 |
|
| 623 |
// DOM elements
|
| 624 |
const chatBox = document.getElementById("chat-box");
|
|
@@ -634,6 +717,10 @@
|
|
| 634 |
const toast = document.getElementById("toast");
|
| 635 |
const connectionStatus = document.getElementById("connection-status");
|
| 636 |
const quickActions = document.querySelectorAll('.quick-action');
|
|
|
|
|
|
|
|
|
|
|
|
|
| 637 |
|
| 638 |
// Initialize UI
|
| 639 |
function initializeUI() {
|
|
@@ -864,6 +951,34 @@
|
|
| 864 |
});
|
| 865 |
}
|
| 866 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 867 |
// Initialize event listeners
|
| 868 |
function initializeEventListeners() {
|
| 869 |
// Send button and input
|
|
@@ -895,15 +1010,30 @@
|
|
| 895 |
localStorage.setItem('darkMode', isDark);
|
| 896 |
});
|
| 897 |
|
| 898 |
-
// Settings panel
|
| 899 |
settingsToggle.addEventListener('click', () => {
|
| 900 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 901 |
});
|
| 902 |
|
| 903 |
closeSettingsBtn.addEventListener('click', () => {
|
| 904 |
settingsPanel.classList.remove('open');
|
| 905 |
});
|
| 906 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 907 |
// Save settings
|
| 908 |
saveSettingsBtn.addEventListener('click', () => {
|
| 909 |
config.apiUrl = apiUrlInput.value.trim();
|
|
|
|
| 387 |
}
|
| 388 |
|
| 389 |
.form-group input[type="text"],
|
| 390 |
+
.form-group input[type="password"],
|
| 391 |
.form-group input[type="number"] {
|
| 392 |
width: 100%;
|
| 393 |
padding: 0.5rem;
|
|
|
|
| 513 |
margin-bottom: 0.25rem;
|
| 514 |
}
|
| 515 |
|
| 516 |
+
.password-prompt {
|
| 517 |
+
position: fixed;
|
| 518 |
+
top: 0;
|
| 519 |
+
left: 0;
|
| 520 |
+
right: 0;
|
| 521 |
+
bottom: 0;
|
| 522 |
+
background: rgba(0, 0, 0, 0.5);
|
| 523 |
+
display: flex;
|
| 524 |
+
align-items: center;
|
| 525 |
+
justify-content: center;
|
| 526 |
+
z-index: 1000;
|
| 527 |
+
display: none;
|
| 528 |
+
}
|
| 529 |
+
|
| 530 |
+
.password-prompt.open {
|
| 531 |
+
display: flex;
|
| 532 |
+
}
|
| 533 |
+
|
| 534 |
+
.password-container {
|
| 535 |
+
background: var(--bg-color);
|
| 536 |
+
padding: 2rem;
|
| 537 |
+
border-radius: 8px;
|
| 538 |
+
box-shadow: var(--shadow);
|
| 539 |
+
width: 90%;
|
| 540 |
+
max-width: 400px;
|
| 541 |
+
}
|
| 542 |
+
|
| 543 |
+
.password-header {
|
| 544 |
+
margin-bottom: 1.5rem;
|
| 545 |
+
text-align: center;
|
| 546 |
+
}
|
| 547 |
+
|
| 548 |
+
.password-header h2 {
|
| 549 |
+
margin-bottom: 0.5rem;
|
| 550 |
+
color: var(--primary-color);
|
| 551 |
+
}
|
| 552 |
+
|
| 553 |
+
.password-actions {
|
| 554 |
+
display: flex;
|
| 555 |
+
gap: 0.5rem;
|
| 556 |
+
justify-content: flex-end;
|
| 557 |
+
margin-top: 1.5rem;
|
| 558 |
+
}
|
| 559 |
+
|
| 560 |
+
.password-btn {
|
| 561 |
+
padding: 0.5rem 1rem;
|
| 562 |
+
border: none;
|
| 563 |
+
border-radius: 4px;
|
| 564 |
+
cursor: pointer;
|
| 565 |
+
font-size: 0.9rem;
|
| 566 |
+
}
|
| 567 |
+
|
| 568 |
+
.password-btn.primary {
|
| 569 |
+
background: var(--primary-color);
|
| 570 |
+
color: white;
|
| 571 |
+
}
|
| 572 |
+
|
| 573 |
+
.password-btn.secondary {
|
| 574 |
+
background: var(--border-color);
|
| 575 |
+
color: var(--text-color);
|
| 576 |
+
}
|
| 577 |
+
|
| 578 |
@media (max-width: 768px) {
|
| 579 |
.sidebar {
|
| 580 |
position: absolute;
|
|
|
|
| 615 |
<span>Connecting...</span>
|
| 616 |
</div>
|
| 617 |
|
|
|
|
| 618 |
<button id="clear" class="btn"
|
| 619 |
style="background: var(--error-color); color: white; border-radius: 4px; width: auto; padding: 0.5rem 1rem; margin-top: auto;">
|
| 620 |
<i class="fas fa-trash"></i> Clear Chat
|
|
|
|
| 643 |
</div>
|
| 644 |
</div>
|
| 645 |
|
| 646 |
+
<!-- Password Prompt -->
|
| 647 |
+
<div class="password-prompt" id="password-prompt">
|
| 648 |
+
<div class="password-container">
|
| 649 |
+
<div class="password-header">
|
| 650 |
+
<h2>Admin Access Required</h2>
|
| 651 |
+
<p>Please enter the password to access settings</p>
|
| 652 |
+
</div>
|
| 653 |
+
<div class="form-group">
|
| 654 |
+
<label for="admin-password">Password</label>
|
| 655 |
+
<input type="password" id="admin-password" placeholder="Enter password">
|
| 656 |
+
</div>
|
| 657 |
+
<div class="password-actions">
|
| 658 |
+
<button id="cancel-password" class="password-btn secondary">Cancel</button>
|
| 659 |
+
<button id="submit-password" class="password-btn primary">Submit</button>
|
| 660 |
+
</div>
|
| 661 |
+
</div>
|
| 662 |
+
</div>
|
| 663 |
+
|
| 664 |
<div class="settings-panel" id="settings-panel">
|
| 665 |
<div class="settings-header">
|
| 666 |
<h2>Settings</h2>
|
|
|
|
| 684 |
<script>
|
| 685 |
// Configuration
|
| 686 |
const config = {
|
|
|
|
| 687 |
apiUrl: localStorage.getItem('apiUrl') || "https://inveros-tech-iso-rag.hf.space",
|
| 688 |
maxChatHistory: 10,
|
| 689 |
typingIndicatorDelay: 300,
|
| 690 |
reconnectDelay: 5000
|
| 691 |
};
|
| 692 |
|
| 693 |
+
// Password configuration
|
| 694 |
+
const ADMIN_PASSWORD = "SECret123"; // Change this to your desired password
|
| 695 |
+
|
| 696 |
// Global variables
|
| 697 |
let chatState = [];
|
| 698 |
let memoryState = [];
|
|
|
|
| 701 |
let eventSource = null;
|
| 702 |
let reconnectAttempts = 0;
|
| 703 |
let maxReconnectAttempts = 3;
|
| 704 |
+
let isAuthenticated = false;
|
| 705 |
|
| 706 |
// DOM elements
|
| 707 |
const chatBox = document.getElementById("chat-box");
|
|
|
|
| 717 |
const toast = document.getElementById("toast");
|
| 718 |
const connectionStatus = document.getElementById("connection-status");
|
| 719 |
const quickActions = document.querySelectorAll('.quick-action');
|
| 720 |
+
const passwordPrompt = document.getElementById("password-prompt");
|
| 721 |
+
const adminPasswordInput = document.getElementById("admin-password");
|
| 722 |
+
const submitPasswordBtn = document.getElementById("submit-password");
|
| 723 |
+
const cancelPasswordBtn = document.getElementById("cancel-password");
|
| 724 |
|
| 725 |
// Initialize UI
|
| 726 |
function initializeUI() {
|
|
|
|
| 951 |
});
|
| 952 |
}
|
| 953 |
|
| 954 |
+
// Show password prompt
|
| 955 |
+
function showPasswordPrompt() {
|
| 956 |
+
passwordPrompt.classList.add('open');
|
| 957 |
+
adminPasswordInput.value = '';
|
| 958 |
+
adminPasswordInput.focus();
|
| 959 |
+
}
|
| 960 |
+
|
| 961 |
+
// Hide password prompt
|
| 962 |
+
function hidePasswordPrompt() {
|
| 963 |
+
passwordPrompt.classList.remove('open');
|
| 964 |
+
adminPasswordInput.value = '';
|
| 965 |
+
}
|
| 966 |
+
|
| 967 |
+
// Verify password
|
| 968 |
+
function verifyPassword() {
|
| 969 |
+
const password = adminPasswordInput.value.trim();
|
| 970 |
+
if (password === ADMIN_PASSWORD) {
|
| 971 |
+
isAuthenticated = true;
|
| 972 |
+
hidePasswordPrompt();
|
| 973 |
+
settingsPanel.classList.add('open');
|
| 974 |
+
showToast('Access granted', 'success');
|
| 975 |
+
} else {
|
| 976 |
+
showError('Incorrect password');
|
| 977 |
+
adminPasswordInput.value = '';
|
| 978 |
+
adminPasswordInput.focus();
|
| 979 |
+
}
|
| 980 |
+
}
|
| 981 |
+
|
| 982 |
// Initialize event listeners
|
| 983 |
function initializeEventListeners() {
|
| 984 |
// Send button and input
|
|
|
|
| 1010 |
localStorage.setItem('darkMode', isDark);
|
| 1011 |
});
|
| 1012 |
|
| 1013 |
+
// Settings panel with password protection
|
| 1014 |
settingsToggle.addEventListener('click', () => {
|
| 1015 |
+
if (isAuthenticated) {
|
| 1016 |
+
settingsPanel.classList.toggle('open');
|
| 1017 |
+
} else {
|
| 1018 |
+
showPasswordPrompt();
|
| 1019 |
+
}
|
| 1020 |
});
|
| 1021 |
|
| 1022 |
closeSettingsBtn.addEventListener('click', () => {
|
| 1023 |
settingsPanel.classList.remove('open');
|
| 1024 |
});
|
| 1025 |
|
| 1026 |
+
// Password prompt events
|
| 1027 |
+
submitPasswordBtn.addEventListener('click', verifyPassword);
|
| 1028 |
+
cancelPasswordBtn.addEventListener('click', hidePasswordPrompt);
|
| 1029 |
+
|
| 1030 |
+
// Allow pressing Enter in password field
|
| 1031 |
+
adminPasswordInput.addEventListener('keypress', (e) => {
|
| 1032 |
+
if (e.key === 'Enter') {
|
| 1033 |
+
verifyPassword();
|
| 1034 |
+
}
|
| 1035 |
+
});
|
| 1036 |
+
|
| 1037 |
// Save settings
|
| 1038 |
saveSettingsBtn.addEventListener('click', () => {
|
| 1039 |
config.apiUrl = apiUrlInput.value.trim();
|
requirements.txt
CHANGED
|
@@ -1,40 +1,40 @@
|
|
| 1 |
# ====================
|
| 2 |
# Core Data Libraries
|
| 3 |
# ====================
|
| 4 |
-
pandas
|
| 5 |
-
numpy
|
| 6 |
|
| 7 |
# ============================
|
| 8 |
# File and Directory Handling
|
| 9 |
# ============================
|
| 10 |
-
glob2
|
| 11 |
openpyxl # Excel processing
|
| 12 |
pypdf # PDF processing
|
| 13 |
|
| 14 |
# ======================
|
| 15 |
# Environment Variables
|
| 16 |
# ======================
|
| 17 |
-
python-dotenv
|
| 18 |
dotenv # Redundant but sometimes required for legacy support
|
| 19 |
|
| 20 |
# ================================
|
| 21 |
# Machine Learning & NLP Tooling
|
| 22 |
# ================================
|
| 23 |
-
transformers
|
| 24 |
# torch>=2.2.0 # Optional but usually required with transformers
|
| 25 |
|
| 26 |
# ====================
|
| 27 |
# LangChain Ecosystem
|
| 28 |
# ====================
|
| 29 |
-
langchain
|
| 30 |
-
langchain-core
|
| 31 |
-
langchain-community
|
| 32 |
-
langchain-text-splitters
|
| 33 |
|
| 34 |
# ==================
|
| 35 |
# OpenAI Integration
|
| 36 |
# ==================
|
| 37 |
-
openai
|
| 38 |
|
| 39 |
# ================
|
| 40 |
# Vector Databases
|
|
|
|
| 1 |
# ====================
|
| 2 |
# Core Data Libraries
|
| 3 |
# ====================
|
| 4 |
+
pandas
|
| 5 |
+
numpy # Required for math and signal processing
|
| 6 |
|
| 7 |
# ============================
|
| 8 |
# File and Directory Handling
|
| 9 |
# ============================
|
| 10 |
+
glob2
|
| 11 |
openpyxl # Excel processing
|
| 12 |
pypdf # PDF processing
|
| 13 |
|
| 14 |
# ======================
|
| 15 |
# Environment Variables
|
| 16 |
# ======================
|
| 17 |
+
python-dotenv
|
| 18 |
dotenv # Redundant but sometimes required for legacy support
|
| 19 |
|
| 20 |
# ================================
|
| 21 |
# Machine Learning & NLP Tooling
|
| 22 |
# ================================
|
| 23 |
+
transformers
|
| 24 |
# torch>=2.2.0 # Optional but usually required with transformers
|
| 25 |
|
| 26 |
# ====================
|
| 27 |
# LangChain Ecosystem
|
| 28 |
# ====================
|
| 29 |
+
langchain
|
| 30 |
+
langchain-core
|
| 31 |
+
langchain-community
|
| 32 |
+
langchain-text-splitters
|
| 33 |
|
| 34 |
# ==================
|
| 35 |
# OpenAI Integration
|
| 36 |
# ==================
|
| 37 |
+
openai
|
| 38 |
|
| 39 |
# ================
|
| 40 |
# Vector Databases
|