@yzj01/llm-router 1.0.2 → 1.0.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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { T as Tier, R as RawConfig, b as PhysicalModel, P as ProxyOptions, a as ProxyHandle, c as TraceMode, d as TraceLogger, C as ConfigSource, e as PublicModelConfig } from './proxy-CpR5cxND.js';
2
- export { D as DEFAULT_SESSION_CONFIG, f as PublicModelMetadata, g as RouteTraceLog, S as SessionConfig, h as SessionEntry, i as SessionStats, j as SessionStore, k as TierEntry, l as TraceAttempt, m as TraceReason, n as TraceSessionAction, o as TraceSummaryInput, p as TraceWriter, V as VERSION, q as buildTraceSummary, r as deriveSessionId, s as emitRouteTrace, t as getPromptPreview, u as hashRequestContent, v as normalizeTraceMode, w as resolveTraceWriter, x as startProxy } from './proxy-CpR5cxND.js';
1
+ import { T as Tier, R as RawConfig, b as PhysicalModel, P as ProxyOptions, a as ProxyHandle, c as TraceMode, d as TraceLogger, C as ConfigSource, e as PublicModelConfig } from './proxy-B7j2DcEK.js';
2
+ export { D as DEFAULT_SESSION_CONFIG, f as PublicModelMetadata, g as RouteTraceLog, S as SessionConfig, h as SessionEntry, i as SessionStats, j as SessionStore, k as TierEntry, l as TraceAttempt, m as TraceReason, n as TraceSessionAction, o as TraceSummaryInput, p as TraceWriter, V as VERSION, q as buildTraceSummary, r as deriveSessionId, s as emitRouteTrace, t as getPromptPreview, u as hashRequestContent, v as normalizeTraceMode, w as resolveTraceWriter, x as startProxy } from './proxy-B7j2DcEK.js';
3
3
 
4
4
  /**
5
5
  * 路由层只关心 alias 的成本画像,因此这里的 key 是 public alias,而不是
package/dist/index.js CHANGED
@@ -1643,7 +1643,7 @@ function hashHex(value, length) {
1643
1643
  }
1644
1644
 
1645
1645
  // src/proxy.ts
1646
- var VERSION = "1.0.2";
1646
+ var VERSION = "1.0.3";
1647
1647
  var HOP_BY_HOP = /* @__PURE__ */ new Set([
1648
1648
  "connection",
1649
1649
  "keep-alive",
@@ -1747,7 +1747,9 @@ function extractPrompt(messages) {
1747
1747
  const parts = [];
1748
1748
  let system;
1749
1749
  let openingText = "";
1750
- let lastUserText = "";
1750
+ let routeUserText = "";
1751
+ let previousRole;
1752
+ let previousUserText = "";
1751
1753
  for (const msg of messages) {
1752
1754
  if (!msg || typeof msg !== "object") continue;
1753
1755
  const role = msg.role;
@@ -1766,15 +1768,21 @@ ${text2}` : text2;
1766
1768
  } else {
1767
1769
  parts.push(text2);
1768
1770
  if (role === "user" && text2.trim()) {
1769
- lastUserText = extractRouteTextFromUserMessage(text2);
1771
+ if (previousRole === "user" && previousUserText.trim()) {
1772
+ routeUserText = previousUserText;
1773
+ } else {
1774
+ routeUserText = extractRouteTextFromUserMessage(text2);
1775
+ }
1770
1776
  }
1771
1777
  if (!openingText && text2.trim()) {
1772
1778
  openingText = text2;
1773
1779
  }
1774
1780
  }
1781
+ previousRole = role;
1782
+ previousUserText = role === "user" ? extractRouteTextFromUserMessage(text2) : "";
1775
1783
  }
1776
1784
  const text = parts.join(" ");
1777
- return { text, routeText: lastUserText || text, system, openingText };
1785
+ return { text, routeText: routeUserText || text, system, openingText };
1778
1786
  }
1779
1787
  function buildUpstreamHeaders(req, cfg) {
1780
1788
  const headers = {};