mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-16 07:33:06 +08:00
用量行新增 requested_reasoning_effort,记录分组策略与模型族改写前的客户端请求值;推理强度列与模型列一致,主行显示请求值,有映射时用 ↳ 展示实际转发值。
45 lines
1005 B
Go
45 lines
1005 B
Go
package service
|
|
|
|
import "strings"
|
|
|
|
func optionalTrimmedStringPtr(raw string) *string {
|
|
trimmed := strings.TrimSpace(raw)
|
|
if trimmed == "" {
|
|
return nil
|
|
}
|
|
return &trimmed
|
|
}
|
|
|
|
func optionalStringValue(value *string) string {
|
|
if value == nil {
|
|
return ""
|
|
}
|
|
return strings.TrimSpace(*value)
|
|
}
|
|
|
|
// coalesceRequestedReasoningEffort prefers the client-requested value and falls
|
|
// back to the effective/forwarded effort for historical or unmapped rows.
|
|
func coalesceRequestedReasoningEffort(requested, forwarded *string) *string {
|
|
if trimmed := optionalStringValue(requested); trimmed != "" {
|
|
return &trimmed
|
|
}
|
|
if trimmed := optionalStringValue(forwarded); trimmed != "" {
|
|
return &trimmed
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func forwardResultBillingModel(requestedModel, upstreamModel string) string {
|
|
if trimmed := strings.TrimSpace(requestedModel); trimmed != "" {
|
|
return trimmed
|
|
}
|
|
return strings.TrimSpace(upstreamModel)
|
|
}
|
|
|
|
func optionalInt64Ptr(v int64) *int64 {
|
|
if v == 0 {
|
|
return nil
|
|
}
|
|
return &v
|
|
}
|