mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-11-01 00:27:30 +00:00
feat(usage): 使用记录展示映射前的推理强度
用量行新增 requested_reasoning_effort,记录分组策略与模型族改写前的客户端请求值;推理强度列与模型列一致,主行显示请求值,有映射时用 ↳ 展示实际转发值。
This commit is contained in:
@@ -211,11 +211,15 @@ export function parseDateTimeLocalInput(value: string): number | null {
|
||||
* @param effort 原始 effort(如 "low" / "medium" / "high" / "xhigh")
|
||||
* @returns 格式化后的字符串(Low / Medium / High / Xhigh),无值返回 "-"
|
||||
*/
|
||||
function normalizeReasoningEffortKey(effort: string | null | undefined): string {
|
||||
return (effort ?? '').toString().trim().toLowerCase().replace(/[-_\s]/g, '')
|
||||
}
|
||||
|
||||
export function formatReasoningEffort(effort: string | null | undefined): string {
|
||||
const raw = (effort ?? '').toString().trim()
|
||||
if (!raw) return '-'
|
||||
|
||||
const normalized = raw.toLowerCase().replace(/[-_\s]/g, '')
|
||||
const normalized = normalizeReasoningEffortKey(raw)
|
||||
switch (normalized) {
|
||||
case 'low':
|
||||
return 'Low'
|
||||
@@ -237,6 +241,31 @@ export function formatReasoningEffort(effort: string | null | undefined): string
|
||||
}
|
||||
}
|
||||
|
||||
export function reasoningEffortValuesEqual(
|
||||
left: string | null | undefined,
|
||||
right: string | null | undefined,
|
||||
): boolean {
|
||||
const a = normalizeReasoningEffortKey(left)
|
||||
const b = normalizeReasoningEffortKey(right)
|
||||
if (!a && !b) return true
|
||||
return a !== '' && a === b
|
||||
}
|
||||
|
||||
/** Requested vs forwarded effort for usage export; one value when they match. */
|
||||
export function formatReasoningEffortMapping(
|
||||
requested: string | null | undefined,
|
||||
forwarded: string | null | undefined,
|
||||
): string {
|
||||
const requestedLabel = formatReasoningEffort(requested)
|
||||
const forwardedLabel = formatReasoningEffort(forwarded)
|
||||
if (requestedLabel === '-' && forwardedLabel === '-') return '-'
|
||||
if (requestedLabel === '-' || reasoningEffortValuesEqual(requested, forwarded)) {
|
||||
return forwardedLabel === '-' ? requestedLabel : forwardedLabel
|
||||
}
|
||||
if (forwardedLabel === '-') return requestedLabel
|
||||
return `${requestedLabel} → ${forwardedLabel}`
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化时间(显示时分秒)
|
||||
* @param date 日期字符串或 Date 对象
|
||||
|
||||
Reference in New Issue
Block a user