@lynn123411/dsh-a6api 1.5.1 → 1.5.2

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/index.js CHANGED
@@ -386,6 +386,17 @@ function formatCnyPrice(micros, exchangeRate = 6.7209) {
386
386
  if (cny < 1) return `\xA5${cny.toFixed(4)}`;
387
387
  return `\xA5${cny.toFixed(3)}`;
388
388
  }
389
+ var BLENDED_OUT_SHARE = 35e-4;
390
+ function computeBlendedPrice100m(inMicros, cacheReadMicros, outMicros, cacheHitRatePct, exchangeRate) {
391
+ const inY = inMicros / 1e6 * exchangeRate;
392
+ const hitY = cacheReadMicros / 1e6 * exchangeRate;
393
+ const outY = outMicros / 1e6 * exchangeRate;
394
+ if (inY <= 0 && hitY <= 0 && outY <= 0) return void 0;
395
+ const h = Math.min(1, Math.max(0, cacheHitRatePct / 100));
396
+ const inShare = 1 - BLENDED_OUT_SHARE;
397
+ const per1M = h * inShare * hitY + (1 - h) * inShare * inY + BLENDED_OUT_SHARE * outY;
398
+ return per1M * 100;
399
+ }
389
400
  function buildWebHeaders2(userId, accessToken) {
390
401
  const headers = {
391
402
  Accept: "application/json",
@@ -648,6 +659,7 @@ async function fetchChannelDetails(channelId, userId, accessToken, targetModelNa
648
659
  const recentSuccessRate = item.recent_success_rate !== void 0 ? Number(item.recent_success_rate) / 100 : 100;
649
660
  const cacheHitRate = item.cache_hit_rate_24h !== void 0 ? Number(item.cache_hit_rate_24h) / 100 : 72;
650
661
  const lastSuccessAt = Number(item.last_success_at || item.last_test_time || 0);
662
+ const blended100m = computeBlendedPrice100m(inMicros, cacheReadMicros, outMicros, cacheHitRate, rate);
651
663
  const ratioCny = Number(item.realtime_ratio_cny || inMicros / 1e6 * rate || 0.0341);
652
664
  const ratioFormatted = ratioCny.toFixed(4);
653
665
  return {
@@ -686,6 +698,7 @@ async function fetchChannelDetails(channelId, userId, accessToken, targetModelNa
686
698
  p50_ttft_ms: Number(item.p50_ttft_ms || 2273),
687
699
  recent_p50_ms: Number(item.recent_p50_ms || item.last_test_response_ms || 2340),
688
700
  cache_hit_rate_pct: cacheHitRate,
701
+ blended_price_100m_cny: blended100m,
689
702
  labels,
690
703
  last_success_at: lastSuccessAt,
691
704
  last_success_text: formatRelativeTime(lastSuccessAt),
@@ -756,6 +769,7 @@ async function fetchChannelDetails(channelId, userId, accessToken, targetModelNa
756
769
  recent_p50_ms: Number(logSnapshot.use_time ? logSnapshot.use_time * 1e3 : 2340),
757
770
  p50_ttft_ms: 2273,
758
771
  cache_hit_rate_pct: 72,
772
+ blended_price_100m_cny: computeBlendedPrice100m(inMicros, cacheReadMicros, outMicros, 72, rate),
759
773
  labels: ["\u7A33\u5B9A", "\u4F4E\u4EF7", "\u9AD8\u901F", "\u9AD8\u8D28"],
760
774
  last_success_at: Math.floor(Date.now() / 1e3),
761
775
  last_success_text: "\u521A\u521A",