Spaces:
Running
Running
Download static/index.html from phaethon-order/tech-trans-rag: direct link, hf CLI and curl.
- Browser
- Download file 17.1 kB
-
https://huggingface.co/spaces/phaethon-order/tech-trans-rag/resolve/bb68da23f4c463dcd807e29c0422879e1b94de4c/static/index.html
- Command line
-
hf download hf://spaces/phaethon-order/tech-trans-rag@bb68da23f4c463dcd807e29c0422879e1b94de4c/static/index.html
-
curl -L -o index.html https://huggingface.co/spaces/phaethon-order/tech-trans-rag/resolve/bb68da23f4c463dcd807e29c0422879e1b94de4c/static/index.html
17.1 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Technology Transactions Assistant (RAG model query interface)</title> | |
| <style> | |
| * { | |
| margin: 0; | |
| padding: 0; | |
| box-sizing: border-box; | |
| } | |
| body { | |
| font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Rounded', 'SF Pro Display', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif; | |
| background: #001122; | |
| min-height: 100vh; | |
| display: flex; | |
| flex-direction: column; | |
| align-items: center; | |
| justify-content: center; | |
| padding: 20px; | |
| color: #fff; | |
| } | |
| .header-section { | |
| width: 100%; | |
| max-width: 1200px; | |
| background: #333; | |
| border-radius: 20px; | |
| padding: 20px; | |
| margin-bottom: 20px; | |
| box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5); | |
| text-align: center; | |
| } | |
| .header-title { | |
| color: #fff; | |
| font-size: 2.5rem; | |
| font-weight: 500; | |
| text-decoration: underline; | |
| text-shadow: 0 4px 8px rgba(0, 0, 0, 0.5); | |
| margin: 0; | |
| } | |
| .header-subtitle { | |
| color: #ccc; | |
| font-size: 0.85rem; | |
| font-weight: 400; | |
| font-style: italic; | |
| margin: 20px; | |
| } | |
| .header-subtitle a.upload-link { | |
| color: #87CEFA; | |
| text-decoration: none; | |
| } | |
| .header-subtitle a.upload-link:hover { | |
| text-decoration: underline; | |
| } | |
| .banner-image { | |
| display: none; | |
| } | |
| .main-container { | |
| display: flex; | |
| gap: 18px; | |
| width: 100%; | |
| max-width: 1200px; | |
| height: 60vh; | |
| align-items: stretch; | |
| } | |
| .left-container { | |
| flex: 1; | |
| background: #333; | |
| border-radius: 20px; | |
| padding: 32px; | |
| box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5); | |
| display: flex; | |
| flex-direction: column; | |
| justify-content: flex-start; | |
| gap: 10px; | |
| min-height: 0; | |
| } | |
| .right-container { | |
| flex: 1; | |
| background: #333; | |
| border-radius: 20px; | |
| padding: 32px; | |
| box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5); | |
| display: flex; | |
| flex-direction: column; | |
| min-height: 0; | |
| position: relative; | |
| } | |
| .left-container h1 { | |
| display: none; | |
| } | |
| .form-group { | |
| margin-bottom: 20px; | |
| } | |
| label { | |
| display: block; | |
| margin-bottom: 8px; | |
| font-weight: 600; | |
| color: #fff; | |
| font-size: 0.95rem; | |
| letter-spacing: 0.5px; | |
| } | |
| .char-count { | |
| float: right; | |
| font-size: 0.85rem; | |
| color: #ccc; | |
| font-weight: normal; | |
| text-transform: none; | |
| letter-spacing: normal; | |
| } | |
| input[type="text"], | |
| textarea { | |
| width: 100%; | |
| padding: 12px 16px; | |
| border: 2px solid #555; | |
| border-radius: 10px; | |
| font-size: 1rem; | |
| font-family: inherit; | |
| transition: all 0.3s ease; | |
| background: #222; | |
| color: #fff; | |
| } | |
| input[type="text"]:focus, | |
| textarea:focus { | |
| outline: none; | |
| border-color: #cc0000; | |
| box-shadow: 0 0 0 3px rgba(204, 0, 0, 0.1); | |
| } | |
| textarea { | |
| resize: vertical; | |
| min-height: 120px; | |
| } | |
| .button-row { | |
| display: flex; | |
| gap: 12px; | |
| margin-top: 10px; | |
| } | |
| .button-row .submit-btn, | |
| .button-row .cancel-btn { | |
| flex: 1; | |
| padding: 12px 18px; | |
| border-radius: 10px; | |
| font-size: 1rem; | |
| font-weight: 600; | |
| cursor: pointer; | |
| transition: all 0.2s ease; | |
| letter-spacing: 1px; | |
| } | |
| .submit-btn { | |
| background: #cfdff0; | |
| color: #0b2233; | |
| border: 1px solid rgba(255,255,255,0.06); | |
| } | |
| .submit-btn:hover { | |
| background: #b9cee3; | |
| transform: translateY(-2px); | |
| box-shadow: 0 8px 18px rgba(11,34,51,0.12); | |
| } | |
| .submit-btn:active { | |
| transform: translateY(0); | |
| } | |
| .cancel-btn { | |
| background: rgba(255,102,102,0.45); | |
| color: #fff; | |
| border: none; | |
| } | |
| .cancel-btn:hover { | |
| background: rgba(255,102,102,0.60); | |
| color: #fff; | |
| } | |
| .output-section { | |
| background: #222; | |
| border: 2px solid #555; | |
| border-radius: 10px; | |
| padding: 20px; | |
| flex: 1; | |
| display: flex; | |
| flex-direction: column; | |
| align-items: flex-start; | |
| justify-content: flex-start; | |
| white-space: pre-wrap; | |
| word-wrap: break-word; | |
| font-family: 'Consolas', 'Monaco', monospace; | |
| font-size: 0.95rem; | |
| line-height: 1.6; | |
| color: #fff; | |
| overflow-y: auto; | |
| margin-bottom: 0; | |
| } | |
| .output-section.empty { | |
| align-items: center; | |
| justify-content: center; | |
| text-align: center; | |
| } | |
| .output-placeholder { | |
| color: #ccc; | |
| font-style: italic; | |
| display: block; | |
| } | |
| .loading { | |
| display: none; | |
| position: absolute; | |
| top: 0; | |
| left: 0; | |
| right: 0; | |
| bottom: 0; | |
| align-items: center; | |
| justify-content: center; | |
| text-align: center; | |
| color: #ffd700; | |
| background: #222; | |
| border-radius: 10px; | |
| flex-direction: column; | |
| gap: 12px; | |
| } | |
| .loading.active { | |
| display: flex; | |
| } | |
| .spinner { | |
| display: inline-block; | |
| width: 20px; | |
| height: 20px; | |
| border: 3px solid rgba(255, 215, 0, 0.3); | |
| border-radius: 50%; | |
| border-top-color: #ffd700; | |
| animation: spin 1s ease-in-out infinite; | |
| } | |
| @keyframes spin { | |
| to { transform: rotate(360deg); } | |
| } | |
| @media (max-width: 768px) { | |
| .main-container { | |
| flex-direction: column; | |
| height: auto; | |
| } | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="header-section"> | |
| <h1 class="header-title">Technology Transactions Assistant</h1> | |
| <p class="header-subtitle">A RAG model that restricts GPT-5 to technology transactions use cases in the legal domain. To add to the corpus, visit <a href="/upload" class="upload-link">/upload</a>.</p> | |
| </div> | |
| <div class="main-container"> | |
| <div class="left-container"> | |
| <h1>TechTrans Query</h1> | |
| <form id="queryForm"> | |
| <div class="form-group"> | |
| <label for="query"> | |
| Query | |
| <span class="char-count"><span id="queryCount">0</span>/1000</span> | |
| </label> | |
| <textarea | |
| id="query" | |
| name="query" | |
| maxlength="1000" | |
| placeholder="Enter query here (e.g., 'Show an example of a confidentiality clause,' 'Define the term Affiliate,' etc.)" | |
| required | |
| ></textarea> | |
| </div> | |
| <div class="form-group"> | |
| <label for="docType">Document Type (optional) | |
| <span class="char-count"><span id="docTypeCount">0</span>/200</span> | |
| </label> | |
| <input type="text" id="docType" name="docType" maxlength="200" placeholder="e.g., License Agreement, Terms of Use..." /> | |
| </div> | |
| <div class="form-group"> | |
| <label for="jurisdiction">Jurisdiction (optional) | |
| <span class="char-count"><span id="jurisdictionCount">0</span>/200</span> | |
| </label> | |
| <input type="text" id="jurisdiction" name="jurisdiction" maxlength="200" placeholder="e.g., US-CA, US-DE, FRG..." /> | |
| </div> | |
| <div class="form-group"> | |
| <label for="topK">Top K Chunks <span class="char-count" style="float:none;">(max 20)</span></label> | |
| <input type="number" id="topK" name="topK" value="5" min="1" max="20" /> | |
| </div> | |
| <div class="button-row"> | |
| <button type="button" class="cancel-btn" id="cancelBtn">Clear</button> | |
| <button type="submit" class="submit-btn">Search</button> | |
| </div> | |
| </form> | |
| </div> | |
| <div class="right-container"> | |
| <label for="response">Query Results</label> | |
| <div id="response" class="output-section empty"> | |
| <span class="output-placeholder">Response will appear here...</span> | |
| </div> | |
| <div class="loading" id="loading"> | |
| <div class="spinner"></div> | |
| <p>Running vector search...</p> | |
| </div> | |
| </div> | |
| </div> | |
| <div id="dangerZone" style="margin-top:28px; font-size:0.7rem; text-align:center; max-width:1200px; width:100%; opacity:0.65;"> | |
| <details> | |
| <summary style="cursor:pointer;">Danger Zone</summary> | |
| <div style="margin-top:10px;"> | |
| <button id="resetBtn" style="background:#660000; color:#fff; border:1px solid #aa2222; padding:8px 14px; border-radius:6px; cursor:pointer; font-size:0.75rem; letter-spacing:0.5px;">Reset / Wipe Corpus</button> | |
| <p style="margin-top:8px; line-height:1.3;">This sends a POST to <code>/api/reset</code> and irreversibly deletes all files under <code>/data</code> and clears Chroma collections. Use only in development.</p> | |
| </div> | |
| </details> | |
| </div> | |
| <script> | |
| // Character count for inputs | |
| function updateCharCount(inputId, counterId) { | |
| const input = document.getElementById(inputId); | |
| const counter = document.getElementById(counterId); | |
| input.addEventListener('input', () => counter.textContent = input.value.length); | |
| counter.textContent = input.value.length; | |
| } | |
| updateCharCount('query', 'queryCount'); | |
| updateCharCount('docType', 'docTypeCount'); | |
| updateCharCount('jurisdiction', 'jurisdictionCount'); | |
| document.getElementById('cancelBtn').addEventListener('click', () => { | |
| document.getElementById('query').value = ''; | |
| document.getElementById('docType').value = ''; | |
| document.getElementById('jurisdiction').value = ''; | |
| document.getElementById('topK').value = '5'; | |
| document.getElementById('queryCount').textContent = '0'; | |
| document.getElementById('docTypeCount').textContent = '0'; | |
| document.getElementById('jurisdictionCount').textContent = '0'; | |
| const responseDiv = document.getElementById('response'); | |
| responseDiv.innerHTML = '<span class="output-placeholder">Response will appear here...</span>'; | |
| responseDiv.classList.add('empty'); | |
| }); | |
| document.getElementById('queryForm').addEventListener('submit', async (e) => { | |
| e.preventDefault(); | |
| const q = document.getElementById('query').value.trim(); | |
| const topK = parseInt(document.getElementById('topK').value, 10) || 5; | |
| if (!q) return; | |
| const filters = {}; | |
| const dt = document.getElementById('docType').value.trim(); | |
| const jur = document.getElementById('jurisdiction').value.trim(); | |
| if (dt) filters.doc_type = dt; | |
| if (jur) filters.jurisdiction = jur; | |
| const body = { query: q, top_k: topK, filters }; | |
| const responseDiv = document.getElementById('response'); | |
| const loadingDiv = document.getElementById('loading'); | |
| responseDiv.innerHTML = ''; | |
| responseDiv.classList.remove('empty'); | |
| loadingDiv.classList.add('active'); | |
| try { | |
| const resp = await fetch('/api/query', { | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify(body) | |
| }); | |
| const data = await resp.json().catch(() => ({})); | |
| loadingDiv.classList.remove('active'); | |
| const escape = (str) => String(str ?? '') | |
| .replace(/&/g,'&') | |
| .replace(/</g,'<') | |
| .replace(/>/g,'>'); | |
| if (!resp.ok) { | |
| const msg = data.error || resp.statusText || 'Request failed'; | |
| responseDiv.innerHTML = `<span style="color:#e53e3e;">Error: ${escape(msg)}</span>`; | |
| return; | |
| } | |
| if (data.error) { | |
| responseDiv.innerHTML = `<span style="color:#e53e3e;">Error: ${escape(data.error)}</span>`; | |
| return; | |
| } | |
| const parts = []; | |
| parts.push(`<u>Query:</u> ${escape(data.query)}`); | |
| if (data.filters && (data.filters.doc_type || data.filters.jurisdiction)) { | |
| parts.push(`<u>Filters:</u> doc_type=${escape(data.filters.doc_type || '—')} jurisdiction=${escape(data.filters.jurisdiction || '—')}`); | |
| } | |
| const results = Array.isArray(data.results) ? data.results : []; | |
| if (!results.length) { | |
| parts.push('<u>Results:</u> <em>No chunks returned (vector index empty or not configured).</em>'); | |
| } else { | |
| const list = results.map((r, idx) => { | |
| const dist = (typeof r.distance === 'number') ? r.distance.toFixed(4) : escape(r.distance); | |
| const txt = escape((r.text || '').slice(0, 500)); | |
| return `<li style="margin-bottom:14px; line-height:1.35;"> | |
| <div><strong>#${idx+1}</strong> chunk_id=${escape(r.chunk_id)} distance=${dist}</div> | |
| <div style="color:#ccc; font-size:0.7rem; margin-top:2px; font-style:italic;">${escape(r.title || '')} ${r.doc_type ? '('+escape(r.doc_type)+')' : ''} ${r.jurisdiction ? '['+escape(r.jurisdiction)+']' : ''}</div> | |
| <div style="color:#ccc; font-size:0.85rem; margin-top:4px;">${txt}${r.text && r.text.length > 500 ? '…' : ''}</div> | |
| </li>`; | |
| }).join(''); | |
| parts.push(`<details open><summary style="cursor:pointer; margin-top:10px;"><u>Results (${results.length})</u></summary><ol style="margin-top:8px; padding-left:20px;">${list}</ol></details>`); | |
| } | |
| responseDiv.innerHTML = parts.join('\n\n'); | |
| } catch (err) { | |
| loadingDiv.classList.remove('active'); | |
| responseDiv.innerHTML = `<span style="color:#e53e3e;">Error: ${err.message}</span>`; | |
| } | |
| }); | |
| // Reset handler | |
| const resetBtn = document.getElementById('resetBtn'); | |
| if (resetBtn) { | |
| resetBtn.addEventListener('click', async () => { | |
| if (!confirm('This will DELETE all data under /data and clear embeddings. Continue?')) return; | |
| resetBtn.disabled = true; | |
| resetBtn.textContent = 'Resetting...'; | |
| try { | |
| const resp = await fetch('/api/reset', { | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify({ confirm: true }) | |
| }); | |
| const data = await resp.json().catch(() => ({})); | |
| if (!resp.ok) { | |
| alert('Reset failed: ' + (data.error || resp.statusText)); | |
| } else { | |
| alert('Reset complete. Files deleted: ' + (data.files_deleted ?? 'n/a')); | |
| location.reload(); | |
| } | |
| } catch (e) { | |
| alert('Reset error: ' + e.message); | |
| } finally { | |
| resetBtn.disabled = false; | |
| resetBtn.textContent = 'Reset / Wipe Corpus'; | |
| } | |
| }); | |
| } | |
| </script> | |
| </body> | |
| </html> | |