dsh-multi-router 0.6.2 → 0.6.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/lib/client.js CHANGED
@@ -29,6 +29,7 @@ __export(client_exports, {
29
29
  ModelsPanel: () => ModelsPanel,
30
30
  PluginUpdatesPanel: () => PluginUpdatesPanel,
31
31
  RestartGuidance: () => RestartGuidance,
32
+ RouteReasoningSelect: () => RouteReasoningSelect,
32
33
  RouterPage: () => RouterPage,
33
34
  RoutesTable: () => RoutesTable,
34
35
  SidebarUsage: () => SidebarUsage,
@@ -49,7 +50,7 @@ module.exports = __toCommonJS(client_exports);
49
50
  var import_react = require("react");
50
51
 
51
52
  // package.json
52
- var version = "0.6.2";
53
+ var version = "0.6.3";
53
54
 
54
55
  // src/client.jsx
55
56
  var import_jsx_runtime = require("react/jsx-runtime");
@@ -2321,6 +2322,66 @@ function FreeRouteForm({ draft, setDraft, data, act, busy, error, notice }) {
2321
2322
  ] })
2322
2323
  ] });
2323
2324
  }
2325
+ function RouteReasoningSelect({ draft, setDraft, data, busy }) {
2326
+ const targets = draft.targets.map((t) => ({
2327
+ provider: t.provider,
2328
+ ...t.account ? { account: t.account } : {},
2329
+ models: t.modelText.split(",").map((x) => x.trim()).filter(Boolean)
2330
+ }));
2331
+ const signature = JSON.stringify({
2332
+ action: "route.preview",
2333
+ revision: data.revision,
2334
+ catalogs: data.accounts?.map((a) => [a.id, a.enabled, a.fetchedAt]),
2335
+ id: draft.id || "preview",
2336
+ route: {
2337
+ contextMode: draft.contextMode ?? "maximum",
2338
+ contextWindow: draft.contextWindow,
2339
+ maxTokens: 1,
2340
+ targets: targets.map(({ models, ...target }) => ({ ...target, ...models.length ? { models } : {} }))
2341
+ }
2342
+ });
2343
+ const [preview, setPreview] = (0, import_react.useState)(null);
2344
+ (0, import_react.useEffect)(() => {
2345
+ const abort = new AbortController();
2346
+ const timer = setTimeout(async () => {
2347
+ try {
2348
+ const res = await fetch(ENDPOINT, {
2349
+ method: "POST",
2350
+ signal: abort.signal,
2351
+ headers: { "Content-Type": "application/json", "X-Multi-Router-Key": data.key },
2352
+ body: signature
2353
+ });
2354
+ const next = await readManagementResponse(res);
2355
+ if (!abort.signal.aborted) setPreview({ signature, ...next.routePreview });
2356
+ } catch (e) {
2357
+ if (!abort.signal.aborted) setPreview({ signature, error: e.message });
2358
+ }
2359
+ }, 250);
2360
+ return () => {
2361
+ clearTimeout(timer);
2362
+ abort.abort();
2363
+ };
2364
+ }, [signature, data.key]);
2365
+ const pending = preview?.signature !== signature, modes = pending ? [] : preview?.reasoning?.supportedEfforts ?? [];
2366
+ const effort = draft.reasoningEffort ?? "", unavailable = !!effort && !pending && !preview?.error && !modes.includes(effort);
2367
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "box stack", children: [
2368
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [
2369
+ "\u9ED8\u8BA4\u601D\u8003\u6DF1\u5EA6",
2370
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", { "aria-describedby": "route-reasoning-help", disabled: busy || pending || !!preview?.error, value: effort, onChange: (e) => setDraft((d) => ({ ...d, reasoningEffort: e.target.value || null })), children: [
2371
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "", children: "\u5E73\u53F0\u9ED8\u8BA4" }),
2372
+ effort && !modes.includes(effort) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("option", { value: effort, disabled: true, children: [
2373
+ effortNames[effort] || effort,
2374
+ "\uFF08",
2375
+ pending ? "\u6838\u5BF9\u4E2D" : "\u5F53\u524D\u4E0D\u53EF\u7528",
2376
+ "\uFF09"
2377
+ ] }),
2378
+ modes.map((e) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: e, children: effortNames[e] || e }, e))
2379
+ ] })
2380
+ ] }),
2381
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { id: "route-reasoning-help", className: preview?.error || unavailable ? "warn notice" : "notice", role: "status", children: pending ? "\u6B63\u5728\u6838\u5BF9\u76EE\u6807\u6A21\u578B\u652F\u6301\u7684\u6863\u4F4D\u2026" : preview?.error || (unavailable ? "\u539F\u6863\u4F4D\u5F53\u524D\u4E0D\u53EF\u7528\uFF0C\u8BF7\u9009\u62E9\u5176\u4ED6\u6863\u4F4D\u6216\u5E73\u53F0\u9ED8\u8BA4\u3002" : !preview?.contextKnown ? "\u5C1A\u672A\u83B7\u53D6\u76EE\u6807\u6A21\u578B\u76EE\u5F55\uFF0C\u6682\u65F6\u53EA\u80FD\u4F7F\u7528\u5E73\u53F0\u9ED8\u8BA4\u3002" : !modes.length ? "\u76EE\u6807\u6A21\u578B\u672A\u58F0\u660E\u53EF\u8C03\u6863\u4F4D\uFF0C\u4F7F\u7528\u5E73\u53F0\u9ED8\u8BA4\u3002" : "\u4EC5\u5C55\u793A\u5F53\u524D\u76EE\u6807\u4E0E\u4E0A\u4E0B\u6587\u5BB9\u91CF\u652F\u6301\u7684\u6863\u4F4D\u3002") }),
2382
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "notice", children: "\u4F1A\u8BDD\u91CC\u624B\u52A8\u9009\u62E9\u7684\u6863\u4F4D\u4F18\u5148\u3002\u6307\u5B9A\u6DF1\u5EA6\u540E\uFF0C\u4EC5\u5728\u652F\u6301\u8BE5\u6863\u4F4D\u7684\u8D26\u53F7\u95F4\u5207\u6362\uFF1B\u5173\u95ED\u601D\u8003\u4EC5\u5728\u6E20\u9053\u652F\u6301\u65F6\u63D0\u4F9B\u3002" })
2383
+ ] });
2384
+ }
2324
2385
  function RouteForm({ draft, setDraft, data, act, busy, error, notice }) {
2325
2386
  if (draft.freeOnly) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FreeRouteForm, { draft, setDraft, data, act, busy, error, notice });
2326
2387
  const set = (key, value) => setDraft((d) => ({ ...d, [key]: value }));
@@ -2351,6 +2412,7 @@ function RouteForm({ draft, setDraft, data, act, busy, error, notice }) {
2351
2412
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { required: true, maxLength: 200, value: draft.name, disabled: busy, onChange: (e) => set("name", e.target.value), placeholder: "\u4F8B\u5982 \u6211\u7684 Flash \u81EA\u52A8\u5207\u6362" })
2352
2413
  ] }),
2353
2414
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "notice", children: "\u540D\u79F0\u663E\u793A\u5728 DSH \u6A21\u578B\u5217\u8868\u4E2D\uFF0C\u53EF\u968F\u65F6\u4FEE\u6539\uFF0C\u4E0D\u5F71\u54CD\u5DF2\u6709\u4F1A\u8BDD\u7684\u8DEF\u7531\u9009\u62E9\u3002" }),
2415
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RouteReasoningSelect, { draft, setDraft, data, busy }),
2354
2416
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [
2355
2417
  "\u8D26\u53F7\u5207\u6362\u89C4\u5219",
2356
2418
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", { disabled: busy, value: draft.strategy, onChange: (e) => set("strategy", e.target.value), children: Object.entries(strategies).map(([id, label]) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: id, children: label }, id)) })