dsh-fish-soul 0.19.11 → 0.19.12

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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  让一个 QQ 小号背后有"同一个人":固定人格、按人记记忆、有自己的生活节奏、会主动开口;同一个"她"同时出现在 QQ、B站、抖音。
4
4
 
5
- DSH 插件(单角色 `feiyu`)。版本 **0.19.11**。
5
+ DSH 插件(单角色 `feiyu`)。版本 **0.19.12**。
6
6
 
7
7
  QQ 交流群:**1125962189**
8
8
 
@@ -78,6 +78,13 @@ window.__ModuleLoader__.load({
78
78
  const anyPrice = models.some(([m]) => (Number(prices[m]?.in) || 0) > 0 || (Number(prices[m]?.out) || 0) > 0);
79
79
  const modelStatus = data.modelStatus ?? {};
80
80
  const today = data.todayUsage ?? { calls: 0, tokens: 0 };
81
+ // #239:失败数要能看出「是持续在坏,还是某一天炸过一次」——否则一个三天前的大数字
82
+ // 会让人以为现在的代码有毛病。只有 daily 里真的有 failed 字段时才提示。
83
+ const dailyFailed = (u.daily ?? []).filter((d) => (d.failed ?? 0) > 0);
84
+ const worstDay = dailyFailed.length > 0 ? dailyFailed.reduce((a, b) => ((b.failed ?? 0) > (a.failed ?? 0) ? b : a)) : null;
85
+ const failedTotal = dailyFailed.reduce((s, d) => s + (d.failed ?? 0), 0);
86
+ const failRate = (f) => (f.failed > 0 && f.calls > 0 ? Math.round((f.failed / f.calls) * 100) : null);
87
+ const failText = (f) => (f.failed > 0 ? `(失败 ${f.failed}${failRate(f) !== null ? ` · ${failRate(f)}%` : ""})` : "");
81
88
  async function savePrice(model) {
82
89
  const p = prices[model] ?? {};
83
90
  const inVal = Number(p.in);
@@ -104,6 +111,11 @@ window.__ModuleLoader__.load({
104
111
  Group({ title: "用量", aside: h(Seg, { label: "时间范围", value: range, onChange: setRange, options: [{ value: "7", label: "7 天" }, { value: "30", label: "30 天" }] }) },
105
112
  Row({ title: "合计", meta: estimated ? "有的模型没报用量,按字数估的" : undefined },
106
113
  Muted(`${t.calls} 次 · 输入 ${fmtTok(t.in)} · 输出 ${fmtTok(t.out)} token`), anyPrice ? Tag(`约 ${fmtCost(t.cost)}`, "info") : null),
114
+ // #239:失败集中在哪一天要说出来,否则「失败 1005 次」会被当成当下的状态
115
+ worstDay ? Row({ title: "失败", meta: `这 ${u.days} 天累计失败 ${failedTotal} 次${dailyFailed.length === 1 ? "(全在同一天)" : `,分布在 ${dailyFailed.length} 天`}` },
116
+ Muted(worstDay.failed === failedTotal
117
+ ? `${worstDay.day} 一天就占满(${worstDay.failed} 次 / 当天 ${worstDay.calls} 次调用)—— 别按这个数字判断现在的代码`
118
+ : `最多的一天是 ${worstDay.day}:${worstDay.failed} 次(当天 ${worstDay.calls} 次调用)`)) : null,
107
119
  Row({ title: "每日后台上限", meta: `今日已用 ${today.calls} 次 · ${fmtTok(today.tokens)} token(0 = 不限)` },
108
120
  Num({ min: 0, max: 100000, step: 10, value: budget.dailyCalls || "", placeholder: "次数/天", "aria-label": "每日调用上限",
109
121
  onChange: (e) => setBudget((b) => ({ ...b, dailyCalls: e.target.value })), onBlur: saveBudget }),
@@ -112,7 +124,7 @@ window.__ModuleLoader__.load({
112
124
  features.length === 0 ? Empty("这段时间还没调用过模型") : h("div", { className: "fs-list" }, features.map(([id, f]) => h("div", { className: "fs-item", key: id },
113
125
  h("span", { className: "fs-item-main" }, labels[id] ?? id),
114
126
  h("span", { className: "fs-item-meta" },
115
- h("span", null, `${f.calls} 次${f.failed ? `(失败 ${f.failed})` : ""}`),
127
+ h("span", null, `${f.calls} 次${failText(f)}`),
116
128
  h("span", null, `${fmtTok(f.in + f.out)} token`),
117
129
  anyPrice ? h("span", null, fmtCost(f.cost)) : null))))),
118
130
  models.length === 0 ? null : Group({ title: "单价", aside: Muted("元 / 百万 token,填了才算花费") },
@@ -122,7 +134,7 @@ window.__ModuleLoader__.load({
122
134
  h("span", { className: "fs-item-main", title: m }, m),
123
135
  h("span", { className: "fs-item-meta" },
124
136
  st ? Tag(st.cooling ? `冷却 ${Math.max(1, Math.ceil(st.cooldownMs / 60000))}m` : `连败 ${st.streak}`, "warning") : null,
125
- h("span", null, `${x.calls} 次${x.failed ? `(失败 ${x.failed})` : ""}`),
137
+ h("span", null, `${x.calls} 次${failText(x)}`),
126
138
  h("span", null, `${fmtTok(x.in + x.out)} token`),
127
139
  priceInput(m, "in", "输入"), priceInput(m, "out", "输出"),
128
140
  h("span", null, fmtCost(x.cost))));
@@ -414,6 +414,9 @@ window.__ModuleLoader__.load({
414
414
  h("span", { className: "fs-unit", title: "群里不会想起私聊说的事" }, "群"),
415
415
  h(Switch, { label: "在群里", checked: inGroup, onChange: setInGroup }),
416
416
  Button({ disabled: busy || text.trim() === "", onClick: run }, busy ? "想…" : "试一下")),
417
+ // #241:这里只测「这一句」本身;真实对话还会带上最近几句上下文(composeQuery),
418
+ // 所以这边的召回结果会比实战「干净」——写成提示,别让人拿它当真实召回的下限。
419
+ Muted("这里只按这一句检索;真实对话会带上最近几句(指代、追问会重复一次),实际召回可能不同——这里看到的不代表实战一定也这样。"),
417
420
  res === null ? null : h("div", { className: "fs-list" },
418
421
  res.recalled.length === 0 ? Empty("什么都想不起来") : res.recalled.map((m) => row(m, `#${m.rank}`, "success")),
419
422
  ...(res.others ?? []).slice(0, 8).map((m) => row(m, "没想起", "outline")),
package/lib/llm.js CHANGED
@@ -503,7 +503,7 @@ export class LlmRouter {
503
503
  for (let i = days - 1; i >= 0; i--) {
504
504
  const d = dayKey(now - i * 86400_000);
505
505
  const day = getKv(this.db, `usage.${d}`, {}) ?? {};
506
- let calls = 0; let tokens = 0; let dayCost = 0;
506
+ let calls = 0; let tokens = 0; let dayCost = 0; let dayFailed = 0;
507
507
  for (const [feature, f] of Object.entries(day)) {
508
508
  const bf = byFeature[feature] ?? { calls: 0, failed: 0, in: 0, out: 0, estimated: 0, cost: 0 };
509
509
  bf.calls += f.calls; bf.failed += f.failed; bf.in += f.in; bf.out += f.out; bf.estimated += f.estimated ?? 0;
@@ -515,9 +515,9 @@ export class LlmRouter {
515
515
  byModel[model] = bm;
516
516
  }
517
517
  byFeature[feature] = bf;
518
- calls += f.calls; tokens += f.in + f.out;
518
+ calls += f.calls; tokens += f.in + f.out; dayFailed += Number(f.failed) || 0;
519
519
  }
520
- daily.push({ day: d, calls, tokens, cost: dayCost });
520
+ daily.push({ day: d, calls, tokens, cost: dayCost, failed: dayFailed });
521
521
  }
522
522
  const total = Object.values(byFeature).reduce((s, f) => ({ calls: s.calls + f.calls, in: s.in + f.in, out: s.out + f.out, cost: s.cost + f.cost }), { calls: 0, in: 0, out: 0, cost: 0 });
523
523
  return { days, byFeature, byModel, daily, total, prices };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-fish-soul",
3
- "version": "0.19.11",
3
+ "version": "0.19.12",
4
4
  "description": "鱼 · 人格、按人记忆(可纠正、有印象、能导入旧聊天记录)、日程自走与主动开口,直连 SnowLuma 收发 QQ(群里会自己插话),B站 / 抖音小号私信与自己刷视频;按功能选模型并统计用量花费,能听会说 QQ 语音、收藏表情包、学群里的梗,可选上网查;心情影响说话、去 AI 味、每个群的设定、按聊天选模型、每晚写日记、每周记忆存档与可选周记(DSH 插件,单角色 feiyu ,v0.18.23)",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",