@nestim/koishi-plugin-qqgm-webui 0.2.6 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -1
- package/lib/data.js +8 -0
- package/package.json +1 -1
- package/public/app.js +18 -0
- package/public/index.html +13 -16
package/index.js
CHANGED
package/lib/data.js
CHANGED
|
@@ -86,6 +86,8 @@ function monitor(ctx) {
|
|
|
86
86
|
SELECT COUNT(*) calls,
|
|
87
87
|
COALESCE(SUM(CASE WHEN status='ok' THEN 1 ELSE 0 END),0) ok,
|
|
88
88
|
COALESCE(SUM(CASE WHEN status!='ok' THEN 1 ELSE 0 END),0) fail,
|
|
89
|
+
COALESCE(SUM(CASE WHEN error_kind='timeout' THEN 1 ELSE 0 END),0) timeout,
|
|
90
|
+
COALESCE(SUM(CASE WHEN error_kind='empty' THEN 1 ELSE 0 END),0) parse_fail,
|
|
89
91
|
COALESCE(SUM(prompt_tokens),0) prompt,
|
|
90
92
|
COALESCE(SUM(completion_tokens),0) completion,
|
|
91
93
|
COALESCE(SUM(cache_tokens),0) cache,
|
|
@@ -119,10 +121,16 @@ function monitor(ctx) {
|
|
|
119
121
|
const renders = messages.map((m) => Number(m.rendered_ms) || 0);
|
|
120
122
|
const sends = messages.map((m) => Number(m.send_ms) || 0);
|
|
121
123
|
const latestBalance = db.prepare('SELECT currency,total,at FROM balance_snapshots ORDER BY at DESC LIMIT 1').get();
|
|
124
|
+
const recent = db.prepare(`
|
|
125
|
+
SELECT trace_id, kind, group_id, model, prompt_tokens, completion_tokens,
|
|
126
|
+
model_ms, status, error_kind, started_at
|
|
127
|
+
FROM calls ORDER BY started_at DESC LIMIT 8
|
|
128
|
+
`).all();
|
|
122
129
|
return {
|
|
123
130
|
installed: true,
|
|
124
131
|
calls,
|
|
125
132
|
groups,
|
|
133
|
+
recent,
|
|
126
134
|
replyMessages: messages.length,
|
|
127
135
|
latency: { e2e: p3(e2e), model: p3(models), queue: p3(queues), render: p3(renders), send: p3(sends) },
|
|
128
136
|
balance: latestBalance ? { currency: latestBalance.currency, total: latestBalance.total, at: latestBalance.at } : null,
|
package/package.json
CHANGED
package/public/app.js
CHANGED
|
@@ -88,6 +88,24 @@ async function initRealData() {
|
|
|
88
88
|
cards[2].innerHTML = `${(data.monitor.latency.e2e.p95 / 1000).toFixed(1)}<small>s</small>`;
|
|
89
89
|
}
|
|
90
90
|
if (cards[3] && data.monitor.balance) cards[3].textContent = `¥${Number(data.monitor.balance.total || 0).toFixed(2)}`;
|
|
91
|
+
const foots = $$('#overview-monitor .metric-foot');
|
|
92
|
+
if (foots[0]) foots[0].textContent = `成功 ${calls.ok || 0} · 失败 ${calls.fail || 0}`;
|
|
93
|
+
if (foots[1] && calls.calls) {
|
|
94
|
+
foots[1].textContent = `失败率 ${((calls.fail || 0) / calls.calls * 100).toFixed(1)}% · 解析 ${calls.parse_fail || 0} · 超时 ${calls.timeout || 0}`;
|
|
95
|
+
}
|
|
96
|
+
const body = $('#recentCallsBody');
|
|
97
|
+
if (body && Array.isArray(data.monitor.recent)) {
|
|
98
|
+
const esc = (value) => String(value == null ? '' : value).replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
|
99
|
+
body.innerHTML = data.monitor.recent.map((call) => {
|
|
100
|
+
const source = call.kind === 'private' ? '私聊' : call.kind === 'memory' ? '记忆' : call.kind === 'idle' ? '主动话题' : `群 ${call.group_id || '-'}`;
|
|
101
|
+
const token = `${((Number(call.prompt_tokens) || 0) + (Number(call.completion_tokens) || 0)) / 1000}`;
|
|
102
|
+
const time = new Date(call.started_at).toLocaleTimeString('zh-CN', { hour12: false });
|
|
103
|
+
const status = call.status === 'ok'
|
|
104
|
+
? '<span class="status ok">成功</span>'
|
|
105
|
+
: `<span class="status fail">${esc(call.error_kind || '失败')}</span>`;
|
|
106
|
+
return `<tr><td>${time}</td><td><span class="tag ${call.kind === 'private' ? 'private' : call.kind === 'memory' ? 'memory' : 'group'}">${esc(source)}</span></td><td>${esc(call.model || '-')}</td><td>${token}k</td><td>${((Number(call.model_ms) || 0) / 1000).toFixed(1)}s</td><td>${status}</td></tr>`;
|
|
107
|
+
}).join('');
|
|
108
|
+
}
|
|
91
109
|
} catch { /* 文件预览或未登录时保留 mock */ }
|
|
92
110
|
}
|
|
93
111
|
initRealData();
|
package/public/index.html
CHANGED
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
<div id="overview-monitor">
|
|
81
81
|
<div class="page-head">
|
|
82
82
|
<div>
|
|
83
|
-
<h1>总览 <span class="proto-tag"
|
|
83
|
+
<h1>总览 <span class="proto-tag">只读</span></h1>
|
|
84
84
|
<p>今天 12-02 · 数据来自 qqgm-monitor SQLite</p>
|
|
85
85
|
</div>
|
|
86
86
|
<div class="head-actions">
|
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
</div>
|
|
162
162
|
<table class="table">
|
|
163
163
|
<thead><tr><th>时间</th><th>来源</th><th>模型</th><th>Token</th><th>耗时</th><th>状态</th></tr></thead>
|
|
164
|
-
<tbody>
|
|
164
|
+
<tbody id="recentCallsBody">
|
|
165
165
|
<tr><td>19:02:41</td><td><span class="tag group">群 1103369527</span></td><td>deepseek-chat</td><td>2.4k</td><td>3.0s</td><td><span class="status ok">成功</span></td></tr>
|
|
166
166
|
<tr><td>19:01:58</td><td><span class="tag group">群 1103369527</span></td><td>deepseek-chat</td><td>3.1k</td><td>8.8s</td><td><span class="status ok">成功</span></td></tr>
|
|
167
167
|
<tr><td>18:58:12</td><td><span class="tag private">私聊</span></td><td>deepseek-chat</td><td>1.2k</td><td>9.9s</td><td><span class="status fail">解析失败</span></td></tr>
|
|
@@ -468,8 +468,7 @@
|
|
|
468
468
|
<button class="config-plugin" data-config="chat"><span class="plugin-ico orange">S</span><div><b>qqgm-chat-style</b><small>聊天风格 · 已安装</small></div></button>
|
|
469
469
|
<button class="config-plugin" data-config="private"><span class="plugin-ico purple">P</span><div><b>qqgm-private</b><small>私聊 · 已安装</small></div></button>
|
|
470
470
|
<button class="config-plugin" data-config="webui"><span class="plugin-ico slate">W</span><div><b>qqgm-webui</b><small>本插件 · 已安装</small></div></button>
|
|
471
|
-
<
|
|
472
|
-
<button class="config-plugin" data-config="memory"><span class="plugin-ico muted">R</span><div><b>qqgm-memory</b><small>记忆管理 · 未安装</small></div><span class="mini-badge">未安装</span></button>
|
|
471
|
+
<button class="config-plugin" data-config="memory"><span class="plugin-ico muted">R</span><div><b>qqgm-memory</b><small>记忆管理 · 已安装</small></div></button>
|
|
473
472
|
</aside>
|
|
474
473
|
|
|
475
474
|
<div class="card config-form">
|
|
@@ -531,18 +530,16 @@
|
|
|
531
530
|
</div>
|
|
532
531
|
|
|
533
532
|
<div class="side-panel" data-panel="memory">
|
|
534
|
-
<div class="
|
|
535
|
-
|
|
536
|
-
<
|
|
537
|
-
<
|
|
538
|
-
<
|
|
539
|
-
<button class="btn primary" data-toast="一键安装(原型):正式版会调用安装接口">一键安装</button>
|
|
540
|
-
<a class="btn ghost" href="https://github.com/Miseat/koishi-plugin-qqgm-memory" target="_blank" rel="noreferrer">GitHub</a>
|
|
541
|
-
<a class="btn ghost" href="https://www.npmjs.com/package/@nestim/koishi-plugin-qqgm-memory" target="_blank" rel="noreferrer">npm</a>
|
|
542
|
-
</div>
|
|
543
|
-
<code class="install-code">npm i @nestim/koishi-plugin-qqgm-memory</code>
|
|
544
|
-
<p class="hint">主插件不用改;记忆库默认仍是 MD,装完后可自行切换。</p>
|
|
533
|
+
<div class="form-head"><div><h2>qqgm-memory</h2><p>@nestim/koishi-plugin-qqgm-memory · v1.0.0</p></div><span class="status ok">运行中</span></div>
|
|
534
|
+
<div class="form-section"><h3>数据库</h3>
|
|
535
|
+
<label class="field"><span>SQLite 文件</span><input value="data/qqgm-memory.sqlite" /></label>
|
|
536
|
+
<label class="field"><span>主插件记忆后端</span><input value="md(默认)" disabled /></label>
|
|
537
|
+
<p class="hint">主插件当前是 MD。把主插件 <code>memoryBackend</code> 改为 <code>sqlite</code> 后,本插件才接管数据;迁移前先备份 MD。</p>
|
|
545
538
|
</div>
|
|
539
|
+
<div class="form-section"><h3>迁移</h3>
|
|
540
|
+
<p class="hint">切到 SQLite 后执行 <code>memdb migrate</code> 导入 Memory_*.md;改回 md 可回滚。当前库 0 条。</p>
|
|
541
|
+
</div>
|
|
542
|
+
<div class="form-foot"><span>和主插件共用同一个 DB 文件</span><div><button class="btn ghost" data-toast="已还原(原型)">还原</button><button class="btn primary" data-toast="记忆配置已保存(原型)">保存</button></div></div>
|
|
546
543
|
</div>
|
|
547
544
|
</div>
|
|
548
545
|
</div>
|
|
@@ -568,7 +565,7 @@
|
|
|
568
565
|
<span><i class="pulse"></i> 127.0.0.1:5140/qqgm</span>
|
|
569
566
|
<span>SQLite · WAL</span>
|
|
570
567
|
<span>21 calls today</span>
|
|
571
|
-
<span class="right"
|
|
568
|
+
<span class="right">只读数据 · SQLite</span>
|
|
572
569
|
</footer>
|
|
573
570
|
</main>
|
|
574
571
|
</div>
|