dsh-modelscope-pool 0.10.2 → 0.10.3
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/README.md +2 -2
- package/lib/index.js +48 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
### 方式一:从 npm 安装(推荐)
|
|
122
122
|
|
|
123
123
|
```bash
|
|
124
|
-
dsh plugin --profile web add dsh-modelscope-pool@0.10.
|
|
124
|
+
dsh plugin --profile web add dsh-modelscope-pool@0.10.3
|
|
125
125
|
```
|
|
126
126
|
|
|
127
127
|
一条命令搞定。装好后重启 App(或让插件重新加载),网关会在 `127.0.0.1:8899` 起来。
|
|
@@ -334,7 +334,7 @@ dsh-go 里更进一步:这个插件会把自己注册成一个叫 **魔搭 Key
|
|
|
334
334
|
看看是不是被「手动禁用」了(`manual` 标记)。手动禁用不会被自动恢复流程放开,需要点「恢复」。
|
|
335
335
|
|
|
336
336
|
**点「刷新额度」提示「魔搭 Key 池没有响应」?**
|
|
337
|
-
App 要求点按在 3 秒内返回,而刷新额度要联网逐个查所有 Key 的额度,早就超过 3 秒了。0.10.
|
|
337
|
+
App 要求点按在 3 秒内返回,而刷新额度要联网逐个查所有 Key 的额度,早就超过 3 秒了。0.10.3 起这几个慢操作(刷新额度 / 测试全部 / 重新拉取模型 / 添加 Key)不再在点按里等:点一下立刻在**面板顶部**显示「正在刷新额度」,**3 秒后自动收起**(操作不会中断),跑完再把结果挂上去 3 秒。如果你还在 0.10.0 或更早,升级即可。
|
|
338
338
|
|
|
339
339
|
**端口被占用?**
|
|
340
340
|
改 `config.json` 的 `port`,同时把客户端和供应商配置里的地址一起改掉。
|
package/lib/index.js
CHANGED
|
@@ -144,6 +144,48 @@ export function apply(ctx) {
|
|
|
144
144
|
})
|
|
145
145
|
let refreshPanel = () => {}
|
|
146
146
|
let refreshStrip = () => {}
|
|
147
|
+
|
|
148
|
+
// 慢操作的顶部提示:写进 data.hint,3 秒后自动收起(后台任务不中断)。
|
|
149
|
+
// 必须放在这一层:buildData 在外面读它,放进 inject 回调里会变成未定义变量。
|
|
150
|
+
let notice = ''
|
|
151
|
+
let noticeUntil = 0
|
|
152
|
+
const noticeNow = () => (noticeUntil > Date.now() ? notice : '')
|
|
153
|
+
let noticeTimer = null
|
|
154
|
+
const kicks = new Set()
|
|
155
|
+
const setNotice = (text, ms = 3000) => {
|
|
156
|
+
notice = String(text ?? '')
|
|
157
|
+
noticeUntil = notice ? Date.now() + ms : 0
|
|
158
|
+
try {
|
|
159
|
+
refreshPanel()
|
|
160
|
+
} catch {}
|
|
161
|
+
try {
|
|
162
|
+
refreshStrip()
|
|
163
|
+
} catch {}
|
|
164
|
+
// 立刻推一次:点下就能看到,不用等下一次心跳。
|
|
165
|
+
for (const kick of kicks) {
|
|
166
|
+
try {
|
|
167
|
+
kick()
|
|
168
|
+
} catch {}
|
|
169
|
+
}
|
|
170
|
+
// 到点主动推一次,让提示正好在 3 秒收起,而不是等下一次 1.5 秒心跳。
|
|
171
|
+
if (noticeTimer) clearTimeout(noticeTimer)
|
|
172
|
+
noticeTimer = null
|
|
173
|
+
if (noticeUntil > 0) {
|
|
174
|
+
noticeTimer = setTimeout(() => {
|
|
175
|
+
noticeTimer = null
|
|
176
|
+
if (noticeUntil > Date.now()) return
|
|
177
|
+
try {
|
|
178
|
+
refreshPanel()
|
|
179
|
+
} catch {}
|
|
180
|
+
for (const kick of kicks) {
|
|
181
|
+
try {
|
|
182
|
+
kick()
|
|
183
|
+
} catch {}
|
|
184
|
+
}
|
|
185
|
+
}, ms + 60)
|
|
186
|
+
if (typeof noticeTimer.unref === 'function') noticeTimer.unref()
|
|
187
|
+
}
|
|
188
|
+
}
|
|
147
189
|
// Key 级无感路由:模型不变,只换 Key。
|
|
148
190
|
const router = createRouter({ logger })
|
|
149
191
|
|
|
@@ -718,14 +760,19 @@ const modelRowOf = (entry, current, t) => {
|
|
|
718
760
|
ready
|
|
719
761
|
.then(() => {
|
|
720
762
|
tick()
|
|
763
|
+
kicks.add(tick)
|
|
721
764
|
const timer = setInterval(tick, 1500)
|
|
722
765
|
if (typeof timer.unref === 'function') timer.unref()
|
|
723
|
-
stop = () =>
|
|
766
|
+
stop = () => {
|
|
767
|
+
kicks.delete(tick)
|
|
768
|
+
clearInterval(timer)
|
|
769
|
+
}
|
|
724
770
|
})
|
|
725
771
|
.catch(() => {})
|
|
726
772
|
let stop = () => {}
|
|
727
773
|
return () => {
|
|
728
774
|
stopped = true
|
|
775
|
+
kicks.delete(tick)
|
|
729
776
|
stop()
|
|
730
777
|
}
|
|
731
778
|
}
|
|
@@ -733,15 +780,6 @@ const modelRowOf = (entry, current, t) => {
|
|
|
733
780
|
// 点按必须 3 秒内返回,否则 App 会提示「没有响应」。
|
|
734
781
|
// 联网的慢操作因此不在点按里等:先把一句话挂到面板顶部(data.hint),
|
|
735
782
|
// 3 秒后自动收起,真正的活儿在后台继续跑,跑完再挂一句结果,同样 3 秒收起。
|
|
736
|
-
let notice = ''
|
|
737
|
-
let noticeUntil = 0
|
|
738
|
-
const setNotice = (text, ms = 3000) => {
|
|
739
|
-
notice = String(text ?? '')
|
|
740
|
-
noticeUntil = notice ? Date.now() + ms : 0
|
|
741
|
-
refreshPanel()
|
|
742
|
-
refreshStrip()
|
|
743
|
-
}
|
|
744
|
-
const noticeNow = () => (noticeUntil > Date.now() ? notice : '')
|
|
745
783
|
const running = new Set()
|
|
746
784
|
const runInBackground = (key, label, work) => {
|
|
747
785
|
if (running.has(key)) return { toast: label }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-modelscope-pool",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.3",
|
|
4
4
|
"description": "魔搭多 Key 聚合网关:无感路由(模型不变,Key 遇限流/额度不足/无权限/不存在自动换下一个);自动识别国际版/国内版令牌;单个 Key 可禁用/停用/恢复/删除/查看;全部密钥分页浏览;模型实际拉取国际版+国内版合并成简化名、按站点分组;额度低于 2 停用到次日 00:01、多 Key 轮换、限流临时失败冷却 5 分钟,并注册为 DSH 模型供应商",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Yizutt",
|