Stats Lab Multi-Agent Statistical AI
SESSION DATASET none
🧰 Tools Explorer
  • Loading tools registry…
🧪 Try Sample 0
  • Loading...
🧪 Try Sample 0
  • Loading...
Upload Dataset CSV / XLSX
Datasets 0
  • No datasets yet
Question deepseek
A 药 vs B 药(t 检验) 吸烟 vs 肺癌(χ² + OR) BMI vs 血糖(线性回归) 糖尿病风险(Logistic + AUC) 生存时间(KM + Log-rank) 多因素 Cox + 森林图 IPTW + Love Plot Nomogram 风险评分 校准曲线 + Brier ROC + DeLong Meta + 森林图 + Egger 样本量计算
Ready
Final Answer
📊
Upload a dataset and ask a statistical question.
Results will appear here.
Tool Log 0 iter
// waiting for run…
/* === 2026-09-05 Multi-Table Helpers (XSS-safe 2026-09-11) === */ const __esc = (s) => String(s).replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,'''); window.renderTableTabs = function(tables, activeKey) { const c = document.getElementById('table-tabs'); if (!c) return; if (!tables || Object.keys(tables).length === 0) { c.innerHTML = ''; return; } c.innerHTML = Object.entries(tables).map(([k, info]) => { const safeK = __esc(k); const safeRows = __esc(info.n_rows); const safeCols = __esc(info.n_cols); const isActive = (k === activeKey) ? 'active' : ''; // 用 classList + addEventListener 而不是 onclick 字符串拼接,避免单引号注入 const div = document.createElement('div'); div.className = 'tab ' + isActive; div.dataset.key = k; div.innerHTML = `${safeK} (${safeRows}x${safeCols})`; div.addEventListener('click', () => window.switchTable(k)); return div.outerHTML; }).join(''); }; window.switchTable = async function(key) { const tabs = document.querySelectorAll('.table-tabs .tab'); tabs.forEach(t => t.classList.toggle('active', t.dataset.key === key)); try { const r = await fetch(`/ai/api/stats/tables?key=${encodeURIComponent(key)}&session_id=${window.SESSION_ID || 'default'}`); const j = await r.json(); if (j.preview) { const tbody = document.querySelector('#data-preview tbody'); if (tbody) { // 全部用 textContent + DOM API 而非 innerHTML 拼接,杜绝 XSS tbody.textContent = ''; j.preview.forEach(row => { const tr = document.createElement('tr'); row.forEach(cell => { const td = document.createElement('td'); td.textContent = String(cell).slice(0,80); tr.appendChild(td); }); tbody.appendChild(tr); }); } } } catch (e) { console.warn('switchTable preview failed', e); } }; window.renderPythonCode = function(code) { const div = document.createElement('div'); div.className = 'code-block python'; // 用 textContent (自动转义) 而非 innerHTML 拼字符串 const lang = document.createElement('span'); lang.className = 'lang'; lang.textContent = 'python'; const body = document.createElement('div'); body.className = 'body'; body.textContent = code; div.appendChild(lang); div.appendChild(body); return div; }; window.renderFigure = function(b64) { const div = document.createElement('div'); div.className = 'figure-block'; // base64 白名单防御,避免恶意 data URL 注入 if (!/^[A-Za-z0-9+/=\s]+$/.test(b64 || '')) { const err = document.createElement('div'); err.textContent = '[invalid base64 figure]'; div.appendChild(err); return div; } const img = document.createElement('img'); img.alt = 'figure'; img.src = 'data:image/png;base64,' + b64; div.appendChild(img); return div; }; /* === SSE: render python_sandbox tool calls + figures === */ (function(){ const origAppend = window.appendSSEMessage || (m => null); window.appendSSEMessage = function(evt) { origAppend(evt); try { if (typeof evt === 'string') evt = JSON.parse(evt); if (evt.tool === 'python_sandbox' && evt.args && evt.args.code) { const log = document.getElementById('sse-log') || document.body; log.appendChild(window.renderPythonCode(evt.args.code)); } if (evt.result && typeof evt.result === 'object') { if (evt.result.figures && evt.result.figures.length) { evt.result.figures.forEach(b64 => { const log = document.getElementById('sse-log') || document.body; log.appendChild(window.renderFigure(b64)); }); } if (evt.result.stdout) { const d = document.createElement('div'); d.className = 'sse-code'; d.textContent = '> ' + evt.result.stdout; (document.getElementById('sse-log') || document.body).appendChild(d); } } if (evt.figures && evt.figures.length) { evt.figures.forEach(b64 => { (document.getElementById('sse-log') || document.body).appendChild(window.renderFigure(b64)); }); } } catch (e) { /* ignore non-JSON events */ } }; })();