skillmkt 0.3.3 → 0.3.5
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/client/commands/init.js +1 -1
- package/client/commands/serve.js +3 -2
- package/client/lib/llm.js +2 -1
- package/client/public/app.js +16 -7
- package/client/public/index.html +1 -0
- package/package.json +1 -1
package/client/commands/init.js
CHANGED
|
@@ -85,7 +85,7 @@ export async function run(ctx) {
|
|
|
85
85
|
// 冒烟:真实 chat 调用
|
|
86
86
|
try {
|
|
87
87
|
const probe = { base_url, model, api_key: keyEnv.v ? process.env[keyEnv.v.slice(4)] ?? '' : '', timeout_ms: 15000 };
|
|
88
|
-
const reply = await chat(probe, { user: 'Reply with exactly: OK', maxTokens:
|
|
88
|
+
const reply = await chat(probe, { user: 'Reply with exactly: OK', maxTokens: 64 });
|
|
89
89
|
ok(`llm smoke: ${reply.trim().slice(0, 40) || '(empty reply)'}`);
|
|
90
90
|
} catch (e) {
|
|
91
91
|
warn(`llm smoke failed: ${e.message}(配置已写入,功能将降级)`);
|
package/client/commands/serve.js
CHANGED
|
@@ -103,8 +103,9 @@ export async function startServer(ctx, { quiet = false, port = 0 } = {}) {
|
|
|
103
103
|
}
|
|
104
104
|
if (u.pathname === '/api/llm-smoke') { // init 冒烟
|
|
105
105
|
const key = resolveKeyRef(b.api_key, ctx); // env: 引用走 hub/.env 等解析链
|
|
106
|
-
const
|
|
107
|
-
|
|
106
|
+
const sent = 'Reply with exactly: OK';
|
|
107
|
+
const r = await chat({ base_url: b.base_url, model: b.model, api_key: key, timeout_ms: 15000 }, { user: sent, maxTokens: 64 });
|
|
108
|
+
return res.end(JSON.stringify({ ok: true, sent, reply: r.trim().slice(0, 200) }));
|
|
108
109
|
}
|
|
109
110
|
if (u.pathname === '/api/models') { // 指定端点+密钥拉模型列表
|
|
110
111
|
const key = resolveKeyRef(b.api_key, ctx);
|
package/client/lib/llm.js
CHANGED
|
@@ -106,7 +106,8 @@ export async function chat(llm, { system = '', user, maxTokens = 64, temperature
|
|
|
106
106
|
});
|
|
107
107
|
if (!res.ok) throw new Error(`llm ${res.status}: ${(await res.text()).slice(0, 200)}`);
|
|
108
108
|
const data = await res.json();
|
|
109
|
-
|
|
109
|
+
const msg = data.choices?.[0]?.message;
|
|
110
|
+
return msg?.content ?? msg?.reasoning_content ?? ''; // 思考型模型可能只回 reasoning_content
|
|
110
111
|
} finally { clearTimeout(t); }
|
|
111
112
|
}
|
|
112
113
|
|
package/client/public/app.js
CHANGED
|
@@ -148,12 +148,13 @@ async function render() {
|
|
|
148
148
|
<div class="row"><button id="probe">扫描本机模型服务</button><span id="probe-out" class="mut"></span></div>
|
|
149
149
|
<div id="eps"></div>
|
|
150
150
|
<div class="frow"><span class="lab">服务地址</span><input type="text" id="murl" placeholder="http://localhost:1234/v1" value="${esc(cfg.llm?.base_url || '')}"></div>
|
|
151
|
-
<div class="frow" id="key-row" style="display:none"><span class="lab">访问密钥</span><input type="text" id="mkey" value="${esc(cfg.llm?.api_key || '')}"><span class="fhint" id="key-hint"></span
|
|
152
|
-
|
|
151
|
+
<div class="frow" id="key-row" style="display:none"><span class="lab">访问密钥</span><input type="text" id="mkey" value="${esc(cfg.llm?.api_key || '')}"><span class="fhint" id="key-hint"></span>
|
|
152
|
+
<div class="fsub">填了密钥会用本机机器码加密后存入 config.yml——文件拷到别的机器解不开,换机需重填。</div></div>
|
|
153
153
|
<div class="frow" id="model-box"><span class="lab">模型名称</span>
|
|
154
154
|
<div class="combo"><input type="text" id="mmodel" autocomplete="off" placeholder="可输入关键字搜索,扫描后自动列出发现的模型" value="${esc(cfg.llm?.model || '')}">
|
|
155
155
|
<div class="combo-list" id="model-drop" style="display:none"></div></div>
|
|
156
|
-
<button id="smoke">测试连接</button
|
|
156
|
+
<button id="smoke">测试连接</button>
|
|
157
|
+
<div id="smoke-out" class="fsub"></div></div></div>
|
|
157
158
|
<div class="card"><h3>第 2 步 · skill 默认安装位置</h3>
|
|
158
159
|
<p class="mut">勾选的 AI 工具会在你安装新 skill 时自动收到一份副本。已勾过的话保存即生效。</p>
|
|
159
160
|
${h.map((x) => `<label class="check"><input type="checkbox" data-h="${esc(x.id)}" ${sel.has(x.id) ? 'checked' : ''} ${x.state === 'absent' ? 'disabled' : ''}> ${esc(x.id)} ${pill(x.state)} <span class="mut">${esc(x.primaryDir || '')}</span></label>`).join('')}</div>
|
|
@@ -215,14 +216,19 @@ async function render() {
|
|
|
215
216
|
// 填完服务地址自动检测是否需要密钥:已知端点直接看 needs_key,手输地址真发 /models 探
|
|
216
217
|
const markKeyNeed = (need) => {
|
|
217
218
|
const has = !!app.querySelector('#mkey').value.trim();
|
|
219
|
+
const hasUrl = !!app.querySelector('#murl').value.trim();
|
|
218
220
|
const want = !!need && !has;
|
|
219
221
|
app.querySelector('#key-row').style.display = (need || has) ? '' : 'none'; // 无需密钥→整行不显示
|
|
220
222
|
app.querySelector('#mkey').classList.toggle('req', want);
|
|
221
223
|
app.querySelector('#key-hint').textContent = want ? '← 需要密钥' : '';
|
|
222
|
-
app.querySelector('#model-box').style.display = want ? '
|
|
224
|
+
app.querySelector('#model-box').style.display = (hasUrl && !want) ? '' : 'none'; // 先选/填服务地址才出现
|
|
223
225
|
};
|
|
224
226
|
markKeyNeed(false); // 初始:无密钥需求→藏密钥行
|
|
225
|
-
app.querySelector('#murl').addEventListener('input', () => {
|
|
227
|
+
app.querySelector('#murl').addEventListener('input', () => {
|
|
228
|
+
const cur = app.querySelector('#murl').value.trim().replace(/\/+$/, '');
|
|
229
|
+
markKeyNeed(epsList.find((e) => e.base_url === cur)?.needs_key);
|
|
230
|
+
refreshOpts(); renderDrop();
|
|
231
|
+
});
|
|
226
232
|
app.querySelector('#mmodel').addEventListener('input', () => { renderDrop(); app.querySelector('#model-drop').style.display = 'block'; });
|
|
227
233
|
app.querySelector('#mmodel').addEventListener('blur', () => setTimeout(() => { app.querySelector('#model-drop').style.display = 'none'; }, 120));
|
|
228
234
|
app.querySelector('#mkey').addEventListener('input', () => { // 密钥开始填了就别挡模型框
|
|
@@ -260,9 +266,12 @@ async function render() {
|
|
|
260
266
|
renderDrop(); app.querySelector('#model-drop').style.display = 'block';
|
|
261
267
|
});
|
|
262
268
|
app.querySelector('#smoke').onclick = async () => {
|
|
263
|
-
app.querySelector('#smoke-out')
|
|
269
|
+
const out = app.querySelector('#smoke-out');
|
|
270
|
+
out.textContent = '测试中…';
|
|
264
271
|
const r = await api('/llm-smoke', { method: 'POST', body: JSON.stringify({ base_url: app.querySelector('#murl').value, model: app.querySelector('#mmodel').value, api_key: app.querySelector('#mkey').value }) });
|
|
265
|
-
|
|
272
|
+
out.innerHTML = r.ok
|
|
273
|
+
? `连接成功<br>发送:${esc(r.sent)}<br>回复:${esc(r.reply || '(空回复)')}`
|
|
274
|
+
: `连接失败:${esc(r.error)}`;
|
|
266
275
|
};
|
|
267
276
|
app.querySelector('#save').onclick = async () => {
|
|
268
277
|
const targets = [...app.querySelectorAll('[data-h]:checked')].map((x) => x.dataset.h);
|
package/client/public/index.html
CHANGED
|
@@ -87,6 +87,7 @@ datalist { display: none; }
|
|
|
87
87
|
.frow input[type=text], .frow input:not([type]), .frow .combo { flex: 1; min-width: 0; }
|
|
88
88
|
.frow button { flex: none; }
|
|
89
89
|
.fhint { flex: none; font-size: 14px; color: var(--color-accent); font-weight: 600; }
|
|
90
|
+
.fsub { flex-basis: 100%; margin: 2px 0 0 88px; font-size: 13.5px; color: var(--color-ink-mut); line-height: 1.55; }
|
|
90
91
|
label.check { display: flex; gap: 10px; align-items: center; padding: 7px 4px; cursor: pointer; border-radius: 6px; }
|
|
91
92
|
label.check:hover { background: color-mix(in oklch, var(--color-ink) 4%, var(--color-surface)); }
|
|
92
93
|
|