- windsurf_gateway_service: 添加上游延迟/TTFT/错误上下文记录 - endpoint: DeriveUpstreamEndpoint 添加 PlatformWindsurf 分支 - ops_error_logger: guessPlatformFromPath 添加 /windsurf/ 识别
18 lines
278 B
Go
18 lines
278 B
Go
package windsurf
|
|
|
|
func EstimateTokens(chars int) int {
|
|
t := (chars + 3) / 4
|
|
if t < 1 {
|
|
return 1
|
|
}
|
|
return t
|
|
}
|
|
|
|
func EstimateInputTokensFromMessages(msgs []ChatMessage) int {
|
|
chars := 0
|
|
for _, m := range msgs {
|
|
chars += len(m.Content)
|
|
}
|
|
return EstimateTokens(chars)
|
|
}
|