skillmkt 0.2.8 → 0.2.9
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/public/app.js +19 -4
- package/client/public/index.html +2 -0
- package/package.json +1 -1
package/client/public/app.js
CHANGED
|
@@ -148,10 +148,10 @@ 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
|
<label class="field">服务地址</label><input type="text" id="murl" placeholder="http://localhost:1234/v1" value="${esc(cfg.llm?.base_url || '')}">
|
|
151
|
+
<label class="field">访问密钥 <span class="field-hint" id="key-hint"></span></label><input type="text" id="mkey" value="${esc(cfg.llm?.api_key || '')}">
|
|
152
|
+
<p class="mut">本机服务一般留空。填了密钥会用本机机器码加密后存入 config.yml——文件拷到别的机器解不开,换机需重填。</p>
|
|
151
153
|
<label class="field">模型名称</label><input type="text" id="mmodel" list="model-opts" placeholder="可输入关键字搜索,扫描后自动列出发现的模型" value="${esc(cfg.llm?.model || '')}">
|
|
152
154
|
<datalist id="model-opts"></datalist>
|
|
153
|
-
<label class="field">访问密钥</label><input type="text" id="mkey" value="${esc(cfg.llm?.api_key || '')}">
|
|
154
|
-
<p class="mut">本机服务一般留空。填了密钥会用本机机器码加密后存入 config.yml——文件拷到别的机器解不开,换机需重填。</p>
|
|
155
155
|
<div class="row"><button id="smoke">测试连接</button><span id="smoke-out" class="mut"></span></div></div>
|
|
156
156
|
<div class="card"><h3>第 2 步 · skill 默认安装位置</h3>
|
|
157
157
|
<p class="mut">勾选的 AI 工具会在你安装新 skill 时自动收到一份副本。已勾过的话保存即生效。</p>
|
|
@@ -187,6 +187,7 @@ async function render() {
|
|
|
187
187
|
app.querySelectorAll('#eps .ep').forEach((x) => x.classList.remove('sel'));
|
|
188
188
|
d.classList.add('sel');
|
|
189
189
|
app.querySelector('#murl').value = d.dataset.b;
|
|
190
|
+
markKeyNeed(epsList.find((e) => e.base_url === d.dataset.b)?.needs_key);
|
|
190
191
|
refreshOpts();
|
|
191
192
|
});
|
|
192
193
|
};
|
|
@@ -195,19 +196,33 @@ async function render() {
|
|
|
195
196
|
const b = modelMap.get(e.target.value);
|
|
196
197
|
if (b) { app.querySelector('#murl').value = b; refreshOpts(); }
|
|
197
198
|
});
|
|
199
|
+
// 填完服务地址自动检测是否需要密钥:已知端点直接看 needs_key,手输地址真发 /models 探
|
|
200
|
+
const markKeyNeed = (need) => {
|
|
201
|
+
app.querySelector('#mkey').classList.toggle('req', !!need);
|
|
202
|
+
app.querySelector('#key-hint').textContent = need ? '← 此服务需要密钥' : '';
|
|
203
|
+
};
|
|
198
204
|
app.querySelector('#murl').addEventListener('input', () => refreshOpts());
|
|
205
|
+
app.querySelector('#murl').addEventListener('change', async () => {
|
|
206
|
+
const cur = app.querySelector('#murl').value.trim().replace(/\/+$/, '');
|
|
207
|
+
const ep = epsList.find((e) => e.base_url === cur);
|
|
208
|
+
if (ep) return markKeyNeed(ep.needs_key);
|
|
209
|
+
if (!/^https?:\/\//.test(cur)) return markKeyNeed(false);
|
|
210
|
+
const r = await api('/models', { method: 'POST', body: JSON.stringify({ base_url: cur, api_key: '' }) });
|
|
211
|
+
markKeyNeed(!!r.error && /401|403/.test(r.error));
|
|
212
|
+
});
|
|
199
213
|
// 需要密钥的端点:密钥填完自动拉它的模型列表
|
|
200
214
|
app.querySelector('#mkey').addEventListener('change', async () => {
|
|
201
215
|
const cur = app.querySelector('#murl').value.trim().replace(/\/+$/, '');
|
|
202
216
|
const ep = epsList.find((e) => e.base_url === cur);
|
|
203
217
|
const key = app.querySelector('#mkey').value.trim();
|
|
204
|
-
if (!ep?.needs_key || !
|
|
218
|
+
if (!key || !(ep?.needs_key || (!ep && /^https?:\/\//.test(cur)))) return;
|
|
205
219
|
const out = app.querySelector('#smoke-out');
|
|
206
220
|
out.textContent = '读取模型列表…';
|
|
207
221
|
const r = await api('/models', { method: 'POST', body: JSON.stringify({ base_url: cur, api_key: key }) });
|
|
208
222
|
if (r.models?.length) {
|
|
209
223
|
for (const m of r.models) { modelMap.set(m, cur); loadedModels.set(m, cur); }
|
|
210
|
-
ep.needs_key = false; ep.models = r.models;
|
|
224
|
+
if (ep) { ep.needs_key = false; ep.models = r.models; }
|
|
225
|
+
markKeyNeed(false);
|
|
211
226
|
refreshOpts();
|
|
212
227
|
out.textContent = `已加载 ${r.models.length} 个模型`;
|
|
213
228
|
} else out.textContent = r.error ? `读取失败:${r.error}` : '密钥通了,但没读到模型';
|
package/client/public/index.html
CHANGED
|
@@ -71,6 +71,8 @@ input[type=text], input:not([type]), textarea, select {
|
|
|
71
71
|
border-radius: 8px; background: var(--color-paper); color: var(--color-ink); }
|
|
72
72
|
textarea { min-height: 7rem; resize: vertical; font-family: var(--font-mono); font-size: 14.5px; }
|
|
73
73
|
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--color-accent); margin-right: 2px; }
|
|
74
|
+
input.req { border-color: var(--color-accent); box-shadow: 0 0 0 3px color-mix(in oklch, var(--color-accent) 16%, transparent); }
|
|
75
|
+
.field-hint { font-size: 14px; color: var(--color-accent); font-weight: 600; }
|
|
74
76
|
label.check { display: flex; gap: 10px; align-items: center; padding: 7px 4px; cursor: pointer; border-radius: 6px; }
|
|
75
77
|
label.check:hover { background: color-mix(in oklch, var(--color-ink) 4%, var(--color-surface)); }
|
|
76
78
|
|