Spaces:
Running
Running
| {% extends 'base.html' %} | |
| {% block content %} | |
| <style> | |
| /* Ensure full-page setup */ | |
| html, body { | |
| height: 100%; | |
| margin: 0; | |
| padding: 0; | |
| background-color: #1e1e2e; | |
| color: white; | |
| font-family: Arial, sans-serif; | |
| } | |
| .container { | |
| display: flex; | |
| height: 80vh; | |
| margin-top: 40px; | |
| align-items: center; | |
| justify-content: center; | |
| gap: 30px; | |
| } | |
| .container-flash { | |
| display: flex; | |
| height: 10vh; | |
| margin-top: 10px; | |
| align-items: center; | |
| justify-content: center; | |
| gap: 30px; | |
| } | |
| .card { | |
| background: #2c2c3e; | |
| border-radius: 10px; | |
| box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.5); | |
| padding: 20px; | |
| width: 45%; | |
| height: 100%; | |
| } | |
| .card-title { | |
| font-size: 20px; | |
| font-weight: bold; | |
| text-align: center; | |
| } | |
| .form-group input { | |
| border-radius: 6px; | |
| padding: 10px; | |
| } | |
| .btn-primary { | |
| background-color: #007bff; | |
| border-color: #007bff; | |
| width: 100%; | |
| padding: 10px; | |
| border-radius: 6px; | |
| } | |
| .btn-primary:hover { | |
| background-color: #0056b3; | |
| border-color: #0056b3; | |
| } | |
| /* Loader */ | |
| .loader { | |
| display: none; | |
| border: 4px solid rgba(255, 255, 255, 0.3); | |
| border-top: 4px solid #007bff; | |
| border-radius: 50%; | |
| width: 30px; | |
| height: 30px; | |
| animation: spin 1s linear infinite; | |
| margin: auto; | |
| } | |
| @keyframes spin { | |
| 0% { transform: rotate(0deg); } | |
| 100% { transform: rotate(360deg); } | |
| } | |
| /* Answer Section */ | |
| .answer-section{ | |
| overflow-y: auto; | |
| max-height: 70vh; | |
| padding: 10px; | |
| border-radius: 6px; | |
| background: #2c2c3e; | |
| } | |
| .answer-section h6 { | |
| color: #ffffff; | |
| font-weight: bold; | |
| text-align: center; | |
| } | |
| .answer-item { | |
| background: #1a1a2e; | |
| padding: 10px; | |
| border-radius: 6px; | |
| margin-bottom: 10px; | |
| } | |
| .token-count { | |
| font-size: 12px; | |
| color: #b0b0b0; | |
| text-align: right; | |
| margin-top: 10px; | |
| font-style: italic; | |
| } | |
| /* History Section */ | |
| .history-section { | |
| overflow-y: auto; | |
| max-height: 70vh; | |
| padding: 10px; | |
| border-radius: 6px; | |
| background: #2c2c3e; | |
| } | |
| .history-item { | |
| background: #1a1a2e; | |
| padding: 10px; | |
| border-radius: 6px; | |
| margin-bottom: 10px; | |
| } | |
| .alert { | |
| padding: 10px; | |
| margin-bottom: 10px; | |
| border-radius: 5px; | |
| text-align: center; | |
| position: absolute; | |
| position-area: top center; | |
| top: 30px; | |
| align-items: center; | |
| } | |
| .alert-error { | |
| background-color: #D84040; | |
| color: #ffffff; | |
| } | |
| .alert-success { | |
| background-color: #D2DE32; | |
| color: #ffffff; | |
| } | |
| .alert-warning { | |
| background-color: #FFC700; | |
| color: #ffffff; | |
| } | |
| </style> | |
| <div class="container-flash"> | |
| {% with messages = get_flashed_messages(with_categories=true) %} | |
| {% if messages %} | |
| <div id="flash-message" class="alert alert-{{ messages[0][0] }}"> | |
| <strong>{{ messages[0][1] }}</strong> | |
| </div> | |
| {% endif %} | |
| {% endwith %} | |
| </div> | |
| <div class="container"> | |
| <!-- Left Pane --> | |
| <div class="card"> | |
| <h5 class="card-title">Document AI</h5> | |
| <p>Enter a query and get an answer based on stored context.</p> | |
| <form method="POST" action="{{ url_for('chat') }}" onsubmit="showLoader()"> | |
| <div class="form-group"> | |
| <input type="text" name="query_text" placeholder="Enter your query" value="{{ query_text }}" required class="form-control"> | |
| </div> | |
| <div class="form-group mt-2"> | |
| <button type="submit" class="btn btn-primary">Submit</button> | |
| </div> | |
| </form> | |
| <div class="loader" id="loader"></div> | |
| {% if answer %} | |
| <div class="answer-section"> | |
| <div class="answer-item"> | |
| <h6><strong>Answer:</strong></h6> | |
| <hr> | |
| {{ answer }} | |
| </div> | |
| <div class="token-count">Tokens Used: {{ token_count }}</div> | |
| </div> | |
| {% endif %} | |
| </div> | |
| <!-- Right Pane --> | |
| <div class="card"> | |
| <h5 class="card-title">Previous Queries</h5> | |
| <div class="history-section"> | |
| {% for question, answer in history %} | |
| <div class="history-item"> | |
| <div><strong>Query:</strong> {{ question }}</div> | |
| <hr> | |
| <div><strong>Answer:</strong> {{ answer }}</div> | |
| </div> | |
| {% endfor %} | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| const flashMessage = document.getElementById('flash-message'); | |
| if (flashMessage) { | |
| setTimeout(function() { | |
| flashMessage.style.display = 'none'; | |
| }, 2000); // Hide after 2 seconds | |
| } | |
| function showLoader() { | |
| document.getElementById('loader').style.display = 'block'; | |
| document.querySelector('.answer-section')?.classList.add('d-none'); | |
| } | |
| // Ensure the answer section is visible when an answer is displayed | |
| window.onload = function() { | |
| if (document.querySelector('.answer-section')) { | |
| document.querySelector('.answer-section').classList.remove('d-none'); | |
| } | |
| }; | |
| </script> | |
| {% endblock %} |